Build alerts & dashboards with Grafana Terraform provider
Configure the Grafana Terraform provider
For instructions on how to generate a Grafana Service Account Token and use it in the Grafana Terraform provider, see: Grafana Service Account Token.
Dashboard provisioning example
Create a directory for the terraform assets
mkdir groundcover-tf-example && cd groundcover-tf-exampleCreate a
main.tffile within the directory that contains the terraform provider configuration mentioned in step 2Create the following
dashboards.tffile, this example declares a newGolden Signalsfolder, and within it aWorkload Golden Signalsdashboard that will be created
resource "grafana_folder" "goldensignals" {
title = "Golden Signals"
}
resource "grafana_dashboard" "workloadgoldensignals" {
config_json = file("workloadgoldensignals.json")
folder = grafana_folder.goldensignals.id
}add the
workloadgoldensignals.jsonfile to the directory as well
Run
terraform initto initialize terraform contextRun
terraform plan, you should see a long output describing the assets that are going to be created last line should statePlan: 2 to add, 0 to change, 0 to destroy.Run
terraform applyto execute the changes, you should now see a new folder in your grafana dashboards screen with the newly created dashboardRun
terraform destroyto revert the changes
Here is a short video to demonstrate the process
You can read more about what you can achieve with the Grafana Terraform provider in the official docs
Last updated
