Dashboards and alert rules managed by hand won't survive long. This episode covers GitOps for observability, the Grafana Terraform provider, automated testing and linting in pipelines, and Jsonnet with Grafonnet for dashboards as code.

Dashboards edited by clicking through the UI are easily broken and hard to trace. In a dynamic environment, observability must be managed like code: committed to git, reviewed, tested, then deployed automatically. This is the core of GitOps for observability.
This episode covers GitOps principles, using the Grafana Terraform provider, integrating testing into CI/CD, and Jsonnet and Grafonnet for programmable dashboards.
git commit -> review -> merge -> apply to GrafanaThe git commit -> review -> merge -> apply pattern ensures no change slips through without a trace.
The Grafana Terraform provider manages data sources, dashboards, and alert rules:
provider "grafana" {
url = "http://localhost:3000"
auth = var.grafana_api_token
}
resource "grafana_data_source" "mimir" {
type = "prometheus"
name = "Mimir"
url = "http://mimir:9009/prometheus"
}The block resource "grafana_data_source" "mimir" creates the Mimir data source declaratively — it can be recreated in any environment.
grafana_rule_group.terraform init
terraform apply -auto-approveThe terraform apply -auto-approve command applies the entire observability configuration to Grafana.
steps:
- name: Lint dashboard
run: jq empty dashboards/*.json
- name: Validate alert rules
run: terraform validateThe Lint dashboard stage in the pipeline rejects pull requests with broken dashboard JSON from the start.
Never put Grafana tokens in the repository. Use secrets from the CI environment and limit the service account scope.
Jsonnet is a templating language that extends JSON, and Grafonnet is a Jsonnet library for Grafana dashboards:
local grafana = import "grafonnet/grafana.libsonnet";
{
grafanaDashboard('Checkout Overview')
.addTimeSeries('Request Rate', { datasource: '$Mimir' })
}The code grafanaDashboard('Checkout Overview') builds dashboards from reusable components.
Tip
Start with Terraform for data sources and alert rules, then move up to Jsonnet/Grafonnet when the number of dashboards grows and becomes repetitive. The balance between simplicity and templating power is the key.
In episode 30 you understood GitOps principles with dashboards and alert rules as code, using the Grafana Terraform provider for data sources and dashboards, automated testing and linting in CI/CD pipelines, and Jsonnet and Grafonnet for programmable dashboards.
The key takeaways:
In the next episode 31 we'll discuss advanced Grafana features — unified alerting, the Explore interface, transformations and overrides in dashboards, the plugin ecosystem, and enterprise features. The Grafana you've been using is far deeper than it looks.