<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Template notifications on Grafana Labs</title><link>https://grafana.com/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/</link><description>Recent content in Template notifications on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/index.xml" rel="self" type="application/rss+xml"/><item><title>Manage notification templates</title><link>https://grafana.com/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/manage-notification-templates/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/manage-notification-templates/</guid><content><![CDATA[&lt;h1 id=&#34;manage-notification-templates&#34;&gt;Manage notification templates&lt;/h1&gt;
&lt;p&gt;In contact points, you can select notification templates to customize the notification messages sent.&lt;/p&gt;
&lt;p&gt;By default, Grafana provides a template for the notification title (&lt;code&gt;{{define &amp;quot;default.title&amp;quot;}}&lt;/code&gt;) and a template for the notification message (&lt;code&gt;{{define &amp;quot;default.message&amp;quot;}}&lt;/code&gt;). Both default templates display common alert details.&lt;/p&gt;
&lt;p&gt;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. In Grafana, a custom notification template is created within a notification template group.&lt;/p&gt;
&lt;p&gt;This documentation provides step-by-step instructions for selecting templates in contact points, previewing templates, and creating notification template groups using the Grafana UI.&lt;/p&gt;
&lt;h2 id=&#34;select-a-notification-template-for-a-contact-point&#34;&gt;Select a notification template for a contact point&lt;/h2&gt;
&lt;p&gt;To add an existing notification template to your contact point, complete the following steps.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Click an existing contact point or create a new one.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In &lt;strong&gt;Optional settings&lt;/strong&gt;, click any field that contains templates.&lt;/p&gt;
&lt;p&gt;For example, if you are creating an email contact point integration, click &lt;strong&gt;Message&lt;/strong&gt; or &lt;strong&gt;Subject&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Edit&lt;/strong&gt;.
A dialog box opens where you can select notification templates.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Select notification template&lt;/strong&gt; or &lt;strong&gt;Enter custom message&lt;/strong&gt; to customize a template or message&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You can select an existing notification template and &lt;a href=&#34;#preview-a-notification-template&#34;&gt;preview&lt;/a&gt; it using the default payload.&lt;/li&gt;
&lt;li&gt;You can also copy the notification template and use it in the &lt;strong&gt;Enter custom message&lt;/strong&gt; tab.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save contact point&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can create custom notification templates using the &lt;strong&gt;Enter custom message&lt;/strong&gt; tab. For reusable and consistent notifications, a best practice is to custom notification templates as described in the following section.&lt;/p&gt;
&lt;h2 id=&#34;create-a-notification-template-and-notification-template-group&#34;&gt;Create a notification template and notification template group&lt;/h2&gt;
&lt;p&gt;Create notification templates to customize notification messages and reuse them in contact points.&lt;/p&gt;
&lt;p&gt;In Grafana, custom notification templates (&lt;code&gt;{{define &amp;quot;&amp;lt;NAME&amp;gt;&amp;quot;}}&lt;/code&gt;) are created within a notification template group, allowing you to test and implement multiple templates together.&lt;/p&gt;
&lt;p&gt;Your notification template name (&lt;code&gt;{{define &amp;quot;&amp;lt;NAME&amp;gt;&amp;quot;}}&lt;/code&gt;) must be unique. You cannot have two templates with the same name in the same notification template group or in different notification template groups. Therefore, avoid using names already defined as default templates, such as: &lt;code&gt;__subject&lt;/code&gt;, &lt;code&gt;__text_values_list&lt;/code&gt;, &lt;code&gt;__text_alert_list&lt;/code&gt;, &lt;code&gt;default.title&lt;/code&gt; and &lt;code&gt;default.message&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To create a notification template in Grafana, complete the following steps.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Alerts &amp;amp; IRM&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Contact points&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click the &lt;strong&gt;Notification Templates&lt;/strong&gt; tab and then &lt;strong&gt;&#43; Add notification template group&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter a name for the notification template group.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Write the content of the template in the content field.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Save your changes.&lt;/p&gt;
&lt;p&gt;If &lt;code&gt;{{ define }}&lt;/code&gt; is not included in the content, &lt;code&gt;{{ define &amp;quot;&amp;lt;NOTIFICATION_TEMPLATE_NAME&amp;gt;&amp;quot; }}&lt;/code&gt; and &lt;code&gt;{{ end }}&lt;/code&gt; is automatically added to the start and end.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To create a notification template group that contains more than one notification template, complete the following steps.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;&#43; Add notification template group&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter a name for the notification template group.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Write each template in the Content field, including &lt;code&gt;{{ define &amp;quot;&amp;lt;NOTIFICATION_TEMPLATE_NAME&amp;gt;&amp;quot; }}&lt;/code&gt; and &lt;code&gt;{{ end }}&lt;/code&gt; at the start and end of each template.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Save your changes.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For more details on how to write notification templates, refer to the 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/&#34;&gt;template reference&lt;/a&gt; and 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/examples/&#34;&gt;examples&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;preview-a-notification-template&#34;&gt;Preview a notification template&lt;/h2&gt;
&lt;p&gt;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.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Notification template preview is only for Grafana Alertmanager.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;To preview your notification templates:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Navigate to &lt;strong&gt;Alerts&amp;amp;IRM&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Alerting&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Contact points&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Notification Templates&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;&#43; Add notification template group&lt;/strong&gt; or edit an existing template group.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add or update your template content.&lt;/p&gt;
&lt;p&gt;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 &lt;strong&gt;Select alert instances&lt;/strong&gt; or &lt;strong&gt;Add custom alerts&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: To add alert data from existing alert instances:&lt;/p&gt;
&lt;p&gt;a. Click &lt;strong&gt;Select alert instances&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;b. Hover over the alert instances to view more information on each alert instance.&lt;/p&gt;
&lt;p&gt;c. Click &lt;strong&gt;Confirm&lt;/strong&gt; to add the alert instance(s) to the payload.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: To add alert data using the Alert data editor, click &lt;strong&gt;Add custom data:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;a. Add annotations, custom labels and/or set a dashboard or a panel.&lt;/p&gt;
&lt;p&gt;b. Toggle Firing/resolved depending on whether you want to add firing or resolved alerts to your notification.&lt;/p&gt;
&lt;p&gt;c. Click &lt;strong&gt;Add alert data&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;d. Click &lt;strong&gt;Refresh preview&lt;/strong&gt; to see what your template content should look like and the corresponding payload data.&lt;/p&gt;
&lt;p&gt;If there are any errors in your template, they are displayed in the Preview and you can correct them before saving.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Save your changes.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="manage-notification-templates">Manage notification templates&lt;/h1>
&lt;p>In contact points, you can select notification templates to customize the notification messages sent.&lt;/p>
&lt;p>By default, Grafana provides a template for the notification title (&lt;code>{{define &amp;quot;default.title&amp;quot;}}&lt;/code>) and a template for the notification message (&lt;code>{{define &amp;quot;default.message&amp;quot;}}&lt;/code>). Both default templates display common alert details.&lt;/p></description></item><item><title>Notification template reference</title><link>https://grafana.com/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/</guid><content><![CDATA[&lt;h1 id=&#34;notification-template-reference&#34;&gt;Notification template reference&lt;/h1&gt;
&lt;p&gt;By default, Grafana provides predefined templates to format notification messages.&lt;/p&gt;
&lt;p&gt;You can also customize your notifications with custom templates, which are based on the 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/language/&#34;&gt;Go template language&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This documentation lists the data available for use in notification templates.&lt;/p&gt;
&lt;h2 id=&#34;notification-data&#34;&gt;Notification Data&lt;/h2&gt;
&lt;p&gt;In notification templates, dot (&lt;code&gt;.&lt;/code&gt;) is initialized with the following data:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Receiver&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The name of the contact point sending the notification&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Status&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The status is &lt;code&gt;firing&lt;/code&gt; if at least one alert is firing, otherwise &lt;code&gt;resolved&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Alerts&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;[]&lt;a href=&#34;#alert&#34;&gt;Alert&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;List of all firing and resolved alerts in this notification.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Alerts.Firing&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;[]&lt;a href=&#34;#alert&#34;&gt;Alert&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;List of all firing alerts in this notification.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Alerts.Resolved&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;[]&lt;a href=&#34;#alert&#34;&gt;Alert&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;List of all resolved alerts in this notification.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;GroupLabels&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;#kv&#34;&gt;KV&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The labels that group these alerts in this notification based on the &lt;code&gt;Group by&lt;/code&gt; option.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;CommonLabels&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;#kv&#34;&gt;KV&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The labels common to all alerts in this notification.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;CommonAnnotations&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;#kv&#34;&gt;KV&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The annotations common to all alerts in this notification.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ExternalURL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;A link to Grafana, or the Alertmanager that sent this notification if using an external Alertmanager.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;GroupKey&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The key used to identify this alert group.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;TruncatedAlerts&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;integer&lt;/td&gt;
              &lt;td&gt;The number of alerts, if any, that were truncated in the notification. Supported by Webhook and OnCall.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;It&amp;rsquo;s important to remember that 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/notifications/group-alert-notifications/&#34;&gt;a single notification can group multiple alerts&lt;/a&gt; to reduce the number of alerts you receive. &lt;code&gt;Alerts&lt;/code&gt; is an array that includes all the alerts in the notification.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s an example that prints all available notification data from dot (&lt;code&gt;.&lt;/code&gt;):&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom_template&amp;#34; }}
  {{ .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 }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can execute this template by passing the dot (&lt;code&gt;.&lt;/code&gt;):&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;custom_template&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;alert&#34;&gt;Alert&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;Alert&lt;/code&gt; contains data for an individual alert:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Status&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Firing or resolved.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Labels&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;#kv&#34;&gt;KV&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The labels associated with this alert. &lt;br/&gt; It includes all 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rules/annotation-label/#label-types&#34;&gt;types of labels&lt;/a&gt;, but only query labels used in the alert condition.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Annotations&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;#kv&#34;&gt;KV&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The annotations for this alert.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;StartsAt&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;#time&#34;&gt;Time&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The time the alert fired&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;EndsAt&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;#time&#34;&gt;Time&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Only set if the end time of an alert is known. Otherwise set to a configurable timeout period from the time since the last alert was received.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;GeneratorURL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;A link to Grafana, or the source of the alert if using an external alert generator.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Fingerprint&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;A unique string that identifies the alert.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Grafana-managed alerts include these additional properties:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;DashboardURL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;A link to the Grafana Dashboard if the alert has a Dashboard UID annotation, with time range from &lt;code&gt;1h&lt;/code&gt; before alert start to end (or now if firing).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PanelURL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;A link to the panel if the alert has a Panel ID annotation, with time range from &lt;code&gt;1h&lt;/code&gt; before alert start to end (or now if firing).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;SilenceURL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;A link to silence the alert.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Values&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;#kv&#34;&gt;KV&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The values of expressions used to evaluate the alert condition. Only relevant values are included.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ValueString&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;A string that contains the labels and value of each reduced expression in the alert.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;OrgID&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;integer&lt;/td&gt;
              &lt;td&gt;The ID of the organization that owns the alert.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;This example iterates over the list of firing and resolved alerts (&lt;code&gt;.Alerts&lt;/code&gt;) in the notification and prints the data for each alert:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom_template&amp;#34; }}
{{ range .Alerts }}
  {{ .Status }}
  {{ .Labels }}
  {{ .Annotations }}
  {{ .StartsAt }}
  {{ .EndsAt }}
  {{ .GeneratorURL }}
  {{ .Fingerprint }}

  {{/* Only available for Grafana-managed alerts */}}
  {{ .DashboardURL }}
  {{ .PanelURL }}
  {{ .SilenceURL }}
  {{ .Values }}
  {{ .ValueString }}
{{ end }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can run this template by passing the dot (&lt;code&gt;.&lt;/code&gt;):&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;custom_template&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;kv&#34;&gt;KV&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;KV&lt;/code&gt; is a set of key value pairs, where each key and value is a string.&lt;/p&gt;
&lt;p&gt;Similarly to accessing variable properties, you can use &lt;code&gt;.&lt;/code&gt; to retrieve the value of a value. For example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom_template&amp;#34; }}
  {{ .CommonLabels.grafana_folder }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If a KV happens to contain numbers or bools then these are string representations of the numeric or boolean value.&lt;/p&gt;
&lt;p&gt;Additionally, KV provides methods to sort the pairs, remove keys, and iterate over just the keys or values:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Method name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Arguments&lt;/th&gt;
              &lt;th&gt;Returns&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;SortedPairs&lt;/td&gt;
              &lt;td&gt;Returns a sorted list of key/value pairs.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;Pairs&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Remove&lt;/td&gt;
              &lt;td&gt;Returns a copy of the KV with the keys removed&lt;/td&gt;
              &lt;td&gt;[]string&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;#kv&#34;&gt;KV&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Names&lt;/td&gt;
              &lt;td&gt;Return the names of the label names&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;[]string&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Values&lt;/td&gt;
              &lt;td&gt;Return a list of the values&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;[]string&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Here&amp;rsquo;s an example of using these methods:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom_template&amp;#34; }}
  {{ .CommonLabels.SortedPairs }}
  {{ .CommonLabels.Names }}
  {{ .CommonLabels.Values }}
  {{ .CommonLabels.Remove (stringSlice &amp;#34;grafana_folder&amp;#34;) }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;time&#34;&gt;Time&lt;/h2&gt;
&lt;p&gt;Some template functions and properties return a &lt;code&gt;Time&lt;/code&gt; object, which refers to the &lt;a href=&#34;https://pkg.go.dev/time#Time&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;type &lt;code&gt;Time&lt;/code&gt;&lt;/a&gt; in Go&amp;rsquo;s time package.&lt;/p&gt;
&lt;p&gt;When accessing a &lt;code&gt;Time&lt;/code&gt; object, you can use various &lt;a href=&#34;https://pkg.go.dev/time#Time&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;Time&lt;/code&gt; functions&lt;/a&gt; in your templates as follows.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom_template&amp;#34; }}
  {{ range .Alerts }}
    {{ .StartsAt  }}
    {{ .StartsAt.Add 6000000000000  }}
    {{ .StartsAt.Add -6000000000000  }}
    {{ .StartsAt.AddDate 1 0 0  }}
    {{ .StartsAt.Year   }}/{{ .StartsAt.Month   }}/{{ .StartsAt.Day   }}
    {{ .StartsAt.Hour   }}:{{ .StartsAt.Minute   }}:{{ .StartsAt.Second   }}
    {{ .StartsAt.YearDay   }}-{{ .StartsAt.Weekday   }}
    {{ .StartsAt.Unix }} {{ .StartsAt.UnixMilli }}
  {{ end}}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;functions&#34;&gt;Functions&lt;/h2&gt;
&lt;p&gt;Functions can perform actions in templates such as transforming or formatting data.&lt;/p&gt;
&lt;p&gt;Note that the 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/language/#functions&#34;&gt;functions provided by Go&amp;rsquo;s template language&lt;/a&gt;, such as &lt;code&gt;index&lt;/code&gt;, &lt;code&gt;and&lt;/code&gt;, &lt;code&gt;printf&lt;/code&gt;, and &lt;code&gt;len&lt;/code&gt;, are available, along with many others.&lt;/p&gt;
&lt;p&gt;In addition, the following functions are also available for templating notifications:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Arguments&lt;/th&gt;
              &lt;th&gt;Returns&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;title&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Capitalizes the first character of each word.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;toUpper&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Returns all text in uppercase.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;toLower&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Returns all text in lowercase.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;trimSpace&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Removes leading and trailing white spaces.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;match&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;pattern, text&lt;/td&gt;
              &lt;td&gt;boolean&lt;/td&gt;
              &lt;td&gt;Matches the text against a regular expression pattern.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;reReplaceAll&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;pattern, replacement, text&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Replaces text matching the regular expression.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;join&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;sep string, s []string&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Concatenates the elements of s to create a single string. The separator string sep is placed between elements in the resulting string.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;safeHtml&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Marks string as HTML not requiring auto-escaping.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;stringSlice&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&amp;hellip;string&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Returns the passed strings as a slice of strings. auto-escaping.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;date&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string, &lt;a href=&#34;#time&#34;&gt;Time&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Format a time in the specified format. For format options, refer to &lt;a href=&#34;https://pkg.go.dev/time#pkg-constants&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Go&amp;rsquo;s time format documentation&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tz&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string, &lt;a href=&#34;#time&#34;&gt;Time&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;#time&#34;&gt;Time&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Returns the time in the specified timezone, such as &lt;code&gt;Europe/Paris&lt;/code&gt;. For available timezone options, refer to the &lt;a href=&#34;https://en.wikipedia.org/wiki/List_of_tz_database_time_zones&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;list of tz database time zones&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Here&amp;rsquo;s an example using some functions to format text:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom_template&amp;#34; }}
  {{ title &amp;#34;hello, world!&amp;#34; }}
  {{ toUpper &amp;#34;Hello, world!&amp;#34; }}
  {{ toLower &amp;#34;Hello, world!&amp;#34; }}
  {{ trimSpace &amp;#34;Hello, world!&amp;#34; }}
  {{ match &amp;#34;a.*&amp;#34; &amp;#34;abc&amp;#34; }}
  {{ reReplaceAll &amp;#34;localhost:(.*)&amp;#34; &amp;#34;example.com:$1&amp;#34; &amp;#34;localhost:8080&amp;#34; }}
  {{ join &amp;#34;-&amp;#34; (stringSlice &amp;#34;a&amp;#34; &amp;#34;b&amp;#34; &amp;#34;c&amp;#34;) }}
  {{ safeHtml &amp;#34;&amp;lt;b&amp;gt;Text&amp;lt;/b&amp;gt;&amp;#34;}}
  {{ stringSlice &amp;#34;a&amp;#34; &amp;#34;b&amp;#34; &amp;#34;c&amp;#34; }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;code&gt;date&lt;/code&gt; and &lt;code&gt;tz&lt;/code&gt; can format times. For example, to print the time an alert fired in the format &lt;code&gt;15:04:05 MST&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom_template&amp;#34; }}
  {{ range .Alerts }}
    {{ .StartsAt | date &amp;#34;15:04:05 MST&amp;#34; }}
  {{ end}}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can then use &lt;code&gt;tz&lt;/code&gt; to change the timezone from UTC to local time, such as &lt;code&gt;Europe/Paris&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom_template&amp;#34; }}
  {{ range .Alerts }}
    {{ .StartsAt | tz &amp;#34;Europe/Paris&amp;#34; }}
    {{ .StartsAt | tz &amp;#34;Europe/Paris&amp;#34; | date &amp;#34;15:04:05 MST&amp;#34; }}
  {{ end}}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;template-output&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-template-output&#34;&gt;2024-10-30 21:01:45.227 &amp;#43;0100 CET
21:01:45 CET&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;namespaced-functions&#34;&gt;Namespaced Functions&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Namespaced Functions are not yet &lt;a href=&#34;/docs/release-life-cycle/#general-availability&#34;&gt;generally available&lt;/a&gt; in Grafana Cloud.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;In addition to the top-level functions, the following namespaced functions are also available:&lt;/p&gt;
&lt;h3 id=&#34;collection-functions&#34;&gt;Collection Functions&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Arguments&lt;/th&gt;
              &lt;th&gt;Returns&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;coll.Dict&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;key string, value any, &amp;hellip;&lt;/td&gt;
              &lt;td&gt;map&lt;/td&gt;
              &lt;td&gt;Creates a map with string keys from key/value pairs. All keys are converted to strings. If an odd number of arguments is provided, the last key will have an empty string value.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;coll.Slice&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&amp;hellip;any&lt;/td&gt;
              &lt;td&gt;[]any&lt;/td&gt;
              &lt;td&gt;Creates a slice (array/list) from the provided arguments. Useful for creating lists that can be iterated over with &lt;code&gt;range&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;coll.Append&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;value any, list []any&lt;/td&gt;
              &lt;td&gt;[]any&lt;/td&gt;
              &lt;td&gt;Creates a new list by appending a value to the end of an existing list. Does not modify the original list.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Example using collection functions:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;collection.example&amp;#34; }}
{{- /* Create a dictionary of alert metadata */ -}}
{{- $metadata := coll.Dict
    &amp;#34;severity&amp;#34; &amp;#34;critical&amp;#34;
    &amp;#34;team&amp;#34; &amp;#34;infrastructure&amp;#34;
    &amp;#34;environment&amp;#34; &amp;#34;production&amp;#34;
-}}

{{- /* Create a slice of affected services */ -}}
{{- $services := coll.Slice &amp;#34;database&amp;#34; &amp;#34;cache&amp;#34; &amp;#34;api&amp;#34; -}}

{{- /* Append a new service to the list */ -}}
{{- $services = coll.Append &amp;#34;web&amp;#34; $services -}}

{{- /* Use the collections in a template */ -}}
Affected Services: {{ range $services }}{{ . }},{{ end }}

Alert Metadata:
{{- range $k, $v := $metadata }}
  {{ $k }}: {{ $v }}
{{- end }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Output:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;Affected Services: database,cache,api,web,

Alert Metadata:
  environment: production
  severity: critical
  team: infrastructure&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;data-functions&#34;&gt;Data Functions&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Arguments&lt;/th&gt;
              &lt;th&gt;Returns&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;data.JSON&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;jsonString string&lt;/td&gt;
              &lt;td&gt;any&lt;/td&gt;
              &lt;td&gt;Parses a JSON string into an object that can be manipulated in the template. Works with both JSON objects and arrays.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;data.ToJSON&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;obj any&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Serializes any object (maps, arrays, etc.) into a JSON string. Useful for creating webhook payloads.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;data.ToJSONPretty&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;indent string, obj any&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Creates an indented JSON string representation of an object. The first argument specifies the indentation string (e.g., spaces).&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Example using data functions:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;data.example&amp;#34; }}
{{- /* First, let&amp;#39;s create some alert data as a JSON string */ -}}
{{ $jsonString := `{
  &amp;#34;service&amp;#34;: {
    &amp;#34;name&amp;#34;: &amp;#34;payment-api&amp;#34;,
    &amp;#34;environment&amp;#34;: &amp;#34;production&amp;#34;,
    &amp;#34;thresholds&amp;#34;: {
      &amp;#34;error_rate&amp;#34;: 5,
      &amp;#34;latency_ms&amp;#34;: 100
    }
  }
}` }}

{{- /* Parse the JSON string into an object we can work with */ -}}
{{ $config := $jsonString | data.JSON }}

{{- /* Create a new alert payload */ -}}
{{ $payload := coll.Dict
    &amp;#34;service&amp;#34; $config.service.name
    &amp;#34;environment&amp;#34; $config.service.environment
    &amp;#34;status&amp;#34; .Status
    &amp;#34;errorThreshold&amp;#34; $config.service.thresholds.error_rate
}}

{{- /* Output the payload in different JSON formats */ -}}
Compact JSON: {{ $payload | data.ToJSON }}

Pretty JSON with 2-space indent:
{{ $payload | data.ToJSONPretty &amp;#34;  &amp;#34; }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Output:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;Compact JSON: {&amp;#34;environment&amp;#34;:&amp;#34;production&amp;#34;,&amp;#34;errorThreshold&amp;#34;:5,&amp;#34;service&amp;#34;:&amp;#34;payment-api&amp;#34;,&amp;#34;status&amp;#34;:&amp;#34;resolved&amp;#34;}

Pretty JSON with 2-space indent:
{
  &amp;#34;environment&amp;#34;: &amp;#34;production&amp;#34;,
  &amp;#34;errorThreshold&amp;#34;: 5,
  &amp;#34;service&amp;#34;: &amp;#34;payment-api&amp;#34;,
  &amp;#34;status&amp;#34;: &amp;#34;resolved&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;template-functions&#34;&gt;Template Functions&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Arguments&lt;/th&gt;
              &lt;th&gt;Returns&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tmpl.Exec&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;name string, [context any]&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Executes a named template and returns the result as a string. Similar to the &lt;code&gt;template&lt;/code&gt; action but allows for post-processing of the result.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tmpl.Inline&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;template string, context any&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Renders a string as a template.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;
&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;template.example&amp;#34; -}}
{{ coll.Dict
    &amp;#34;info&amp;#34; (tmpl.Exec `info` . | data.JSON)
    &amp;#34;severity&amp;#34; (tmpl.Inline `{{ print &amp;#34;critical&amp;#34; | toUpper }}` . )
    | data.ToJSONPretty &amp;#34; &amp;#34;}}
{{- end }}

{{- /* Define a sub-template */ -}}
{{ define &amp;#34;info&amp;#34; -}}
{{coll.Dict
    &amp;#34;team&amp;#34; &amp;#34;infrastructure&amp;#34;
    &amp;#34;environment&amp;#34; &amp;#34;production&amp;#34; | data.ToJSON }}
{{- end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Output:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
  &amp;#34;info&amp;#34;: {
    &amp;#34;environment&amp;#34;: &amp;#34;production&amp;#34;,
    &amp;#34;team&amp;#34;: &amp;#34;infrastructure&amp;#34;
  },
  &amp;#34;severity&amp;#34;: &amp;#34;CRITICAL&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;time-functions&#34;&gt;Time Functions&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Arguments&lt;/th&gt;
              &lt;th&gt;Returns&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;time.Now&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;Time&lt;/td&gt;
              &lt;td&gt;Returns the current local time as a time.Time object. Can be formatted using Go&amp;rsquo;s time formatting functions.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Example using time functions:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;time.example&amp;#34; }}
{{- /* Get current time in different formats */ -}}
Current Time (UTC): {{ (time.Now).UTC.Format &amp;#34;2006-01-02 15:04:05 MST&amp;#34; }}
Current Time (Local): {{ (time.Now).Format &amp;#34;Monday, January 2, 2006 at 15:04:05&amp;#34; }}

{{- /* Compare alert time with current time */ -}}
{{ $timeAgo := (time.Now).Sub .StartsAt }}
Alert fired: {{ $timeAgo }} ago
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Output:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;Current Time (UTC): 2025-03-08 18:14:27 UTC
Current Time (Local): Saturday, March 8, 2025 at 14:14:27
Alert fired: 25h49m32.78574723s ago&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;differences-with-annotation-and-label-templates&#34;&gt;Differences with annotation and label templates&lt;/h2&gt;
&lt;p&gt;In the alert rule, you can also template annotations and labels to include additional information. For example, you might add a &lt;code&gt;summary&lt;/code&gt; annotation that displays the query value triggering the alert.&lt;/p&gt;
&lt;p&gt;Annotation and label templates add relevant information to individual alert instances, while notification templates inform about a group of alert instances.&lt;/p&gt;
&lt;p&gt;Since both types of templates operate in distinct contexts, the 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/templates/reference/&#34;&gt;functions and variables available in annotation and label templates&lt;/a&gt; differ from those used in notification templates.&lt;/p&gt;
]]></content><description>&lt;h1 id="notification-template-reference">Notification template reference&lt;/h1>
&lt;p>By default, Grafana provides predefined templates to format notification messages.&lt;/p>
&lt;p>You can also customize your notifications with custom templates, which are based on the
&lt;a href="/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/language/">Go template language&lt;/a>.&lt;/p></description></item><item><title>Notification template examples</title><link>https://grafana.com/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/examples/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/examples/</guid><content><![CDATA[&lt;h1 id=&#34;notification-template-examples&#34;&gt;Notification template examples&lt;/h1&gt;
&lt;p&gt;Notification templates allows you to change the default notification messages.&lt;/p&gt;
&lt;p&gt;You can modify the content and format of notification messages. For example, you can customize the content to show only specific information or adjust the format to suit a particular contact point, such as Slack or Email.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Avoid adding extra information about alert instances in notification templates, as this information is only visible in the notification message.&lt;/p&gt;
&lt;p&gt;Instead, you should 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/templates/&#34;&gt;use annotations or labels&lt;/a&gt; to add information directly to the alert, ensuring it&amp;rsquo;s also visible in the alert state and alert history within Grafana. You can then print the new alert annotation or label in notification templates.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;This page provides various examples illustrating how to template common notification messages. For more details about notification templates, refer to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/&#34;&gt;Template notifications&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/manage-notification-templates/&#34;&gt;Select, create, and preview a notification template&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/&#34;&gt;Notification template reference&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;basic-examples&#34;&gt;Basic examples&lt;/h2&gt;
&lt;p&gt;Notification templates can access the 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/#notification-data&#34;&gt;notification data&lt;/a&gt; using the dot (&lt;code&gt;.&lt;/code&gt;). The following examples demonstrate some basic uses of the 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/language/&#34;&gt;template language&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;text-formatting-examples&#34;&gt;Text formatting examples&lt;/h3&gt;
&lt;p&gt;Text formatting in notification templates varies by contact point type. Each platform has its own formatting syntax:&lt;/p&gt;
&lt;h4 id=&#34;slack-formatting&#34;&gt;Slack formatting&lt;/h4&gt;
&lt;p&gt;For Slack contact points, you can use:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;slack_formatted_message&amp;#34; -}}
*This text will be bold in Slack*
_This text will be italic in Slack_
Regular text without formatting
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Execute the template:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;slack_formatted_message&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;template_output&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-template_output&#34;&gt;*This text will be bold in Slack*
_This text will be italic in Slack_
Regular text without formatting&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;additional-contact-point-types&#34;&gt;Additional contact point types&lt;/h4&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Each contact point type has its own formatting requirements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Some support Markdown-style formatting&lt;/li&gt;
&lt;li&gt;Others use HTML tags&lt;/li&gt;
&lt;li&gt;Some may not support formatting at all&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Check your specific contact point&amp;rsquo;s documentation for supported formatting syntax.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;template-logic-examples&#34;&gt;Template logic examples&lt;/h2&gt;
&lt;p&gt;Beyond text formatting, you can use template logic to create dynamic notification content. The following examples demonstrate basic template operations:&lt;/p&gt;
&lt;h3 id=&#34;conditional-logic&#34;&gt;Conditional logic&lt;/h3&gt;
&lt;p&gt;To check if there are common labels (&lt;code&gt;.CommonLabels&lt;/code&gt;) for all alerts in the notification, use &lt;code&gt;if&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom_message&amp;#34; -}}
{{ if .CommonLabels }}
Alerts have common labels
{{ else }}
There are no common labels
{{ end }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;iterating-over-alerts&#34;&gt;Iterating over alerts&lt;/h3&gt;
&lt;p&gt;To iterate on the alerts in the notification and print a specific label, use &lt;code&gt;range&lt;/code&gt; and &lt;code&gt;index&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom_message&amp;#34; -}}
{{ range .Alerts }}
The name of the alert is {{ index .Labels &amp;#34;alertname&amp;#34; }}
{{ end }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Alternatively, you can use the &lt;code&gt;.&lt;/code&gt; notation to print the value of the key.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom_message&amp;#34; -}}
{{ range .Alerts }}
The name of the alert is {{ .Labels.alertname }}
{{ end }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can then use the template by passing the 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/#notification-data&#34;&gt;notification data (dot &lt;code&gt;.&lt;/code&gt;)&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;custom_message&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;template_output&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-template_output&#34;&gt;The name of the alert is InstanceDown

The name of the alert is CpuOverload&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;print-alerts-with-summary-and-description&#34;&gt;Print alerts with summary and description&lt;/h2&gt;
&lt;p&gt;Here&amp;rsquo;s an example that displays the summary and description annotations for each alert in the notification.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom.alerts&amp;#34; -}}
{{ len .Alerts }} alert(s)
{{ range .Alerts -}}
  {{ template &amp;#34;alert.summary_and_description&amp;#34; . -}}
{{ end -}}
{{ end -}}
{{ define &amp;#34;alert.summary_and_description&amp;#34; }}
  Summary: {{.Annotations.summary}}
  Status: {{ .Status }}
  Description: {{.Annotations.description}}
{{ end -}}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A template (&lt;code&gt;alert.summary_and_description&lt;/code&gt;) is defined to print the &lt;code&gt;summary&lt;/code&gt;, &lt;code&gt;status&lt;/code&gt;, and &lt;code&gt;description&lt;/code&gt; of one 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/#alert&#34;&gt;alert&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The main template &lt;code&gt;custom.alerts&lt;/code&gt; iterates the list of alerts (&lt;code&gt;.Alerts&lt;/code&gt;) in 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/#notification-data&#34;&gt;notification data&lt;/a&gt;, executing the &lt;code&gt;alert.summary_and_description&lt;/code&gt; template to print the details of each alert.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Execute the template by passing the dot (&lt;code&gt;.&lt;/code&gt;):&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;custom.alerts&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;template_output&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-template_output&#34;&gt;2 alert(s)

  Summary: The database server db1 has exceeded 75% of available disk space.
  Status: firing
  Description: This alert fires when a database server is at risk of running out of disk space. You should take measures to increase the maximum available disk space as soon as possible to avoid possible corruption.

  Summary: The web server web1 has been responding to 5% of HTTP requests with 5xx errors for the last 5 minutes.
  Status: resolved
  Description: This alert fires when a web server responds with more 5xx errors than is expected. This could be an issue with the web server or a backend service.&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;print-firing-and-resolved-alerts&#34;&gt;Print firing and resolved alerts&lt;/h2&gt;
&lt;p&gt;The following example is similar to the previous one, but it separates firing and resolved alerts.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom.firing_and_resolved_alerts&amp;#34; -}}
{{ len .Alerts.Resolved }} resolved alert(s)
{{ range .Alerts.Resolved -}}
  {{ template &amp;#34;alert.summary_and_description&amp;#34; . -}}
{{ end }}
{{ len .Alerts.Firing }} firing alert(s)
{{ range .Alerts.Firing -}}
  {{ template &amp;#34;alert.summary_and_description&amp;#34; . -}}
{{ end -}}
{{ end -}}
{{ define &amp;#34;alert.summary_and_description&amp;#34; }}
  Summary: {{.Annotations.summary}}
  Status: {{ .Status }}
  Description: {{.Annotations.description}}
{{ end -}}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Instead of &lt;code&gt;.Alerts&lt;/code&gt;, the template accesses &lt;code&gt;.Alerts.Firing&lt;/code&gt; and &lt;code&gt;.Alerts.Resolved&lt;/code&gt; separately to print details for each alert.&lt;/p&gt;
&lt;p&gt;Run the template by passing the dot (&lt;code&gt;.&lt;/code&gt;):&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;custom.firing_and_resolved_alerts&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;template_output&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-template_output&#34;&gt;1 resolved alert(s)

  Summary: The database server db1 has exceeded 75% of available disk space.
  Status: resolved
  Description: This alert fires when a database server is at risk of running out of disk space. You should take measures to increase the maximum available disk space as soon as possible to avoid possible corruption.

1 firing alert(s)

  Summary: The web server web1 has been responding to 5% of HTTP requests with 5xx errors for the last 5 minutes.
  Status: firing
  Description: This alert fires when a web server responds with more 5xx errors than is expected. This could be an issue with the web server or a backend service.&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;print-common-labels-and-annotations&#34;&gt;Print common labels and annotations&lt;/h2&gt;
&lt;p&gt;This example displays only the labels and annotations that are common to all alerts in the notification.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom.common_labels_and_annotations&amp;#34; -}}
{{ len .Alerts.Resolved }} resolved alert(s)
{{ len .Alerts.Firing }} firing alert(s)
Common labels: {{ len .CommonLabels.SortedPairs }}
{{ range .CommonLabels.SortedPairs -}}
- {{ .Name }} = {{ .Value }}
{{ end }}
Common annotations: {{ len .CommonAnnotations.SortedPairs }}
{{ range .CommonAnnotations.SortedPairs }}
- {{ .Name }} = {{ .Value }}
{{ end }}
{{ end -}}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Note that &lt;code&gt;.CommonAnnotations&lt;/code&gt; and &lt;code&gt;.CommonLabels&lt;/code&gt; are part of 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/#notification-data&#34;&gt;notification data&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Execute the template by passing the dot (&lt;code&gt;.&lt;/code&gt;) as argument:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;custom.common_labels_and_annotations&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;template_output&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-template_output&#34;&gt;1 resolved alert(s)
1 firing alert(s)
Common labels: 2
- grafana_folder = server_alerts
- team = server_admin

Common annotations: 0&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;print-individual-labels-and-annotations&#34;&gt;Print individual labels and annotations&lt;/h2&gt;
&lt;p&gt;This example displays all labels and annotations for each 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/#alert&#34;&gt;alert&lt;/a&gt; in the notification.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom.alert_labels_and_annotations&amp;#34; -}}
{{ len .Alerts.Resolved }} resolved alert(s)
{{ range .Alerts.Resolved -}}
  {{ template &amp;#34;alert.labels_and_annotations&amp;#34; . -}}
{{ end }}
{{ len .Alerts.Firing }} firing alert(s)
{{ range .Alerts.Firing -}}
  {{ template &amp;#34;alert.labels_and_annotations&amp;#34; . -}}
{{ end -}}
{{ end -}}
{{ define &amp;#34;alert.labels_and_annotations&amp;#34; }}
Alert labels: {{ len .Labels.SortedPairs }}
{{ range .Labels.SortedPairs -}}
- {{ .Name }} = {{ .Value }}
{{ end -}}
Alert annotations: {{ len .Annotations.SortedPairs }}
{{ range .Annotations.SortedPairs -}}
- {{ .Name }} = {{ .Value }}
{{ end -}}
{{ end -}}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;custom.alert_labels_and_annotations&lt;/code&gt; template iterates over the list of resolved and firing alerts, similar to previous examples. It then executes &lt;code&gt;alert.labels_and_annotations&lt;/code&gt; for each alert.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;alert.labels_and_annotations&lt;/code&gt; template prints all the alert labels and annotations by accessing &lt;code&gt;.Labels.SortedPairs&lt;/code&gt; and &lt;code&gt;.Annotations.SortedPairs&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Run the template by passing the dot (&lt;code&gt;.&lt;/code&gt;):&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;custom.alert_labels_and_annotations&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;template_output&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-template_output&#34;&gt;1 resolved alert(s)

Alert labels: 4
- alertname = db_server_disk_space
- grafana_folder = server_alerts
- server = db1
- team = server_admin

Alert annotations: 2
- summary = The database server db1 has exceeded 75% of available disk space.
- description = This alert fires when a database server is at risk of running out of disk space. You should take measures to increase the maximum available disk space as soon as possible to avoid possible corruption.

1 firing alert(s)

Alert labels: 4
- alertname = web_server_http_errors
- grafana_folder = server_alerts
- server = web1
- team = server_admin

Alert annotations: 2
- summary = The web server web1 has been responding to 5% of HTTP requests with 5xx errors for the last 5 minutes.
- description = This alert fires when a web server responds with more 5xx errors than is expected. This could be an issue with the web server or a backend service.&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;print-urls-for-runbook-and-alert-data-in-grafana&#34;&gt;Print URLs for runbook and alert data in Grafana&lt;/h2&gt;
&lt;p&gt;Note that the following example works only for Grafana-managed alerts. It displays some 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/#alert&#34;&gt;alert data&lt;/a&gt; such as &lt;code&gt;DashboardURL&lt;/code&gt;, &lt;code&gt;PanelURL&lt;/code&gt;, and &lt;code&gt;SilenceURL&lt;/code&gt;, which are exclusive to Grafana-managed alerts.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom.alert_additional_details&amp;#34; -}}
{{ len .Alerts.Resolved }} resolved alert(s)
{{ range .Alerts.Resolved -}}
  {{ template &amp;#34;alert.additional_details&amp;#34; . -}}
{{ end }}
{{ len .Alerts.Firing }} firing alert(s)
{{ range .Alerts.Firing -}}
  {{ template &amp;#34;alert.additional_details&amp;#34; . -}}
{{ end -}}
{{ end -}}
{{ define &amp;#34;alert.additional_details&amp;#34; }}
- Dashboard: {{ .DashboardURL }}
- Panel: {{ .PanelURL }}
- AlertGenerator: {{ .GeneratorURL }}
- Silence: {{ .SilenceURL }}
- RunbookURL: {{ .Annotations.runbook_url}}
{{ end -}}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Pass the dot (&lt;code&gt;.&lt;/code&gt;) to execute the template:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;custom.alert_additional_details&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;template_output&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-template_output&#34;&gt;1 resolved alert(s)

- Dashboard: https://example.com/d/uiyahbsdaubsd?from=1740070380000&amp;amp;orgId=1&amp;amp;to=1740074106395
- Panel: https://example.com/d/uiyahbsdaubsd?from=1740070380000&amp;amp;orgId=1&amp;amp;to=1740074106395&amp;amp;viewPanel=31
- AlertGenerator: ?orgId=1
- Silence: https://example.com/alerting/silence/new
- RunbookURL: https://example.com/on-call/db_server_disk_space

1 firing alert(s)

- Dashboard: https://example.com/d/uiyahbsdaubsd?from=1740070380000&amp;amp;orgId=1&amp;amp;to=1740074106395
- Panel: https://example.com/d/uiyahbsdaubsd?from=1740070380000&amp;amp;orgId=1&amp;amp;to=1740074106395&amp;amp;viewPanel=31
- AlertGenerator: ?orgId=1
- Silence: https://example.com/alerting/silence/new
- RunbookURL: https://example.com/on-call/web_server_http_errors&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;print-a-notification-title-or-subject&#34;&gt;Print a notification title or subject&lt;/h2&gt;
&lt;p&gt;A title or subject provides a one-line summary of the notification content.&lt;/p&gt;
&lt;p&gt;Here’s a basic example that displays the number of firing and resolved alerts in the notification.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom_title&amp;#34; -}}
{{ if gt (.Alerts.Firing | len) 0 }}🚨 {{ .Alerts.Firing | len }} firing alerts. {{ end }}{{ if gt (.Alerts.Resolved | len) 0 }}✅ {{ .Alerts.Resolved | len }} resolved alerts.{{ end }}
{{ end -}}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Execute the template by passing the dot (&lt;code&gt;.&lt;/code&gt;) as argument:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;custom_title&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;template_output&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-template_output&#34;&gt;🚨 1 firing alerts. ✅ 1 resolved alerts.&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The next example is a copy of the default title/subject template used in Grafana.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;copy_of_default_title&amp;#34; -}}
[{{ .Status | toUpper }}{{ if eq .Status &amp;#34;firing&amp;#34; }}:{{ .Alerts.Firing | len }}{{ if gt (.Alerts.Resolved | len) 0 }}, RESOLVED:{{ .Alerts.Resolved | len }}{{ end }}{{ end }}] {{ .GroupLabels.SortedPairs.Values | join &amp;#34; &amp;#34; }} {{ if gt (len .CommonLabels) (len .GroupLabels) }}({{ with .CommonLabels.Remove .GroupLabels.Names }}{{ .Values | join &amp;#34; &amp;#34; }}{{ end }}){{ end }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This is a more advanced example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Prints the number of firing and resolved alerts in the notification.&lt;/li&gt;
&lt;li&gt;Outputs &lt;code&gt;.GroupLabels&lt;/code&gt;, the labels used to 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/notifications/group-alert-notifications/&#34;&gt;group multiple alerts in one notification&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Prints &lt;code&gt;CommonLabels&lt;/code&gt;, excluding labels in &lt;code&gt;.GroupLabels&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Execute the template by passing the dot (&lt;code&gt;.&lt;/code&gt;):&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;copy_of_default_title&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;template_output&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-template_output&#34;&gt;[FIRING:1, RESOLVED:1] api warning (sql_db)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;print-a-link-to-a-dashboard-with-time-range&#34;&gt;Print a link to a dashboard with time range&lt;/h2&gt;
&lt;p&gt;You can include a link to a dashboard or panel in your alert notifications. This is useful when the alert rule is created from a dashboard panel or monitors a target visualized in an existing dashboard.&lt;/p&gt;
&lt;p&gt;Including a dashboard link in the notification helps responders quickly navigate to the relevant context for investigation.&lt;/p&gt;
&lt;p&gt;Use one of the following methods to include a dashboard link with the correct time range in the alert notification:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;You can 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/link-alert-rules-to-panels/&#34;&gt;link the alert rule to a panel&lt;/a&gt;. This includes the dashboard and panel URLs via &lt;code&gt;{{.Alert.DashboardURL}}&lt;/code&gt; and &lt;code&gt;{{.Alert.PanelURL}}&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom.link_to_dashboard&amp;#34; -}}
{{ range .Alerts -}}
  Dashboard: {{.DashboardURL}}
  Panel: {{ .PanelURL }}
{{ end -}}
{{ end -}}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Run the template using:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;custom.link_to_dashboard&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;template_output&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-template_output&#34;&gt;Dashboard: https://example.com/d/uiyahbsdaubsd?from=1740070380000&amp;amp;orgId=1&amp;amp;to=1740074106395
Panel: https://example.com/d/uiyahbsdaubsd?from=1740070380000&amp;amp;orgId=1&amp;amp;to=1740074106395&amp;amp;viewPanel=31&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;These URLs include a time range based on the alert’s timing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;from&lt;/code&gt;: One hour before the alert started.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;to&lt;/code&gt;: The current time if the alert is firing, or the alert’s end time if resolved.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Alternatively, you can use a custom annotation to set the dashboard URL and build the full URL using the &lt;code&gt;from&lt;/code&gt; and &lt;code&gt;to&lt;/code&gt; query parameters derived from &lt;code&gt;{{.Alert.StartsAt}}&lt;/code&gt; and &lt;code&gt;{{.Alert.EndsAt}}&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;custom.my_dashboard_url_annotation&amp;#34; -}}
{{ range .Alerts -}}

  {{/* StartsAt - 1h */}}
  {{- $from := (.StartsAt.Add -3600000000000).UnixMilli }}

  {{- $to := &amp;#34;&amp;#34; }}
  {{- if eq .Status &amp;#34;resolved&amp;#34; }}
     {{- $to = (.EndsAt).UnixMilli }}
  {{- else -}}
    {{/* Use current time if alert is firing */}}
    {{- $to = (time.Now).UnixMilli }}
  {{- end -}}

  Dashboard: {{.Annotations.MyDashboardURL}}?from={{$from}}&amp;amp;to={{$to}}
{{ end }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To use this template, define a custom annotation named &lt;code&gt;MyDashboardURL&lt;/code&gt; that contains the base dashboard URL without &lt;code&gt;from&lt;/code&gt; and &lt;code&gt;to&lt;/code&gt; parameters. For example: &lt;code&gt;http://localhost:3000/d/uiyahbsdaubsd&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Run the template using:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;custom.my_dashboard_url_annotation&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;template_output&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-template_output&#34;&gt;Dashboard: http://localhost:3000/d/uiyahbsdaubsd?from=1740070380000&amp;amp;to=1740071880000&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;custom-json-payload&#34;&gt;Custom JSON payload&lt;/h2&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/manage-contact-points/integrations/webhook-notifier/#custom-payload&#34;&gt;custom payload option&lt;/a&gt; in the webhook contact point allows you to customize the payload of webhook notifications using a custom template.&lt;/p&gt;
&lt;p&gt;The following example generates a custom JSON payload by executing other templates with &lt;code&gt;tmpl.Exec&lt;/code&gt;, and using functions like &lt;code&gt;coll.Dict&lt;/code&gt; and &lt;code&gt;data.ToJSON&lt;/code&gt; to process and format JSON data.&lt;/p&gt;


&lt;div data-shared=&#34;alerts/example-custom-json-payload.md&#34;&gt;
            
&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{- /* Generates a pretty-printed JSON payload with alert group info and individual alerts metadata. */ -}}
{{ define &amp;#34;webhook.custom.payload&amp;#34; -}}
  {{ coll.Dict
  &amp;#34;receiver&amp;#34; .Receiver
  &amp;#34;status&amp;#34; .Status
  &amp;#34;alerts&amp;#34; (tmpl.Exec &amp;#34;webhook.custom.simple_alerts&amp;#34; .Alerts | data.JSON)
  &amp;#34;groupLabels&amp;#34; .GroupLabels
  &amp;#34;commonLabels&amp;#34; .CommonLabels
  &amp;#34;commonAnnotations&amp;#34; .CommonAnnotations
  &amp;#34;externalURL&amp;#34; .ExternalURL
  &amp;#34;version&amp;#34; &amp;#34;1&amp;#34;
  &amp;#34;orgId&amp;#34;  (index .Alerts 0).OrgID
  &amp;#34;truncatedAlerts&amp;#34;  .TruncatedAlerts
  &amp;#34;groupKey&amp;#34; .GroupKey
  &amp;#34;state&amp;#34;  (tmpl.Inline &amp;#34;{{ if eq .Status \&amp;#34;resolved\&amp;#34; }}ok{{ else }}alerting{{ end }}&amp;#34; . )
  &amp;#34;allVariables&amp;#34;  .Vars
  &amp;#34;title&amp;#34; (tmpl.Exec &amp;#34;default.title&amp;#34; . )
  &amp;#34;message&amp;#34; (tmpl.Exec &amp;#34;default.message&amp;#34; . )
  | data.ToJSONPretty &amp;#34; &amp;#34;}}
{{- end }}

{{- /* Embed json templates in other json templates. */ -}}
{{ define &amp;#34;webhook.custom.simple_alerts&amp;#34; -}}
  {{- $alerts := coll.Slice -}}
  {{- range . -}}
    {{ $alerts = coll.Append (coll.Dict
    &amp;#34;status&amp;#34; .Status
    &amp;#34;labels&amp;#34; .Labels
    &amp;#34;startsAt&amp;#34; .StartsAt
    &amp;#34;endsAt&amp;#34; .EndsAt
    ) $alerts}}
  {{- end -}}
  {{- $alerts | data.ToJSON -}}
{{- end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

        

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;template_output&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-template_output&#34;&gt;{
 &amp;#34;alerts&amp;#34;: [
  {
   &amp;#34;endsAt&amp;#34;: &amp;#34;0001-01-01T00:00:00Z&amp;#34;,
   &amp;#34;labels&amp;#34;: {
    &amp;#34;alertname&amp;#34;: &amp;#34;InstanceDown&amp;#34;,
    &amp;#34;grafana_folder&amp;#34;: &amp;#34;Test Folder&amp;#34;,
    &amp;#34;instance&amp;#34;: &amp;#34;instance1&amp;#34;
   },
   &amp;#34;startsAt&amp;#34;: &amp;#34;2025-04-21T10:19:46.179Z&amp;#34;,
   &amp;#34;status&amp;#34;: &amp;#34;firing&amp;#34;
  },
  {
   &amp;#34;endsAt&amp;#34;: &amp;#34;2025-04-22T10:19:46.179Z&amp;#34;,
   &amp;#34;labels&amp;#34;: {
    &amp;#34;alertname&amp;#34;: &amp;#34;CpuUsage&amp;#34;,
    &amp;#34;grafana_folder&amp;#34;: &amp;#34;Test Folder&amp;#34;,
    &amp;#34;instance&amp;#34;: &amp;#34;instance1&amp;#34;
   },
   &amp;#34;startsAt&amp;#34;: &amp;#34;2025-04-22T06:19:46.179Z&amp;#34;,
   &amp;#34;status&amp;#34;: &amp;#34;resolved&amp;#34;
  }
 ],
 &amp;#34;allVariables&amp;#34;: {},
 &amp;#34;commonAnnotations&amp;#34;: {},
 &amp;#34;commonLabels&amp;#34;: {
  &amp;#34;grafana_folder&amp;#34;: &amp;#34;Test Folder&amp;#34;,
  &amp;#34;instance&amp;#34;: &amp;#34;instance1&amp;#34;
 },
 &amp;#34;externalURL&amp;#34;: &amp;#34;http://localhost:3000/&amp;#34;,
 &amp;#34;groupKey&amp;#34;: &amp;#34;&amp;#34;,
 &amp;#34;groupLabels&amp;#34;: {
  &amp;#34;group_label&amp;#34;: &amp;#34;group_label_value&amp;#34;
 },
 &amp;#34;message&amp;#34;: &amp;#34;**Firing**\n\nValue: B=22, C=1\nLabels:\n - alertname = InstanceDown\n - grafana_folder = Test Folder\n - instance = instance1\nAnnotations:\n - summary = Instance instance1 has been down for more than 5 minutes\nSource: https://grafana.com/alerting/grafana/cdeqmlhvflz40f/view?orgId=1\nSilence: http://localhost:3000/alerting/silence/new?alertmanager=grafana\u0026matcher=alertname%3DInstanceDown\u0026matcher=grafana_folder%3DTest&amp;#43;Folder\u0026matcher=instance%3Dinstance1\u0026orgId=1\nDashboard: http://localhost:3000/d/dashboard_uid?from=1745227186179\u0026orgId=1\u0026to=1745317189058\nPanel: http://localhost:3000/d/dashboard_uid?from=1745227186179\u0026orgId=1\u0026to=1745317189058\u0026viewPanel=1\n\n\n**Resolved**\n\nValue: B=22, C=1\nLabels:\n - alertname = CpuUsage\n - grafana_folder = Test Folder\n - instance = instance1\nAnnotations:\n - summary = CPU usage above 90%\nSource: https://grafana.com/alerting/grafana/oZSMdGj7z/view?orgId=1\nSilence: http://localhost:3000/alerting/silence/new?alertmanager=grafana\u0026matcher=alertname%3DCpuUsage\u0026matcher=grafana_folder%3DTest&amp;#43;Folder\u0026matcher=instance%3Dinstance1\u0026orgId=1\nDashboard: http://localhost:3000/d/dashboard_uid?from=1745299186179\u0026orgId=1\u0026to=1745317186179\nPanel: http://localhost:3000/d/dashboard_uid?from=1745299186179\u0026orgId=1\u0026to=1745317186179\u0026viewPanel=1\n&amp;#34;,
 &amp;#34;orgId&amp;#34;: 1,
 &amp;#34;receiver&amp;#34;: &amp;#34;TestReceiver&amp;#34;,
 &amp;#34;state&amp;#34;: &amp;#34;alerting&amp;#34;,
 &amp;#34;status&amp;#34;: &amp;#34;firing&amp;#34;,
 &amp;#34;title&amp;#34;: &amp;#34;[FIRING:1, RESOLVED:1] group_label_value (Test Folder instance1)&amp;#34;,
 &amp;#34;truncatedAlerts&amp;#34;: null,
 &amp;#34;version&amp;#34;: &amp;#34;1&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="notification-template-examples">Notification template examples&lt;/h1>
&lt;p>Notification templates allows you to change the default notification messages.&lt;/p>
&lt;p>You can modify the content and format of notification messages. For example, you can customize the content to show only specific information or adjust the format to suit a particular contact point, such as Slack or Email.&lt;/p></description></item><item><title>Alerting template language</title><link>https://grafana.com/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/language/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/language/</guid><content><![CDATA[&lt;h1 id=&#34;alerting-template-language&#34;&gt;Alerting template language&lt;/h1&gt;
&lt;p&gt;Notification templates and alert rule templates, such as annotations and labels, both use the Go template language, &lt;a href=&#34;https://pkg.go.dev/text/template&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;text/template&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Both types of templates can use the same keywords, functions, and comparison operators of the Go template language, such as &lt;code&gt;range&lt;/code&gt;, &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;and&lt;/code&gt;, &lt;code&gt;index&lt;/code&gt;, &lt;code&gt;eq&lt;/code&gt;, and more.&lt;/p&gt;
&lt;p&gt;However, it&amp;rsquo;s important to note that because notifications and alert rules operate in distinct context, some additional variables and functions are only available for either notification or alert rule templates. Refer to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/templates/reference/&#34;&gt;Annotation and label template reference&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/&#34;&gt;Notification template reference&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This documentation provides an overview of the functions and operators of the Go template language that are available for both notification and alert rule templates.&lt;/p&gt;
&lt;h2 id=&#34;print&#34;&gt;Print&lt;/h2&gt;
&lt;p&gt;To print the value of something, use &lt;code&gt;{{&lt;/code&gt; and &lt;code&gt;}}&lt;/code&gt;. You can print the value of a &lt;a href=&#34;#variables&#34;&gt;variable&lt;/a&gt;, a field of a variable, the result of a function, or the value of dot.&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;{{ $values }}
{{ $values.A.Value }}
{{ humanize 1000.0 }}
{{ .Alerts }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;dot&#34;&gt;Dot&lt;/h2&gt;
&lt;p&gt;In &lt;code&gt;text/template&lt;/code&gt;, there is a special cursor called dot, written as &lt;code&gt;.&lt;/code&gt;. You can think of this cursor as a variable whose value changes depending on where in the template it is used.&lt;/p&gt;
&lt;p&gt;At the start of notification templates, dot (&lt;code&gt;.&lt;/code&gt;) refers to 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/#notification-data&#34;&gt;Notification Data&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;{{ .Alerts }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In annotation and label templates, dot (&lt;code&gt;.&lt;/code&gt;) is initialized with all alert data. It’s recommended to use the 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/templates/reference/#variables&#34;&gt;&lt;code&gt;$labels&lt;/code&gt; and &lt;code&gt;$values&lt;/code&gt; variables&lt;/a&gt; instead to directly access the alert labels and query values.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Dot (&lt;code&gt;.&lt;/code&gt;) might refer to something else when used in a &lt;a href=&#34;#range&#34;&gt;range&lt;/a&gt;, a &lt;a href=&#34;#with&#34;&gt;with&lt;/a&gt;, or when writing &lt;a href=&#34;#templates&#34;&gt;templates&lt;/a&gt; used in other templates.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;



&lt;div data-shared=&#34;alerts/template-language.md&#34;&gt;
            &lt;h2 id=&#34;if&#34;&gt;If&lt;/h2&gt;
&lt;p&gt;You can use &lt;code&gt;if&lt;/code&gt; statements in templates. For example, you can print &lt;code&gt;Variable empty&lt;/code&gt; when a variable is empty:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ if $element }}
Element value: {{$element}}
{{ else }}
Element is empty
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;with&#34;&gt;With&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;with&lt;/code&gt; is similar to &lt;code&gt;if&lt;/code&gt; statements, but unlike &lt;code&gt;if&lt;/code&gt;, it updates dot(&lt;code&gt;.&lt;/code&gt;) to refer to the value of the expression in &lt;code&gt;with&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ with $array }}
There are {{ len . }} item(s)
{{ else }}
There are no alerts
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;range&#34;&gt;Range&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;range&lt;/code&gt; iterates over an array or map, and dot (&lt;code&gt;.&lt;/code&gt;) is set to the current element of the array:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ range $array }}
{{ .itemPropertyName }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Optionally, you can handle empty objects using &lt;code&gt;else&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ range $array }}
  {{ .itemPropertyName }}
{{ else }}
  Empty array
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can also get the index of each item within a range by defining index and value variables at the start of the range:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ $num_items := len $array }}
{{ range $index, $item := $array }}
This is item {{ $index }} out of {{ $num_items }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Additionally, you can use &lt;code&gt;{{break}}&lt;/code&gt; to stop the remaining iterations or &lt;code&gt;{{continue}}&lt;/code&gt; to stop the current iteration and continue with the next one.&lt;/p&gt;
&lt;h2 id=&#34;functions&#34;&gt;Functions&lt;/h2&gt;
&lt;p&gt;The global functions available in &lt;code&gt;text/template&lt;/code&gt; are:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Function&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;and&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the boolean AND of its arguments by returning the first empty argument or the last argument.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;call&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the result of calling the first argument, which must be a function, with the remaining arguments as parameters.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;html&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the escaped HTML equivalent of the textual representation of its arguments.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;index&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the result of indexing its first argument by the following arguments, e.g., &lt;code&gt;{{ index $labels &amp;quot;instance&amp;quot; }}&lt;/code&gt; returns the &lt;code&gt;instance&lt;/code&gt; key in the &lt;code&gt;$labels&lt;/code&gt; map variable.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;slice&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the result of slicing its first argument by the remaining arguments.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;js&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the escaped JavaScript equivalent of the textual representation of its arguments.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;len&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the integer length of its argument, e.g., &lt;code&gt;{{ len $array }}&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;not&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the boolean negation of its single argument.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;or&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the boolean OR of its arguments by returning the first non-empty argument or the last argument.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;print&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;An alias for fmt.Sprint&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;printf&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;An alias for fmt.Sprintf&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;println&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;An alias for fmt.Sprintln&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;urlquery&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the escaped value of the textual representation of its arguments in a form suitable for embedding in a URL query&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;For more details, refer to the official documentation on &lt;a href=&#34;https://pkg.go.dev/text/template#hdr-Functions&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;functions in &lt;code&gt;text/template&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;comparison-operators&#34;&gt;Comparison operators&lt;/h2&gt;
&lt;p&gt;Boolean comparison operators are also available in &lt;code&gt;text/template&lt;/code&gt;:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Function&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;eq&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the boolean truth of arg1 == arg2&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ne&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the boolean truth of arg1 != arg2&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;lt&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the boolean truth of arg1 &amp;lt; arg2&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;le&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the boolean truth of arg1 &amp;lt;= arg2&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;gt&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the boolean truth of arg1 &amp;gt; arg2&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ge&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the boolean truth of arg1 &amp;gt;= arg2&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;variables&#34;&gt;Variables&lt;/h2&gt;
&lt;p&gt;Variables in &lt;code&gt;text/template&lt;/code&gt; must be created within the template. For example, you can create a variable with the current value of dot (&lt;code&gt;.&lt;/code&gt;) and assign a string or another object to the variable like this:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ $variable := . }}
{{ $variable := &amp;#34;This is a test&amp;#34; }}
{{ $variable }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This template outputs:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;This is a test&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;templates&#34;&gt;Templates&lt;/h2&gt;
&lt;p&gt;You can create reusable templates that can be executed from other templates or within the same template.&lt;/p&gt;
&lt;p&gt;Define templates using &lt;code&gt;define&lt;/code&gt; and the name of the template in double quotes:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;print_labels&amp;#34; }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You should not define templates with the same name as other templates, including default templates such as &lt;code&gt;__subject&lt;/code&gt;, &lt;code&gt;__text_values_list&lt;/code&gt;, &lt;code&gt;__text_alert_list&lt;/code&gt;, &lt;code&gt;default.title&lt;/code&gt; and &lt;code&gt;default.message&lt;/code&gt;. Where a template has been created with the same name as a default template, or a template in another notification template, Grafana might use either template. Grafana does not prevent, or show an error message, when there are two or more templates with the same name.&lt;/p&gt;
&lt;h3 id=&#34;execute-templates&#34;&gt;Execute templates&lt;/h3&gt;
&lt;p&gt;You can execute defined templates using &lt;code&gt;template&lt;/code&gt;, the name of the template in double quotes, and the cursor that should be passed to the template:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;print_labels&amp;#34; . }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Within a template dot refers to the value that is passed to the template.&lt;/p&gt;
&lt;p&gt;For example, if a template is passed a list of firing alerts then dot refers to that list of firing alerts:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;print_alerts&amp;#34; .Alerts }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If the template is passed the sorted labels for an alert then dot refers to the list of sorted labels:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;print_labels&amp;#34; .SortedLabels }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This is useful when writing reusable templates. For example, to print all alerts you might write the following:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;print_alerts&amp;#34; .Alerts }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Then to print just the firing alerts you could write this:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ template &amp;#34;print_alerts&amp;#34; .Alerts.Firing }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This works because both &lt;code&gt;.Alerts&lt;/code&gt; and &lt;code&gt;.Alerts.Firing&lt;/code&gt; is a list of alerts.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ define &amp;#34;print_alerts&amp;#34; }}
{{ range . }}
{{ template &amp;#34;print_labels&amp;#34; .SortedLabels }}
{{ end }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;You cannot create independent, reusable templates for labels and annotations as you can with notification templates. In alert rule templates, you need to write each template inline within the label or annotation field.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;p&gt;You can add comments with &lt;code&gt;{{/*&lt;/code&gt; and &lt;code&gt;*/}}&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{/* This is a comment */}}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To avoid adding line breaks, use:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{- /* This is a comment with no leading or trailing line breaks */ -}}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;indentation&#34;&gt;Indentation&lt;/h2&gt;
&lt;p&gt;You can use indentation, both tabs and spaces, and line breaks, to make templates more readable:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ range .Alerts }}
  {{ range .Labels.SortedPairs }}
    {{ .Name }} = {{ .Value }}
  {{ end }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;However, indentation in the template is also present in the text.&lt;/p&gt;
&lt;h3 id=&#34;remove-spaces-and-line-breaks&#34;&gt;Remove spaces and line breaks&lt;/h3&gt;
&lt;p&gt;In text/template use &lt;code&gt;{{-&lt;/code&gt; and &lt;code&gt;-}}&lt;/code&gt; to remove leading and trailing spaces and line breaks.&lt;/p&gt;
&lt;p&gt;For example, when using indentation and line breaks to make a template more readable:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ range .Alerts }}
  {{ range .Labels.SortedPairs }}
    {{ .Name }} = {{ .Value }}
  {{ end }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The indentation and line breaks are also present in the text:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;    alertname = &amp;#34;Test&amp;#34;

    grafana_folder = &amp;#34;Test alerts&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can remove the indentation and line breaks from the text changing &lt;code&gt;}}&lt;/code&gt; to &lt;code&gt;-}}&lt;/code&gt; at the start of each range:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;{{ range .Alerts -}}
  {{ range .Labels.SortedPairs -}}
    {{ .Name }} = {{ .Value }}
  {{ end }}
{{ end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The indentation and line breaks in the template are now absent from the text:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;alertname = &amp;#34;Test&amp;#34;
grafana_folder = &amp;#34;Test alerts&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

        
]]></content><description>&lt;h1 id="alerting-template-language">Alerting template language&lt;/h1>
&lt;p>Notification templates and alert rule templates, such as annotations and labels, both use the Go template language, &lt;a href="https://pkg.go.dev/text/template" target="_blank" rel="noopener noreferrer">text/template&lt;/a>.&lt;/p>
&lt;p>Both types of templates can use the same keywords, functions, and comparison operators of the Go template language, such as &lt;code>range&lt;/code>, &lt;code>if&lt;/code>, &lt;code>and&lt;/code>, &lt;code>index&lt;/code>, &lt;code>eq&lt;/code>, and more.&lt;/p></description></item><item><title>Use images in notifications</title><link>https://grafana.com/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/images-in-notifications/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/images-in-notifications/</guid><content><![CDATA[&lt;h1 id=&#34;use-images-in-notifications&#34;&gt;Use images in notifications&lt;/h1&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Grafana Cloud users can request this feature by &lt;a href=&#34;/profile/org#support&#34;&gt;opening a support ticket in the Cloud Portal&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Images in notifications helps recipients of alert notifications better understand why an alert has fired or resolved by including a screenshot of the panel associated with the alert.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;This feature is not supported in Mimir or Loki, or when Grafana is configured to send alerts to other Alertmanagers such as the Prometheus Alertmanager.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;When an alert is fired or resolved Grafana takes a screenshot of the panel associated with the alert. This is determined via the Dashboard UID and Panel ID annotations of the rule. Grafana cannot take a screenshot for alerts that are not associated with a panel.&lt;/p&gt;
&lt;p&gt;Grafana takes at most two screenshots for each alert: once when the alert fires and again when the alert is resolved. Screenshots are not re-taken over the lifetime of the alert, instead you should open the panel in Grafana to follow the data in real time. In addition, depending on how alerts are grouped in your notification policies, Grafana might send a notification with many screenshots of the same panel. This happens because Grafana does not know how your alerts are grouped at the time a screenshot is taken, and so acts conservatively by taking a screenshot for every alert.&lt;/p&gt;
&lt;p&gt;After a screenshot has been taken Grafana can either upload it to a cloud storage service such as Amazon S3, Azure Blob Storage or Google Cloud Storage; upload the screenshot to it&amp;rsquo;s internal web server; or upload it to the service that is receiving the notification, such as Slack. Which option you should choose depends on how your Grafana is managed and which integrations you use. More information on this can be found in Requirements.&lt;/p&gt;
&lt;p&gt;Refer to the table at the end of this page for a list of contact points and their support for images in notifications.&lt;/p&gt;
&lt;h2 id=&#34;requirements&#34;&gt;Requirements&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;To use images in notifications, Grafana must be set up to use image rendering. You can either install the image rendering plugin or run it as a remote rendering service.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When a screenshot is taken, it is saved to the [data][paths] folder, even if Grafana is configured to upload screenshots to a cloud storage service. Grafana must have write-access to this folder otherwise screenshots cannot be saved to disk and an error is logged for each failed screenshot attempt.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You should use a cloud storage service unless sending alerts to Discord, email, Pushover, Slack or Telegram. These integrations support either embedding screenshots in the email or attaching screenshots to the notification, while other integrations must link screenshots uploaded to a cloud storage bucket. If a cloud storage service has been configured then integrations that support both link screenshots from the cloud storage bucket instead of embedding or attaching screenshots to the notification.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If uploading screenshots to a cloud storage service such as Amazon S3, Azure Blob Storage or Google Cloud Storage; and accessing screenshots in the bucket requires authentication, logging into a VPN or corporate network; then image previews might not work in all instant messaging and communication platforms as some services rewrite URLs to use their CDN. If this happens, we recommend using &lt;a href=&#34;#supported-contact-points&#34;&gt;integrations which support uploading images&lt;/a&gt; or &lt;a href=&#34;#configuration&#34;&gt;disabling images in notifications&lt;/a&gt; altogether.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When uploading screenshots to a cloud storage service Grafana uses a random 20 character (30 characters for Azure Blob Storage) filename for each image. This makes URLs hard to guess but not impossible.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Grafana does not delete screenshots from cloud storage. We recommend configuring a retention policy with your cloud storage service to delete screenshots older than 1 month.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If Grafana is configured to upload screenshots to its internal web server, and accessing Grafana requires logging into a VPN or corporate network; image previews might not work in all instant messaging and communication platforms as some services rewrite URLs to use their CDN. If this happens, we recommend using &lt;a href=&#34;#supported-contact-points&#34;&gt;integrations which support uploading images&lt;/a&gt; or &lt;a href=&#34;#configuration&#34;&gt;disabling images in notifications&lt;/a&gt; altogether.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Grafana does not delete screenshots uploaded to its internal web server. To delete screenshots from &lt;code&gt;static_root_path/images/attachments&lt;/code&gt; after a certain amount of time, we recommend setting up a CRON job.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Note you cannot adjust the number and size of images or their placement in notifications.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;configuration&#34;&gt;Configuration&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Grafana Cloud users can request this feature by &lt;a href=&#34;/profile/org#support&#34;&gt;opening a support ticket in the Cloud Portal&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Having installed either the image rendering plugin, or set up Grafana to use a remote rendering service, set &lt;code&gt;capture&lt;/code&gt; in &lt;code&gt;[unified_alerting.screenshots]&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Enable screenshots in notifications. You must have either installed the Grafana image rendering
# plugin, or set up Grafana to use a remote rendering service.
# For more information on configuration options, refer to [rendering].
capture = false
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If screenshots should be uploaded to cloud storage then &lt;code&gt;upload_external_image_storage&lt;/code&gt; should also be set to &lt;code&gt;true&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Uploads screenshots to the local Grafana server or remote storage such as Azure, S3 and GCS. Please
# see [external_image_storage] for further configuration options. If this option is false, screenshots
# are persisted to disk for up to temp_data_lifetime.
upload_external_image_storage = false
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Restart Grafana for the changes to take effect.&lt;/p&gt;
&lt;h2 id=&#34;advanced-configuration&#34;&gt;Advanced configuration&lt;/h2&gt;
&lt;p&gt;We recommend that &lt;code&gt;max_concurrent_screenshots&lt;/code&gt; is less than or equal to &lt;code&gt;concurrent_render_request_limit&lt;/code&gt;. The default value for both &lt;code&gt;max_concurrent_screenshots&lt;/code&gt; and &lt;code&gt;concurrent_render_request_limit&lt;/code&gt; is &lt;code&gt;5&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# The maximum number of screenshots that can be taken at the same time. This option is different from
# concurrent_render_request_limit as max_concurrent_screenshots sets the number of concurrent screenshots
# that can be taken at the same time for all firing alerts where as concurrent_render_request_limit sets
# the total number of concurrent screenshots across all Grafana services.
max_concurrent_screenshots = 5
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&#34;supported-contact-points&#34;&gt;Supported contact points&lt;/h2&gt;
&lt;p&gt;Grafana supports a wide range of contact points with varied support for images in notifications. The table below shows the list of all contact points supported in Grafana and their support for uploading screenshots to the receiving service and referencing screenshots that have been uploaded to a cloud storage service.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Upload from disk&lt;/th&gt;
              &lt;th&gt;Reference from cloud storage&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;DingDing&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Discord&lt;/td&gt;
              &lt;td&gt;Yes (Maximum of 10 per notification)&lt;/td&gt;
              &lt;td&gt;Yes (Maximum of 10 per notification)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Email&lt;/td&gt;
              &lt;td&gt;Yes (Embedded in the email)&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Google Chat&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Kafka&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Line&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;MQTT&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Microsoft Teams&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Opsgenie&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;PagerDuty&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Prometheus Alertmanager&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Pushover&lt;/td&gt;
              &lt;td&gt;Yes (Maximum of 1 per notification)&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Sensu Go&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Slack&lt;/td&gt;
              &lt;td&gt;Yes (when using Bot tokens, maximum of 5 per notification)&lt;/td&gt;
              &lt;td&gt;Yes (when using webhooks, maximum of 1 per notification)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Telegram&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Threema&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;VictorOps&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Webhook&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;limitations&#34;&gt;Limitations&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;This feature is not supported in Mimir or Loki, or when Grafana is configured to send alerts to other Alertmanagers such as the Prometheus Alertmanager.&lt;/li&gt;
&lt;li&gt;This feature is not supported when using custom templates in email notifications.&lt;/li&gt;
&lt;li&gt;A number of contact points support at most one image per notification. In this case, just the first image is either uploaded to the receiving service or referenced from cloud storage per notification.&lt;/li&gt;
&lt;li&gt;When multiple alerts are sent in a single notification a screenshot might be included for each alert. The order the images are shown is random.&lt;/li&gt;
&lt;li&gt;If uploading screenshots to a cloud storage service such as Amazon S3, Azure Blob Storage or Google Cloud Storage; and accessing screenshots in the bucket requires authentication, logging into a VPN or corporate network; image previews might not work in all instant messaging and communication platforms as some services rewrite URLs to use their CDN.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;troubleshooting&#34;&gt;Troubleshooting&lt;/h2&gt;
&lt;p&gt;If Grafana has been set up to send images in notifications, however notifications are still being received without them, follow the troubleshooting steps below:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Check that images in notifications has been set up as per the instructions.&lt;/li&gt;
&lt;li&gt;Enable debug logging in Grafana and look for logs with the logger &lt;code&gt;ngalert.image&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If the alert is not associated with a dashboard there are logs for &lt;code&gt;Cannot take screenshot for alert rule as it is not associated with a dashboard&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If the alert is associated with a dashboard, but no panel in the dashboard, there are logs for &lt;code&gt;Cannot take screenshot for alert rule as it is not associated with a panel&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If images cannot be taken because of mis-configuration or an issue with image rendering there are logs for &lt;code&gt;Failed to take an image&lt;/code&gt; including the Dashboard UID, Panel ID, and the error message.&lt;/li&gt;
&lt;li&gt;Check that the contact point supports images in notifications and whether it supports uploading images to the receiving service or referencing images that have been uploaded to a cloud storage service.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;monitor&#34;&gt;Monitor&lt;/h2&gt;
&lt;p&gt;Grafana provides the following metrics to observe the performance and failure rate of images in notifications.
For example, if a screenshot could not be taken within the expected time (10 seconds) then the counter &lt;code&gt;grafana_screenshot_failures_total&lt;/code&gt; is updated.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;grafana_alerting_image_cache_hits_total&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;grafana_alerting_image_cache_misses_total&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;grafana_screenshot_duration_seconds&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;grafana_screenshot_failures_total&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;grafana_screenshot_successes_total&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;grafana_screenshot_upload_failures_total&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;grafana_screenshot_upload_successes_total&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="use-images-in-notifications">Use images in notifications&lt;/h1>
&lt;div class="admonition admonition-note">&lt;blockquote>&lt;p class="title text-uppercase">Note&lt;/p>&lt;p>Grafana Cloud users can request this feature by &lt;a href="/profile/org#support">opening a support ticket in the Cloud Portal&lt;/a>.&lt;/p>&lt;/blockquote>&lt;/div>
&lt;p>Images in notifications helps recipients of alert notifications better understand why an alert has fired or resolved by including a screenshot of the panel associated with the alert.&lt;/p></description></item></channel></rss>