Files
Pepe Cano ec42b2a361 Alerting docs: restructure Introduction (#84248)
* Rename `Data sources` title

* Relocate and rename `Introduction/Notification templates`

* Rename `alert-rules/alert-instances` to `alert-rules/multi-dimensional-alerts`

* Move `fundamentals/high-availability` to `setup/enable-ha`

* Fix 404 high-availability alerting link on Setup HA Grafana docs

* Move alert manager/contact poitns/notification templates within Notifications

* Remove `Alerting on numeric data`

* Restructure Introduction v2

* Continue Intro restructuring

* Update docs/sources/alerting/fundamentals/alert-rules/_index.md

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* Complete contact point TODO

* Alias: alertManager

* Aliases `annotation-label` + content changes

* Aliases to `templating-labels-annotations`

* Aliases to `queries-conditions`

* Rename `rule-evaluation.md` file

* Aliases: `contact points`

* Aliases to `message-templating`

* Aliases to `alert-rules`

* Update links to new URL slugs

* Remove duplicated alias

* Remove trailing slash for external heading links

* Remove trailing slash in heading links to other grafana pages

* Change URL directory slug `fundamentals/notifications`

* rename title `Configure High Availability`

* Content changes

* Update docs/sources/alerting/fundamentals/alert-rules/_index.md

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* Update docs/sources/alerting/set-up/configure-alert-state-history/index.md

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* Update docs/sources/alerting/set-up/configure-high-availability/_index.md

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* Update docs/sources/alerting/set-up/configure-alert-state-history/index.md

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* Update docs/sources/alerting/set-up/configure-high-availability/_index.md

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* Update docs/sources/alerting/set-up/configure-high-availability/_index.md

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* Update docs/sources/alerting/set-up/configure-high-availability/_index.md

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* Update docs/sources/alerting/fundamentals/alert-rules/_index.md

Co-authored-by: Jack Baldry <jack.baldry@grafana.com>

* Fix broken link reference

* Fix `queries-and-conditions`

* Fix `alert-rule-evaluation` ref link

* Fix aliases + inline doc comments

* Fix broken link

---------

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Jack Baldry <jack.baldry@grafana.com>
2024-03-14 16:58:18 +01:00

3.4 KiB

aliases canonical description keywords labels title weight
../../contact-points/message-templating/
../../alert-rules/message-templating/
../../unified-alerting/message-templating/
https://grafana.com/docs/grafana/latest/alerting/fundamentals/notifications/message-templating/ Learn about notification templating
grafana
alerting
guide
contact point
templating
products
cloud
enterprise
oss
Notification templates 114

Notification templates

Notifications sent via contact points are built using notification templates. Grafana's default templates are based on the Go templating system where some fields are evaluated as text, while others are evaluated as HTML (which can affect escaping).

The default template default_template.go is a useful reference for custom templates.

Since most of the contact point fields can be templated, you can create reusable custom templates and use them in multiple contact points.

Using templates

The following example shows how to use default templates to render an alert message in Slack. The message title contains a count of alerts that are firing or were resolved. The message body lists the alerts and their status.

{{< figure src="/static/img/docs/alerting/unified/contact-points-template-fields-8-0.png" class="docs-image--no-shadow" max-width= "550px" caption="Default template" >}}

The following example shows the use of a custom template within one of the contact point fields.

{{< figure src="/static/img/docs/alerting/unified/contact-points-use-template-8-0.png" class="docs-image--no-shadow" max-width= "550px" caption="Default template" >}}

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
default.title Displays high-level status information.
default.message Provides a formatted summary of firing and resolved alerts.
teams.default.message Similar to default.message, formatted for Microsoft Teams.

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.