Section 2 · Grafana resources and Terraform

Hands-on path to deploy an alert rule with Terraform

Estimated time: 2 min

Learning path: Deploy an alert rule with Terraform

Path: Deploy an alert rule with Terraform

The following table describes the steps you’ll work through in the path.

StepWhat you’ll doOutcome
1. Why Terraform?Understand why Terraform is a natural fit for deploying alerting resourcesContext for choosing Terraform over manual workflows
2. Create a service accountSet up API credentials in Grafana for TerraformA service account token for authentication
3. Configure the providerDeclare the Grafana Terraform provider and authenticateTerraform connected to your Grafana instance
4. Define a folder and an alert rule groupCreate a folder to organize your alert rules, anda grafana_rule_group with a CPU usage alertAn organizational folder and alert rule ready to deploy in Grafana
5. Add a contact pointDefine a grafana_contact_point for Slack or emailA notification destination configured
6. Add a notification policyRoute alerts to the contact point based on labelsA complete alerting pipeline
7. Run terraform planPreview what Terraform will create in GrafanaConfidence in what will change before applying
8. Apply and verifyRun terraform apply and confirm the resources appear in GrafanaA live alerting pipeline deployed from code

Before you start

Have these ready before you open the path:

  • A Grafana Cloud account or self-managed Grafana instance (version 12 or higher)
  • Terraform installed (version 1.0 or later)
  • A data source configured in Grafana (for example, Prometheus or Grafana TestData)
  • Admin or Editor permissions on your Grafana instance
Learning path

Deploy an alert rule with Terraform

Deploy a complete Grafana alerting pipeline using the Terraform provider.

17 min
Advanced
Docs & blog posts

Open in Grafana Cloud

Complete this learning path directly in your Grafana Cloud stack with an interactive learning experience.