Grafana Cloud Prometheus Alertmanager Contact Point

Hi,

I’m trying to set up contact points using Terraform automation for Grafana Cloud. However, with my current configuration, the contact points are being created under Grafana Alertmanager, which is not what I want.

I’m using Grafana’s managed Prometheus for metrics, which comes with many built-in default alerts. I’d like to route these alerts to a Slack channel, but since my current code creates contact points specifically under Grafana Alertmanager, they don’t apply to the Prometheus-managed alerts.

So far, I haven’t found any Terraform documentation or examples on how to create contact points and notification policies specifically for Prometheus Alertmanager in Grafana Cloud.

Here’s the current setup I’m using in Terraform:

// Lets Create the Contact Point
resource “grafana_contact_point” “slack_alert_contact_point” {
provider = grafana.stack
name = “Slack Alert Contact Point”

slack {
url = var.slackWebhook
recipient = “#alert_dev_channel
icon_url = “https://avatars3.githubusercontent.com/u/123456
title = <<-EOT
[{{ .Status | toUpper }}{{ if eq .Status “firing” }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }}
EOT
text = <<-EOT
{{ range .Alerts -}}
Alert: {{ .Annotations.title }}{{ if .Labels.severity }} - {{ .Labels.severity }}{{ end }}
Description: {{ .Annotations.description }}
Details:
{{- if .Labels.namespace }} • Namespace: {{ .Labels.namespace }}{{ end }}
{{- if .Labels.service }} • Service: {{ .Labels.service }}{{ end }}
{{- if .Labels.eksCluster }} • Cluster: {{ .Labels.eksCluster }}{{ end }}
{{ end }}
EOT
}
}

// Lets connect the contact point with the default notification policy
resource “grafana_notification_policy” “default_notification_policy” {
provider = grafana.stack
group_by = [“alertname”]
contact_point = grafana_contact_point.slack_alert_contact_point.name

policy {
  matcher {
    label = "namespace"
    match = "="
    value = "synthetic"
  }
  group_by = ["grafana_folder"]
  continue = true

  group_wait       =  "1s"
  group_interval   =  "1s"
  repeat_interval  =  "1m"
}

}

and this code creates the contact point and notification policy under Grafana alert manager, not Prometheus alert manager.

Grafana Terraform provider can provision only to Grafana embedded Alertmanager. You need to use mimirtool or 3-rd party Terraform provider that can provision to Mimir.

1 Like