---
title: "Alerting pipeline in Terraform | Grafana Labs"
description: "How alert notifications are routed in Terraform"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

## How the alerting pipeline works

The notification policy tree starts with a default route. All alerts enter at the top and flow down through nested policies until they match. The first matching policy determines which contact point receives the notification.

Labels on the alert rule, like `severity = "warning"`, are what the notification policy matches against. This is why consistent labeling matters: it’s the contract between your alert rules and your notification routing.

## Example: a Slack contact point

A contact point defines a notification destination. This example sends alerts to a Slack channel.

hcl ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```hcl
resource "grafana_contact_point" "slack_alerts" {
  name = "Slack alerts"

  slack {
    url     = var.slack_webhook_url
    title   = "{{ .CommonLabels.alertname }}"
    text    = "{{ .CommonAnnotations.description }}"
  }
}
```

## Example: a notification policy

A notification policy routes alerts to contact points based on label matching. This example routes critical alerts to PagerDuty and everything else to Slack.

hcl ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```hcl
resource "grafana_notification_policy" "main" {
  contact_point = grafana_contact_point.slack_alerts.name
  group_by      = ["alertname"]

  policy {
    matcher {
      label = "severity"
      match = "="
      value = "critical"
    }
    contact_point = grafana_contact_point.pagerduty.name
  }
}
```
