Managing dashboards and alerts with Terraform or Ansible
As dashboards are typically managed by the teams responsible for a service or application, it is best practice to separate the tooling to deploy dashboards from the tooling to manage observability infrastructure. We will discuss the practicalities of this in Chapter 14.
For managing dashboards, both Terraform and Ansible leverage the fact that Grafana dashboards are JSON objects, providing a mechanism to upload a JSON file with the dashboard configuration to the Grafana instance. Let’s look at how this works.
The Terraform code looks like this:
resource "grafana_dashboard" "top_level " { config_json = file("top-level.json") overwrite = true }
A collection of dashboard JSON files can be iterated over using the Terraform fileset
function with a for_each
command. This makes it very easy for a team to manage all its dashboards in an automated manner by saving...