Open source Enterprise Grafana Cloud
Last reviewed: August 19, 2026

Templates

Templating shows up in two places in a data source-managed setup. They look alike—both use Go template syntax—but they’re evaluated by different systems at different times, and the data available to each is different.

The two contexts

Rule annotations and labelsNotification templates
Evaluated byThe rulerAlertmanager
Evaluated whenEvery rule evaluationEvery notification sent
ScopeOne alert instanceA whole group of alerts
Key variables$labels, $value.Alerts, .GroupLabels, .CommonLabels
Configured inThe rule, on the Rules pageThe Alertmanager config, on the Templates page

Rule annotations and labels

The ruler renders these when it evaluates the rule, so the result is baked into the alert before Alertmanager ever sees it. The template has access to exactly one alert instance: its labels and its value.

Go
{{ $labels.instance }} is using {{ $value | printf "%.1f" }}% of its disk.

Because this runs on every evaluation, keep it cheap and simple. Refer to Template annotations and labels.

Notification templates

Alertmanager renders these when it sends a notification, which happens after grouping. The template therefore sees a group of alerts, not one, and its job is to format that group into a message.

Go
{{ define "slack.summary" }}
{{ .Alerts | len }} alert(s) firing for {{ .GroupLabels.alertname }}
{{ range .Alerts }}- {{ .Annotations.summary }}
{{ end }}{{ end }}

Notice that this template reads .Annotations.summary, the output of the rule-level template from the previous step. The two stack: the ruler produces per-alert text, and Alertmanager assembles those into a message. Refer to Notification templates.

Which one do you want?

  • To change what a single alert says about itself, edit the rule’s annotations.
  • To change how a batch of alerts is laid out in Slack or email, edit a notification template.

A common mistake is reaching for a notification template to add information the alert never carried. If the data isn’t in the alert’s labels or annotations, no notification template can recover it. It has to be added at the rule.