Intro to Observability as Code: Managing Dashboards with GitOps

Observability as code brings the same benefits we expect from infrastructure as code — versioning, reviewability, repeatability — to dashboards, alerting rules, and other observability configuration. Instead of clicking in a GUI to create panels, teams store dashboard definitions and related config in Git, let a GitOps controller reconcile those files into running systems, and treat dashboards as reviewable, auditable artifacts. This approach reduces drift, makes rollbacks trivial, and integrates dashboard changes into standard CI/CD workflows. (grafana.com)

Why this matters

Key building blocks

Patterns for managing dashboards with GitOps Below are patterns you’ll see in real-world projects, and when to use each.

A minimal repo layout (example)

Sample GrafanaDashboard CRD (simplified)

apiVersion: integreatly.org/v1alpha1
kind: GrafanaDashboard
metadata:
  name: k8s-cluster-overview
  namespace: monitoring
spec:
  json: |
    {
      "title": "Kubernetes cluster overview",
      "panels": [
        {
          "type": "graph",
          "title": "CPU usage",
          "targets": [{ "expr": "sum(rate(container_cpu_usage_seconds_total[5m])) by (pod)" }]
        }
      ]
    }

This CRD-style manifest can be applied by a GitOps controller and reconciled by the Grafana Operator into a running dashboard. The exact CRD group/version may vary by operator release. (grafana.github.io)

Choosing a GitOps controller: ArgoCD vs Flux

A simple GitOps workflow (high level)

  1. Author dashboard JSON (or JSONNet/YAML/CRD) in a branch.
  2. Open a pull request describing intent and queries changed.
  3. Run CI checks (linting, schema validation, and rendering tests).
  4. Merge to main — the GitOps controller detects the change and reconciles it into the cluster or pushes it to Grafana.
  5. Monitor the controller’s sync status and dashboard health; if something breaks, revert the commit and the controller rolls back the running config.

Testing and CI for dashboards

Tooling and templating options

Best practices (practical, battle-tested)

Handling drift, secrets, and multi-tenant setups

Common pitfalls and how teams mitigate them

A short checklist before you adopt

Closing thoughts Managing dashboards with GitOps reframes dashboards from ephemeral dashboards to first-class, versioned artifacts. The immediate wins — reproducible dashboards, audit trails, and simple rollbacks — are obvious. The bigger win is cultural: you change dashboard edits from “I clicked something” to “I opened a PR,” which invites review, sanity checking, and better collaboration across teams.

If you’re starting, pick one dashboard or folder, move it into a repo, add a simple CI check, and let a GitOps controller reconcile it. The pattern scales: teams that adopt observability as code find fewer surprises in production and a much clearer history of why metric views changed over time. (grafana.com)