Notification templating
This documentation topic is designed for Grafana workspaces that support Grafana version 10.x.
For Grafana workspaces that support Grafana version 9.x, see Working in Grafana version 9.
For Grafana workspaces that support Grafana version 8.x, see Working in Grafana version 8.
Notifications sent via contact points are built using notification templates.
Grafana’s default templates are based on the Go templating system
The default template default_template.go
Since most of the contact point fields can be templated, you can create reusable custom templates and use them in multiple contact points. To learn about custom notifications using templates, see Customize notifications.
Nested templates
You can embed templates within other templates.
For example, you can define a template fragment using the
define
keyword.
{{ define "mytemplate" }} {{ len .Alerts.Firing }} firing. {{ len .Alerts.Resolved }} resolved. {{ end }}
You can then embed custom templates within this fragment using the
template
keyword. For example:
Alert summary: {{ template "mytemplate" . }}
You can use any of the following built-in template options to embed custom templates.
Name | Notes |
---|---|
|
Displays high-level status information. |
|
Provides a formatted summary of firing and resolved alerts. |
|
Similar to |
HTML in notification templates
HTML in alerting notification templates is escaped. We do not support rendering of HTML in the resulting notification.
Some notifiers support alternative methods of changing the look and feel
of the resulting notification. For example, Grafana installs the base
template for alerting emails to
<grafana-install-dir>/public/emails/ng_alert_notification.html
.
You can edit this file to change the appearance of all alerting
emails.