DevTools Logo

Grafana Panel Generator

Grafana Panel Generator

Build Grafana panel or importable dashboard JSON, with datasource references and thresholds.

Runs in your browser
Try an example

Panel settings

24-column grid

Panel JSON

58 lines · 1,006 chars
Panel JSON can be pasted into a panel's JSON editor or added to a dashboard's panels array. It cannot be imported on its own: choose Dashboard JSON for that.
The first threshold step is the base step: its value (0) is written as null, and applies to every value below the next step.
Queries are not parsed or run here. Only bracket and quote balance is checked; Grafana reports query errors when the panel loads.

Examples

Timeseries request rate

Input
generateGrafanaPanelJSON({ title: "Request rate", type: "timeseries", unit: "reqps", gridPos: { w: 12, h: 8, x: 0, y: 0 }, targets: [{ expr: "rate(http_requests_total[5m])" }] })
Output
targets: [{ refId: "A" }], fieldConfig.defaults.unit: "reqps"

The first target auto-labels A and the unit lands in field defaults for axis formatting.

Gauge with two queries

Input
generateGrafanaPanelJSON({ title: "Saturation", type: "gauge", gridPos: { w: 6, h: 8, x: 0, y: 0 }, targets: [{ expr: "up" }, { expr: "down" }] })
Output
type: "gauge", refIds: ["A", "B"]

Gauge rendering applies while both queries keep deterministic A/B references for overrides.

About this tool

Grafana Panel Generator builds import-ready dashboard panels with generateGrafanaPanelJSON(config): the output keys fix deterministically to type/title/datasource/fieldConfig/options/gridPos/targets, options default legend to list/bottom/showLegend with multi/desc tooltip and area graphMode, and targets auto-assign refIds A, B, C… unless overridden. fieldConfig.defaults carries unit, min/max, absolute threshold steps, and any field overrides.

Validation with validateGrafanaPanel enforces the 24-column grid (finite w/h/x/y, positive w/h, x + w within 0–24), strictly increasing threshold values, and a fixed recognized color set (green/red/yellow/orange/blue/purple/pink/grey/gray/transparent). Any violation flips valid to false with field-tagged issues — panels outside the grid or with flat thresholds never silently pass.

Panel types span timeseries, stat, gauge, barGauge, table, and logs, so the same config shape covers graphs, single-stats, gauges, and log views. Generation is deterministic — identical configs serialize byte-identically — and fully local, so queries and titles never leave the browser.

How to use this tool

  1. Choose type and queries

    Pick timeseries, stat, gauge, barGauge, table, or logs, then add one target per query — refIds assign A/B automatically.

  2. Set units and thresholds

    Enter the unit (e.g. ms, reqps), min/max, and threshold steps in strictly increasing value order with recognized colors.

  3. Place on the 24-column grid

    Size gridPos so x + w stays within 0–24, then import the JSON into a dashboard or provision it as code.

Use cases

Scaffolding timeseries dashboards

Generate legend/tooltip-complete panels for request-rate, latency, and error-ratio graphs.

Adding gauge and stat rows

Render saturation or availability snapshots with threshold-colored gauges from the same schema.

Provisioning panels as code

Check deterministic panel JSON into version control for repeatable dashboard provisioning.

Common mistakes

Mistake:Overflowing the 24-column grid.

Fix:x + w must stay within 0–24 (e.g. w 13 at x 12 fails) — shrink w or move x left instead of assuming w + h is the constraint.

Mistake:Repeating or decreasing threshold values.

Fix:Steps must be strictly increasing — equal or falling values report Threshold values must be in strictly increasing order.

Mistake:Using arbitrary threshold color names.

Fix:Only the built-in palette (green, red, yellow, orange, blue, purple, pink, grey/gray, transparent) validates — ultraviolet and similar names fail.

Frequently asked questions

What does this tool do?

It builds import-ready panel JSON with generateGrafanaPanelJSON (fixed key order, legend/tooltip defaults, unit/min/max/thresholds in field defaults, auto refIds A/B/…) and validates with validateGrafanaPanel (24-column grid, increasing thresholds, recognized colors and types).

What grid and threshold rules apply?

w/h must be positive and x + w must stay within 0–24 (w 13 at x 12 fails). Threshold values must be strictly increasing, and colors must come from the built-in palette — ultraviolet fails as Unrecognized.

Is my dashboard data uploaded or stored?

No. Generation and validation run entirely in your browser — queries, titles, and units never leave your device.

Are refIds and output deterministic?

Yes. Targets without explicit refIds assign A, B, C… in order, and identical configs serialize byte-identically, so the JSON is safe to snapshot and provision as code.

References & standards