Grafana Cloud Enterprise Open source

Notification template reference

By default, Grafana provides predefined templates to format notification messages.

You can also customize your notifications with custom templates, which are based on the Go template language.

This documentation lists the data available for use in notification templates.

Notification Data

In notification templates, dot (.) is initialized with the following data:

NameTypeDescription
ReceiverstringThe name of the contact point sending the notification
StatusstringThe status is firing if at least one alert is firing, otherwise resolved.
Alerts[]AlertList of all firing and resolved alerts in this notification.
Alerts.Firing[]AlertList of all firing alerts in this notification.
Alerts.Resolved[]AlertList of all resolved alerts in this notification.
GroupLabelsKVThe labels that group these alerts in this notification based on the Group by option.
CommonLabelsKVThe labels common to all alerts in this notification.
CommonAnnotationsKVThe annotations common to all alerts in this notification.
ExternalURLstringA link to Grafana, or the Alertmanager that sent this notification if using an external Alertmanager.
GroupKeystringThe key used to identify this alert group.
TruncatedAlertsintegerThe number of alerts, if any, that were truncated in the notification. Supported by Webhook and OnCall.

It’s important to remember that a single notification can group multiple alerts to reduce the number of alerts you receive. Alerts is an array that includes all the alerts in the notification.

Here’s an example that prints all available notification data from dot (.):

Go
{{ define "custom_template" }}
  {{ .Receiver }}
  {{ .Status }}
  There are {{ len .Alerts }} alerts
  There are {{ len .Alerts.Firing }} firing alerts
  There are {{ len .Alerts.Resolved }} resolved alerts
  {{ .GroupLabels }}
  {{ .CommonLabels }}
  {{ .CommonAnnotations }}
  {{ .ExternalURL }}
{{ end }}

You can execute this template by passing the dot (.):

Go
{{ template "custom_template" . }}

Alert

Alert contains data for an individual alert:

NameTypeDescription
StatusstringFiring or resolved.
LabelsKV