The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templat...

137 lines
6.7 KiB

[v11.3.x] Alerting Docs: Update Alert rule and Notification Templating (#95242) Alerting Docs: Update Alert rule and Notification Templating (#94069) * Update links to the new location of the Templates intro page * Set alert rule template structure * Update the `Template notifications` structure/sidebar * Move examples to examples pages * Update menu titles and URL paths * WIP reference * added intro to examples.md * reference page section intros * examples title * Template * Continue Alert Template Reference * example sections * Almost finish with Reference page * weight pages * WIP - template variables Intro * Edits Alert rule templates + Differences with notification templates * examples-draft-2 * how to map annotations to notif templates * examples v2 * moved example * Continue Template annotations and labels * Preview annotation templates * Complete `Template annotations and labels` * Update `Differences with notification templates` * Polish a bit `Differences with notification tempaltes` * added logic examples to `Examples` * Finish sharing Template language * Minor: set `anchor` link * Minor edit * Minor edit * Minor changes * Template language changes * Document missing functions for alert rule templates * 'Examples' v3 * `Examples` v3.1 * `Examples` v3.2 * added context/intro to `Examples` * added a how to section to `Examples` * moved legacy info in `Examples` * added examples, sections in `Examples` * formatting * examples v5 * examples v5.1 * Complete update to `Notification template reference` * Update `$values` description * moved steps to `index` * fixed urls * removed section in `examples` * added refs * fixed urls * refs fix * blended the use case into the explanation * Notification template reference: Minor readibility changes * Edit `$value` in Alert rule template reference * Edit `Manage notification templates * links to ref and lang pages * Minor copy changes * Edit Template annotation overview + Prepare Template notifications overview * `Select` vs `Choose` * Template Overview * Fix `heading` does not match `title` * examples v6 * examples v6.1 * Fix spell errors * Run `prettier --write` to fix md format errors * examples v7 * examples v7.1 * examples v7.2 * examples v7.4 * examples v7.5 * examples v7.6 * all pretty, no pity * Update alert rule examples * Complete `Labels and annotations template examples` * Minor changes * Use `.` notation instead of `index` in examples * rename `extendeddata` to `notificationdata` * Complete Notification examples * minor changes * Set `go` language when displaying template examples * Revert "minor changes" This reverts commit f647c55c8718a4b5c5ab51b3ef88ef0605de3c84. * Update example and admonition for consistency * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/shared/alerts/template-language.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/shared/alerts/template-language.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/language.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/examples.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/examples.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/examples.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/examples.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/examples.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * use `add` instead of `enrich` * fix prettier content errors * minor copy change * Specify which Alert properties are exclusive to Grafana-managed alerts * Use `Monitor` instead of `Meta monitoring` * Be more detailed about notifation template limitations --------- Co-authored-by: tonypowa <tonypowa@gmail.com> Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> (cherry picked from commit 813632dff13f69c84daf328a6562c660d1b19016)
8 months ago
---
aliases:
- ../../manage-notifications/template-notifications/create-notification-templates/ # /docs/grafana/<GRAFANA_VERSION>/alerting/manage-notifications/template-notifications/create-notification-templates/
- ../../manage-notifications/template-notifications/use-notification-templates/ # /docs/grafana/<GRAFANA_VERSION>/alerting/manage-notifications/template-notifications/use-notification-templates/
- ../../configure-notifications/template-notifications/use-notification-templates/ # /docs/grafana/<GRAFANA_VERSION>/alerting/manage-notifications/template-notifications/use-notification-templates/
- ../../configure-notifications/template-notifications/create-notification-templates/ # /docs/grafana/<GRAFANA_VERSION>/alerting/manage-notifications/template-notifications/create-notification-templates/
canonical: https://grafana.com/docs/grafana/latest/alerting/configure-notifications/template-notifications/manage-notification-templates/
description: Create notification templates to sent to your contact points
keywords:
- grafana
- alerting
- notifications
- templates
- create templates
- edit templates
- delete templates
labels:
products:
- cloud
- enterprise
- oss
title: Manage notification templates
menuTitle: Manage templates
weight: 101
refs:
notification-template-reference:
- pattern: /docs/grafana/
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/configure-notifications/template-notifications/reference/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana-cloud/alerting-and-irm/alerting/configure-notifications/template-notifications/reference/
notification-template-examples:
- pattern: /docs/grafana/
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/configure-notifications/template-notifications/examples/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana-cloud/alerting-and-irm/alerting/configure-notifications/template-notifications/examples/
[v11.3.x] Alerting Docs: Update Alert rule and Notification Templating (#95242) Alerting Docs: Update Alert rule and Notification Templating (#94069) * Update links to the new location of the Templates intro page * Set alert rule template structure * Update the `Template notifications` structure/sidebar * Move examples to examples pages * Update menu titles and URL paths * WIP reference * added intro to examples.md * reference page section intros * examples title * Template * Continue Alert Template Reference * example sections * Almost finish with Reference page * weight pages * WIP - template variables Intro * Edits Alert rule templates + Differences with notification templates * examples-draft-2 * how to map annotations to notif templates * examples v2 * moved example * Continue Template annotations and labels * Preview annotation templates * Complete `Template annotations and labels` * Update `Differences with notification templates` * Polish a bit `Differences with notification tempaltes` * added logic examples to `Examples` * Finish sharing Template language * Minor: set `anchor` link * Minor edit * Minor edit * Minor changes * Template language changes * Document missing functions for alert rule templates * 'Examples' v3 * `Examples` v3.1 * `Examples` v3.2 * added context/intro to `Examples` * added a how to section to `Examples` * moved legacy info in `Examples` * added examples, sections in `Examples` * formatting * examples v5 * examples v5.1 * Complete update to `Notification template reference` * Update `$values` description * moved steps to `index` * fixed urls * removed section in `examples` * added refs * fixed urls * refs fix * blended the use case into the explanation * Notification template reference: Minor readibility changes * Edit `$value` in Alert rule template reference * Edit `Manage notification templates * links to ref and lang pages * Minor copy changes * Edit Template annotation overview + Prepare Template notifications overview * `Select` vs `Choose` * Template Overview * Fix `heading` does not match `title` * examples v6 * examples v6.1 * Fix spell errors * Run `prettier --write` to fix md format errors * examples v7 * examples v7.1 * examples v7.2 * examples v7.4 * examples v7.5 * examples v7.6 * all pretty, no pity * Update alert rule examples * Complete `Labels and annotations template examples` * Minor changes * Use `.` notation instead of `index` in examples * rename `extendeddata` to `notificationdata` * Complete Notification examples * minor changes * Set `go` language when displaying template examples * Revert "minor changes" This reverts commit f647c55c8718a4b5c5ab51b3ef88ef0605de3c84. * Update example and admonition for consistency * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/shared/alerts/template-language.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/shared/alerts/template-language.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/language.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/_index.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/examples.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/examples.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/examples.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/alerting-rules/templates/examples.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/examples.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Update docs/sources/alerting/configure-notifications/template-notifications/manage-notification-templates.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * use `add` instead of `enrich` * fix prettier content errors * minor copy change * Specify which Alert properties are exclusive to Grafana-managed alerts * Use `Monitor` instead of `Meta monitoring` * Be more detailed about notifation template limitations --------- Co-authored-by: tonypowa <tonypowa@gmail.com> Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> (cherry picked from commit 813632dff13f69c84daf328a6562c660d1b19016)
8 months ago
---
# Manage notification templates
In contact points, you can select notification templates to customize the notification messages sent.
By default, Grafana provides a template for the notification title (`default.title`) and a template for the notification message (`default.message`). Both default templates display common alert details.
You can also create custom templates to customize the content and format of notification messages, which can then be applied to one or more contact points.
This documentation provides step-by-step instructions for selecting templates in contact points, previewing templates, and creating custom templates using the Grafana UI.
## Select a notification template for a contact point
To add an existing notification template to your contact point, complete the following steps.
1. Click an existing contact point or create a new one.
1. In **Optional settings**, click any field that contains templates.
For example, if you are creating an email contact point integration, click **Message** or **Subject**.
1. Click **Edit**.
A dialog box opens where you can select templates.
1. Click **Select existing template** to select a template and [preview](#preview-a-notification-template) it using the default payload.
You can also copy the selected template and use it in the custom tab.
1. Click **Enter custom message** to customize and edit the field directly. Note that the title changes depending on the field you are editing.
1. You can switch between the two tabs to access the list of available templates and copy them across to the customized version.
1. Click **Save contact point**.
## Create a notification template
Create notification templates to customize notification messages and reuse them in contact points.
Your notification template name must be unique. You cannot have two templates with the same name in the same notification template or in different notification templates. Avoid defining templates with the same name as default templates, such as: `__subject`, `__text_values_list`, `__text_alert_list`, `default.title` and `default.message`.
To create a notification template in Grafana, complete the following steps.
1. Click **Alerts & IRM** -> **Contact points**.
1. Click the **Notification Templates** tab and then **+ Add notification template**.
1. Enter a name for the notification template.
1. Write the content of the template in the content field.
1. Save your changes.
If `{{ define }}` is not included in the content, `{{ define "<NOTIFICATION_TEMPLATE_NAME>" }}` and `{{ end }}` is automatically added to the start and end.
To create a notification template that contains more than one template, complete the following steps.
1. Click **+ Add notification template**.
1. Enter a name for the notification template.
1. Write each template in the Content field, including `{{ define "name-of-template" }}` and `{{ end }}` at the start and end of each template.
1. Save your changes.
For more details on how to write notification templates, refer to the [template reference](ref:notification-template-reference) and [examples](ref:notification-template-examples).
## Preview a notification template
Preview how your notification templates should look before using them in your contact points, helping you understand the result of the template you are creating as well as enabling you to fix any errors before saving it.
{{% admonition type="note" %}}
Notification template preview is only for Grafana Alertmanager.
{{% /admonition %}}
To preview your notification templates:
1. Navigate to **Alerts&IRM** -> **Alerting** -> **Contact points** -> **Notification Templates**.
1. Click **+ Add notification template** or edit an existing template.
1. Add or update your template content.
Default data is provided and you can add or edit alert data to it as well as alert instances. You can add alert data directly in the Payload data window itself or click **Select alert instances** or **Add custom alerts**.
1. Optional: To add alert data from existing alert instances:
a. Click **Select alert instances**.
b. Hover over the alert instances to view more information on each alert instance.
c. Click **Confirm** to add the alert instance(s) to the payload.
1. Optional: To add alert data using the Alert data editor, click **Add custom data:**
a. Add annotations, custom labels and/or set a dashboard or a panel.
b. Toggle Firing/resolved depending on whether you want to add firing or resolved alerts to your notification.
c. Click **Add alert data**.
d. Click **Refresh preview** to see what your template content should look like and the corresponding payload data.
If there are any errors in your template, they are displayed in the Preview and you can correct them before saving.
1. Save your changes.