Interview Prep/Monitoring & Observability/Observability as Code, Security & Vendor Choices

How do you manage Grafana with Terraform?

IntermediateProductionObservability as Code, Security & Vendor Choices
Answer

The official grafana/grafana provider manages folders, dashboards, data sources, teams, permissions and Grafana-managed alerting resources. Dashboard JSON stays in the repo and is loaded with file().

resource "grafana_folder" "payments" {
  title = "Payments"
}

resource "grafana_dashboard" "checkout" {
  folder      = grafana_folder.payments.uid
  config_json = file("${path.module}/dashboards/checkout.json")
  overwrite   = true
}

Strip id and version from exported JSON and keep a stable uid so links survive. Use one Terraform state per Grafana instance or organisation, and a service account token stored in the CI secret store.

All Monitoring & Observability questions

More on Observability as Code, Security & Vendor Choices