Ask or search…
Comment on page

Build alerts & dashboards with Grafana Terraform provider

Step 1 - generate Grafana Service Account Token

groundcover version
  • Generate service account token
groundcover auth generate-service-account-token
Service Account Token are only accessible once, so make sure you keep them somewhere safe, running the command again will generate a new service account token
Only groundcover tenant admins can generate Service Account Tokens

Step 2 - Use Grafana Terraform provider

terraform {
required_providers {
grafana = {
source = "grafana/grafana"
provider "grafana" {
url = ""
auth = "{service account token}"

Step 3 - Dashboard provisioning example

  • Create a directory for the terraform assets
    mkdir groundcover-tf-example && cd groundcover-tf-example
  • Create a file within the directory that contains the terraform provider configuration mentioned in step 2
  • Create the following file, this example declares a new Golden Signals folder, and within it a Workload Golden Signals dashboard that will be created
resource "grafana_folder" "goldensignals" {
title = "Golden Signals"
resource "grafana_dashboard" "workloadgoldensignals" {
config_json = file("workloadgoldensignals.json")
folder =
  • add the workloadgoldensignals.json file to the directory as well
  • Run terraform init to initialize terraform context
  • Run terraform plan , you should see a long output describing the assets that are going to be created last line should state Plan: 2 to add, 0 to change, 0 to destroy.
  • Run terraform apply to execute the changes, you should now see a new folder in your grafana dashboards screen with the newly created dashboard
  • Run terraform destroy to 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