Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Prometheus & Monitoring Difficulty: Advanced ClaudeChatGPT

Grafana Dashboards as Code with Grafonnet Prompt

Generate maintainable, DRY Grafana dashboards as code with Grafonnet/Jsonnet — reusable panel libraries, templated rows, and a CI pipeline that lints and diffs dashboards on every PR.

Target user
Platform teams managing many dashboards who are tired of clicking in the UI
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a Grafana-as-code expert who has replaced hundreds of hand-clicked dashboards with a small, composable Jsonnet library.

I will provide:
- The dashboards I want to codify (or screenshots/JSON exports)
- My data sources and label conventions
- How dashboards are currently managed and deployed

Your job:

1. **Make the case** — explain why Grafonnet/Jsonnet beats clicking and beats raw JSON: DRY panels, code review, env templating, and bulk refactors across N dashboards at once. Be honest about the learning curve and when a simpler tool (the Foundation SDK, or provisioned JSON) is enough.

2. **Library structure** — design a repo layout: a shared `lib/` of reusable panel/row functions (a standard RED panel, a USE row, a SLO header), per-service dashboard files that compose them, and a `vendor/` pinned via jsonnet-bundler (`jb`). Show the import graph.

3. **Parameterize** — make panels take `datasource`, `job`, and label selectors as arguments so one definition renders for every service. Show a templated variable (`$namespace`, `$service`) wired through the queries.

4. **A real panel** — produce a Grafonnet snippet for a latency panel (histogram_quantile p50/p90/p99) and a request-rate/error-rate RED row, with thresholds and units set in code.

5. **Build & deploy** — the pipeline: `jb install` → render with `jsonnet`/`grizzly` → validate the output JSON → apply via the Grafana API, Grizzly, or file-based provisioning. Cover environment overlays (staging vs prod data sources).

6. **CI guardrails** — lint with `jsonnetfmt`, render in CI, and DIFF the produced dashboard JSON against what's deployed so reviewers see the visual delta. Fail PRs that change a dashboard without regenerating.

7. **Migration** — import existing dashboards: convert exported JSON to a starting Jsonnet file, then refactor the repeated panels into the library incrementally.

Output: the repo layout, the reusable library functions, one full example dashboard composed from them, the jsonnet-bundler + render + deploy commands, and the CI lint/diff steps.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Related prompts

More Prometheus & Monitoring prompts & error guides

Browse every Prometheus & Monitoring prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.