Menu
Grafana Cloud Enterprise Open source

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.

  2. In Optional settings, click any field that contains templates.

    For example, if you are creating an email contact point integration, click Message or Subject.

  3. Click Edit. A dialog box opens where you can select templates.

  4. Click Select existing template to select a template and preview it using the default payload.

    You can also copy the selected template and use it in the custom tab.

  5. Click Enter custom message to customize and edit the field directly. Note that the title changes depending on the field you are editing.

  6. You can switch between the two tabs to access the list of available templates and copy them across to the customized version.

  7. 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.

  2. Click the Notification Templates tab and then + Add notification template.

  3. Enter a name for the notification template.

  4. Write the content of the template in the content field.

  5. 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.

  2. Enter a name for the notification template.

  3. Write each template in the Content field, including {{ define "name-of-template" }} and {{ end }} at the start and end of each template.

  4. Save your changes.

For more details on how to write notification templates, refer to the template reference and 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.

Note

Notification template preview is only for Grafana Alertmanager.

To preview your notification templates:

  1. Navigate to Alerts&IRM -> Alerting -> Contact points -> Notification Templates.

  2. Click + Add notification template or edit an existing template.

  3. 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.

  4. 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.

  5. 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.

  6. Save your changes.