<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Configure alert rules on Grafana Labs</title><link>https://grafana.com/docs/grafana/v12.4/alerting/alerting-rules/</link><description>Recent content in Configure alert rules on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/grafana/v12.4/alerting/alerting-rules/index.xml" rel="self" type="application/rss+xml"/><item><title>Configure Grafana-managed alert rules</title><link>https://grafana.com/docs/grafana/v12.4/alerting/alerting-rules/create-grafana-managed-rule/</link><pubDate>Fri, 03 Apr 2026 12:35:46 -0500</pubDate><guid>https://grafana.com/docs/grafana/v12.4/alerting/alerting-rules/create-grafana-managed-rule/</guid><content><![CDATA[&lt;h1 id=&#34;configure-grafana-managed-alert-rules&#34;&gt;Configure Grafana-managed alert rules&lt;/h1&gt;
&lt;p&gt;Grafana-managed alert rules are the default way to create alert rules in Grafana.&lt;/p&gt;
&lt;p&gt;Grafana-managed rules inherit their model from Prometheus Alerting and extend it with greater flexibility—such as multi-data source queries, expression-based transformations, advanced alert conditions, images in notifications, custom states, and more.&lt;/p&gt;
&lt;p&gt;To create or edit Grafana-managed alert rules, follow the instructions below.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-tip&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Tip&lt;/p&gt;&lt;p&gt;For quick-start tutorials on key alerting features, see 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/best-practices/tutorials/&#34;&gt;Getting started with Grafana Alerting tutorials&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Before you create Grafana-managed alert rules, review the following requirements and options.&lt;/p&gt;
&lt;h3 id=&#34;supported-data-sources&#34;&gt;Supported data sources&lt;/h3&gt;
&lt;p&gt;Grafana-managed alert rules can query backend data sources when the data source&amp;rsquo;s &lt;code&gt;plugin.json&lt;/code&gt; file sets &lt;code&gt;{&amp;quot;backend&amp;quot;: true, &amp;quot;alerting&amp;quot;: true}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Before you create an alert rule, verify that the data sources you plan to query are compatible and properly configured.&lt;/p&gt;
&lt;p&gt;You can find the public data sources that support alert rules in the &lt;a href=&#34;/grafana/plugins/data-source-plugins/?features=alerting&#34;&gt;Grafana Plugins directory&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;alert-rule-limits-in-grafana-cloud&#34;&gt;Alert rule limits in Grafana Cloud&lt;/h3&gt;
&lt;p&gt;In Grafana Cloud, the number of Grafana-managed alert rules you can create depends on your Grafana Cloud plan.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Free Forever plan: You can create up to 100 free alert rules, with each alert rule having a maximum of 1000 alert instances.&lt;/li&gt;
&lt;li&gt;All paid plans: They have a soft limit of 2000 alert rules and support unlimited alert instances. To increase the limit, open a support ticket from the &lt;a href=&#34;/docs/grafana-cloud/account-management/support/&#34;&gt;Cloud portal&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;permissions&#34;&gt;Permissions&lt;/h3&gt;
&lt;p&gt;Only users with &lt;strong&gt;Edit&lt;/strong&gt; permissions for the folder storing the rules can edit or delete Grafana-managed alert rules. Only admins can restore deleted Grafana-managed alert rules.&lt;/p&gt;
&lt;h3 id=&#34;provisioning&#34;&gt;Provisioning&lt;/h3&gt;
&lt;p&gt;Note that if you delete an alert resource created in the UI, you can no longer retrieve it.&lt;/p&gt;
&lt;p&gt;To backup and manage alert rules, you can 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/set-up/provision-alerting-resources/&#34;&gt;provision alerting resources&lt;/a&gt; using options such as configuration files, Terraform, or the Alerting API.&lt;/p&gt;
&lt;h3 id=&#34;default-versus-advanced-options&#34;&gt;Default versus Advanced options&lt;/h3&gt;
&lt;p&gt;Grafana Alerting provides multiple configuration options to support different alerting needs.&lt;/p&gt;
&lt;p&gt;To simplify alert rule creation, some settings display a &lt;strong&gt;Default&lt;/strong&gt; and an &lt;strong&gt;Advanced&lt;/strong&gt; configuration view:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#define-query-and-condition&#34;&gt;Define query and condition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#configure-notifications&#34;&gt;Configure notifications&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Use &lt;strong&gt;Default&lt;/strong&gt; to create basic query conditions and route alerts directly to a contact point. Use &lt;strong&gt;Advanced&lt;/strong&gt; for more complex query definitions, or to route alerts using notification policies.&lt;/p&gt;
&lt;p&gt;You can switch between options at any time. After you create an alert rule, Grafana remembers your last selection and uses it as the default for the next rule.&lt;/p&gt;
&lt;p&gt;If you prefer to always use advanced configuration, you can disable the &lt;strong&gt;Default&lt;/strong&gt; modes by disabling the &lt;code&gt;alertingQueryAndExpressionsStepMode&lt;/code&gt; and &lt;code&gt;alertingNotificationsStepMode&lt;/code&gt; feature toggles.&lt;/p&gt;
&lt;h2 id=&#34;set-alert-rule-name&#34;&gt;Set alert rule name&lt;/h2&gt;


&lt;div data-shared=&#34;alerts/configure-alert-rule-name.md&#34;&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;Alert rules&lt;/strong&gt; -&amp;gt; &lt;strong&gt;&#43; New alert rule&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter a name to identify your alert rule.&lt;/p&gt;
&lt;p&gt;This name is displayed in the alert rule list. It is also the &lt;code&gt;alertname&lt;/code&gt; label for every alert instance that is created from this rule.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;

        
&lt;h2 id=&#34;define-query-and-condition&#34;&gt;Define query and condition&lt;/h2&gt;
&lt;p&gt;Define a query to get the data you want to measure and a condition that needs to be met before an alert rule fires.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;Default&lt;/strong&gt; option allows to configure one query and one alert condition. The &lt;strong&gt;Advanced&lt;/strong&gt; option allows multiple queries and expressions for more complex rule definitions.&lt;/p&gt;
&lt;div class=&#34;collapse&#34; x-data=&#34;app_collapse()&#34;&gt;
  &lt;button class=&#34;collapse-trigger&#34; @click=&#34;toggle()&#34;&gt;
    &lt;span class=&#34;body-large&#34;&gt;Default options&lt;/span&gt;
    &lt;span class=&#34;collapse-trigger__icon&#34; :class=&#34;{ &#39;collapse-trigger__icon-open&#39; : open }&#34;&gt;
      
  &lt;svg width=&#34;27&#34; height=&#34;26&#34; viewBox=&#34;0 0 27 26&#34; fill=&#34;none&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path opacity=&#34;0.2&#34; d=&#34;M1.73047 12.8359C1.73047 19.4634 7.10305 24.8359 13.7305 24.8359C20.3579 24.8359 25.7305 19.4634 25.7305 12.8359C25.7305 6.20852 20.3579 0.835937 13.7305 0.835937C7.10305 0.835937 1.73047 6.20852 1.73047 12.8359Z&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;path d=&#34;M18.2344 12.8359L9.23438 12.8359&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;path d=&#34;M13.7344 8.33594L13.7344 17.3359&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;/svg&gt;


    &lt;/span&gt;
  &lt;/button&gt;
  &lt;div class=&#34;collapse-content&#34; x-ref=&#34;content&#34; hidden=&#34;until-found&#34;&gt;
    &lt;div class=&#34;collapse-content__inner&#34; x-ref=&#34;content-inner&#34;&gt;&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Select a data source.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add a 

&lt;a href=&#34;/404/&#34;&gt;query&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add an 

&lt;a href=&#34;/404/&#34;&gt;alert condition&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;When&lt;/strong&gt; input includes the reducer function and the last input is the threshold.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Preview&lt;/strong&gt; to verify.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;collapse&#34; x-data=&#34;app_collapse()&#34;&gt;
  &lt;button class=&#34;collapse-trigger&#34; @click=&#34;toggle()&#34;&gt;
    &lt;span class=&#34;body-large&#34;&gt;Advanced options&lt;/span&gt;
    &lt;span class=&#34;collapse-trigger__icon&#34; :class=&#34;{ &#39;collapse-trigger__icon-open&#39; : open }&#34;&gt;
      
  &lt;svg width=&#34;27&#34; height=&#34;26&#34; viewBox=&#34;0 0 27 26&#34; fill=&#34;none&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path opacity=&#34;0.2&#34; d=&#34;M1.73047 12.8359C1.73047 19.4634 7.10305 24.8359 13.7305 24.8359C20.3579 24.8359 25.7305 19.4634 25.7305 12.8359C25.7305 6.20852 20.3579 0.835937 13.7305 0.835937C7.10305 0.835937 1.73047 6.20852 1.73047 12.8359Z&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;path d=&#34;M18.2344 12.8359L9.23438 12.8359&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;path d=&#34;M13.7344 8.33594L13.7344 17.3359&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;/svg&gt;


    &lt;/span&gt;
  &lt;/button&gt;
  &lt;div class=&#34;collapse-content&#34; x-ref=&#34;content&#34; hidden=&#34;until-found&#34;&gt;
    &lt;div class=&#34;collapse-content__inner&#34; x-ref=&#34;content-inner&#34;&gt;&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Select a data source.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;From the &lt;strong&gt;Options&lt;/strong&gt; drop-down menu, specify a 

&lt;a href=&#34;/404/&#34;&gt;time range&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that Grafana Alerting only supports fixed relative time ranges, for example, &lt;code&gt;now-24hr: now&lt;/code&gt;.
It doesn&amp;rsquo;t support absolute time ranges: &lt;code&gt;2021-12-02 00:00:00 to 2021-12-05 23:59:592&lt;/code&gt; or semi-relative time ranges: &lt;code&gt;now/d to: now&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add a query.&lt;/p&gt;
&lt;p&gt;To add multiple 

&lt;a href=&#34;/404/&#34;&gt;queries&lt;/a&gt;, click &lt;strong&gt;Add query&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;All alert rules are managed by Grafana by default. If you want to switch to a data source-managed alert rule, click &lt;strong&gt;Switch to data source-managed alert rule&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add one or more 

&lt;a href=&#34;/404/&#34;&gt;expressions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;a. For each expression, select either &lt;strong&gt;Classic condition&lt;/strong&gt; to create a single alert rule, or choose from the &lt;strong&gt;Math&lt;/strong&gt;, &lt;strong&gt;Reduce&lt;/strong&gt;, and &lt;strong&gt;Resample&lt;/strong&gt; options to generate separate alert for each series.&lt;/p&gt;
&lt;p&gt;When using Prometheus, you can use an instant vector and built-in functions, so you don&amp;rsquo;t need to add additional expressions.&lt;/p&gt;
&lt;p&gt;b. Click &lt;strong&gt;Preview&lt;/strong&gt; to verify that the expression is successful.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To add a 

&lt;a href=&#34;/404/&#34;&gt;recovery threshold&lt;/a&gt;, enable the &lt;strong&gt;Custom recovery threshold&lt;/strong&gt; toggle and enter a value that defines when the alert should recover—transition to &lt;code&gt;Normal&lt;/code&gt; state from the &lt;code&gt;Alerting&lt;/code&gt; or &lt;code&gt;Pending&lt;/code&gt; state.&lt;/p&gt;
&lt;p&gt;You can only add one recovery threshold, and it must be part of the alert condition.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Set as alert condition&lt;/strong&gt; on the query or expression you want to set as your 

&lt;a href=&#34;/404/&#34;&gt;alert condition&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;You can switch between &lt;strong&gt;Default&lt;/strong&gt; and &lt;strong&gt;Advanced&lt;/strong&gt; options at any time.&lt;/p&gt;
&lt;p&gt;Switching from &lt;strong&gt;Advanced&lt;/strong&gt; to &lt;strong&gt;Default&lt;/strong&gt; may result in queries and expressions that can&amp;rsquo;t be converted. In this case, a warning message asks if you want to continue to reset to default settings.&lt;/p&gt;
&lt;p&gt;If the &lt;a href=&#34;#default-versus-advanced-options&#34;&gt;Default versus Advanced options&lt;/a&gt; feature is not enabled in your Grafana instance, follow the &lt;strong&gt;Advanced options&lt;/strong&gt; instructions.&lt;/p&gt;
&lt;h2 id=&#34;set-folder-and-labels&#34;&gt;Set folder and labels&lt;/h2&gt;
&lt;p&gt;Organize your alert rule with a folder and set of labels.&lt;/p&gt;
&lt;p&gt;In the &lt;strong&gt;Labels&lt;/strong&gt; section, you can optionally choose whether to add labels to organize your alert rules and their notifications. For more details, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rules/annotation-label/#labels&#34;&gt;alert rule labels&lt;/a&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Select a folder or click &lt;strong&gt;&#43; New folder&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add labels, if required.&lt;/p&gt;
&lt;p&gt;Add custom labels by selecting existing key-value pairs from the drop down, or add new labels by entering the new key or value.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;configure-alert-evaluation-behavior&#34;&gt;Configure alert evaluation behavior&lt;/h2&gt;
&lt;p&gt;Use 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rule-evaluation/&#34;&gt;alert rule evaluation&lt;/a&gt; to determine how frequently an alert rule should be evaluated and how quickly it should change its state.&lt;/p&gt;
&lt;p&gt;To do this, you need to make sure that your alert rule is in the right evaluation group and set a pending period time that works best for your use case.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Select an evaluation group or click &lt;strong&gt;&#43; New evaluation group&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If you are creating a new evaluation group, specify the interval for the group.&lt;/p&gt;
&lt;p&gt;All rules within the same group are evaluated concurrently over the same time interval.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter a 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rule-evaluation/#pending-period&#34;&gt;pending period&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The pending period is the period in which an alert rule can be in breach of the condition until it fires.&lt;/p&gt;
&lt;p&gt;After a condition is met, the alert goes into the &lt;strong&gt;Pending&lt;/strong&gt; state.
If the condition remains active for the duration specified, the alert transitions to the &lt;strong&gt;Firing&lt;/strong&gt; state, else it reverts to the &lt;strong&gt;Normal&lt;/strong&gt; state.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optionally, set the 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rule-evaluation/#keep-firing-for&#34;&gt;Keep firing for&lt;/a&gt; period.&lt;/p&gt;
&lt;p&gt;You can set the minimum amount of time that an alert remains firing after the breached threshold expression no longer returns any results. This sets an alert to a &amp;ldquo;Recovering&amp;rdquo; state for the duration of time set here. The Recovering state can be used to reduce noise from flapping alerts. Select &amp;ldquo;none&amp;rdquo; stop an alert from firing immediately after the breach threshold is cleared.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Turn on pause alert notifications, if required.&lt;/p&gt;
&lt;p&gt;You can pause alert rule evaluation to prevent noisy alerting while tuning your alerts.
Pausing stops alert rule evaluation and doesn&amp;rsquo;t create any alert instances.
This is different to 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/mute-timings/&#34;&gt;mute timings&lt;/a&gt;, which stop notifications from being delivered, but still allows for alert rule evaluation and the creation of alert instances.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In &lt;strong&gt;Configure no data and error handling&lt;/strong&gt;, you can define the alerting behavior and alerting state for two scenarios:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;When the evaluation returns &lt;strong&gt;No data&lt;/strong&gt; or all values are null.&lt;/li&gt;
&lt;li&gt;When the evaluation returns &lt;strong&gt;Error&lt;/strong&gt; or timeout.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;configure-no-data-and-error-handling&#34;&gt;Configure no data and error handling&lt;/h3&gt;

   
   &lt;div data-shared=&#34;alerts/table-configure-no-data-and-error.md&#34;&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;Configure&lt;/th&gt;
                 &lt;th&gt;Set alert state&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;No Data&lt;/td&gt;
                 &lt;td&gt;No Data&lt;/td&gt;
                 &lt;td&gt;The default option for &lt;strong&gt;No Data&lt;/strong&gt; events.&lt;br/&gt;Sets alert instance state to &lt;code&gt;No Data&lt;/code&gt;. &lt;br/&gt; The alert rule immediately creates a new &lt;code&gt;DatasourceNoData&lt;/code&gt; alert instance after evaluation, with the alert rule&amp;rsquo;s name, UID, and the data source UID as labels.&lt;/td&gt;
             &lt;/tr&gt;
             &lt;tr&gt;
                 &lt;td&gt;Error&lt;/td&gt;
                 &lt;td&gt;Error&lt;/td&gt;
                 &lt;td&gt;The default option for &lt;strong&gt;Error&lt;/strong&gt; events.&lt;br/&gt;Sets alert instance state to &lt;code&gt;Error&lt;/code&gt;. &lt;br/&gt; The alert rule immediately creates a new &lt;code&gt;DatasourceError&lt;/code&gt; alert instance after evaluation, with the alert rule&amp;rsquo;s name, UID, and the data source UID as labels.&lt;/td&gt;
             &lt;/tr&gt;
             &lt;tr&gt;
                 &lt;td&gt;No Data or Error&lt;/td&gt;
                 &lt;td&gt;Alerting&lt;/td&gt;
                 &lt;td&gt;Sets the alert instance state to &lt;code&gt;Pending&lt;/code&gt; and then transitions to &lt;code&gt;Alerting&lt;/code&gt; once the pending period ends. If you sent the pending period to 0, the alert instance state is immediately set to &lt;code&gt;Alerting&lt;/code&gt;.&lt;/td&gt;
             &lt;/tr&gt;
             &lt;tr&gt;
                 &lt;td&gt;No Data or Error&lt;/td&gt;
                 &lt;td&gt;Normal&lt;/td&gt;
                 &lt;td&gt;Sets alert instance state to &lt;code&gt;Normal&lt;/code&gt;.&lt;/td&gt;
             &lt;/tr&gt;
             &lt;tr&gt;
                 &lt;td&gt;No Data or Error&lt;/td&gt;
                 &lt;td&gt;Keep Last State&lt;/td&gt;
                 &lt;td&gt;Maintains the alert instance in its last state. Useful for mitigating temporary issues.&lt;/td&gt;
             &lt;/tr&gt;
         &lt;/tbody&gt;
       &lt;/table&gt;
     &lt;/div&gt;
   &lt;/section&gt;&lt;/div&gt;
   
           
&lt;p&gt;For more details, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rule-evaluation/stale-alert-instances/&#34;&gt;alert instance states&lt;/a&gt; and 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rule-evaluation/nodata-and-error-states/#modify-the-no-data-or-error-state&#34;&gt;modify the no data or error state&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In &lt;strong&gt;Configure no data and error handling&lt;/strong&gt;, you can also configure 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rule-evaluation/stale-alert-instances/#configure-missing-series-evaluations-to-resolve&#34;&gt;Missing series evaluations to resolve&lt;/a&gt;: how many consecutive evaluation intervals must pass without data before an alert instance is considered stale.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;configure-notifications&#34;&gt;Configure notifications&lt;/h2&gt;
&lt;p&gt;Configure who receives notifications when the alert rule fires.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;Default&lt;/strong&gt; option allows to select a 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/notifications/contact-points/&#34;&gt;contact point&lt;/a&gt; to handle notifications for this alert rule. The &lt;strong&gt;Advanced&lt;/strong&gt; option routes notifications through 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/notifications/notification-policies/&#34;&gt;notification policies&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&#34;collapse&#34; x-data=&#34;app_collapse()&#34;&gt;
  &lt;button class=&#34;collapse-trigger&#34; @click=&#34;toggle()&#34;&gt;
    &lt;span class=&#34;body-large&#34;&gt;Default options&lt;/span&gt;
    &lt;span class=&#34;collapse-trigger__icon&#34; :class=&#34;{ &#39;collapse-trigger__icon-open&#39; : open }&#34;&gt;
      
  &lt;svg width=&#34;27&#34; height=&#34;26&#34; viewBox=&#34;0 0 27 26&#34; fill=&#34;none&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path opacity=&#34;0.2&#34; d=&#34;M1.73047 12.8359C1.73047 19.4634 7.10305 24.8359 13.7305 24.8359C20.3579 24.8359 25.7305 19.4634 25.7305 12.8359C25.7305 6.20852 20.3579 0.835937 13.7305 0.835937C7.10305 0.835937 1.73047 6.20852 1.73047 12.8359Z&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;path d=&#34;M18.2344 12.8359L9.23438 12.8359&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;path d=&#34;M13.7344 8.33594L13.7344 17.3359&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;/svg&gt;


    &lt;/span&gt;
  &lt;/button&gt;
  &lt;div class=&#34;collapse-content&#34; x-ref=&#34;content&#34; hidden=&#34;until-found&#34;&gt;
    &lt;div class=&#34;collapse-content__inner&#34; x-ref=&#34;content-inner&#34;&gt;&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Select an existing 

&lt;a href=&#34;/404/&#34;&gt;contact point&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;All notifications for this alert rule are sent to this contact point automatically and notification policies aren&amp;rsquo;t used.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optionally, configure additional notification settings like grouping or timing options.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;collapse&#34; x-data=&#34;app_collapse()&#34;&gt;
  &lt;button class=&#34;collapse-trigger&#34; @click=&#34;toggle()&#34;&gt;
    &lt;span class=&#34;body-large&#34;&gt;Advanced options&lt;/span&gt;
    &lt;span class=&#34;collapse-trigger__icon&#34; :class=&#34;{ &#39;collapse-trigger__icon-open&#39; : open }&#34;&gt;
      
  &lt;svg width=&#34;27&#34; height=&#34;26&#34; viewBox=&#34;0 0 27 26&#34; fill=&#34;none&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path opacity=&#34;0.2&#34; d=&#34;M1.73047 12.8359C1.73047 19.4634 7.10305 24.8359 13.7305 24.8359C20.3579 24.8359 25.7305 19.4634 25.7305 12.8359C25.7305 6.20852 20.3579 0.835937 13.7305 0.835937C7.10305 0.835937 1.73047 6.20852 1.73047 12.8359Z&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;path d=&#34;M18.2344 12.8359L9.23438 12.8359&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;path d=&#34;M13.7344 8.33594L13.7344 17.3359&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;/svg&gt;


    &lt;/span&gt;
  &lt;/button&gt;
  &lt;div class=&#34;collapse-content&#34; x-ref=&#34;content&#34; hidden=&#34;until-found&#34;&gt;
    &lt;div class=&#34;collapse-content__inner&#34; x-ref=&#34;content-inner&#34;&gt;&lt;p&gt;With this option, all notifications for this alert rule are managed by the 

&lt;a href=&#34;/404/&#34;&gt;notification policy tree&lt;/a&gt;, which routes alerts based on their labels.&lt;/p&gt;
&lt;p&gt;You can preview which notification policy would handle notifications from this alert rule.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Preview routing&lt;/strong&gt; after configuring the previous alert rule settings.&lt;/p&gt;
&lt;p&gt;Based on the alert labels and query labels, Grafana displays the notification policies that would handle the notifications.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;View route&lt;/strong&gt; to view policy and routing details.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;You can switch between &lt;strong&gt;Default&lt;/strong&gt; and &lt;strong&gt;Advanced&lt;/strong&gt; options at any time.&lt;/p&gt;
&lt;p&gt;If the &lt;a href=&#34;#default-versus-advanced-options&#34;&gt;Default versus Advanced options&lt;/a&gt; feature is not enabled in your Grafana instance, follow the &lt;strong&gt;Advanced options&lt;/strong&gt; instructions.&lt;/p&gt;
&lt;h2 id=&#34;configure-notification-message&#34;&gt;Configure notification message&lt;/h2&gt;
&lt;p&gt;Use 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rules/annotation-label/#annotations&#34;&gt;annotations&lt;/a&gt; to add information to alert messages that can help respond to the alert.&lt;/p&gt;
&lt;p&gt;Annotations are included by default in notification messages, and can use text or 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/templates/&#34;&gt;templates&lt;/a&gt; to display dynamic data from queries.&lt;/p&gt;
&lt;p&gt;Grafana provides several optional annotations.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Optional: Add a summary.&lt;/p&gt;
&lt;p&gt;Short summary of what happened and why.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: Add a description.&lt;/p&gt;
&lt;p&gt;Description of what the alert rule does.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: Add a Runbook URL.&lt;/p&gt;
&lt;p&gt;Webpage where you keep your runbook for the alert&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: Add a custom annotation.&lt;/p&gt;
&lt;p&gt;Add any additional information that could help address the alert.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: &lt;strong&gt;Link dashboard and panel&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;
    &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; to facilitate alert investigation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save rule&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="configure-grafana-managed-alert-rules">Configure Grafana-managed alert rules&lt;/h1>
&lt;p>Grafana-managed alert rules are the default way to create alert rules in Grafana.&lt;/p>
&lt;p>Grafana-managed rules inherit their model from Prometheus Alerting and extend it with greater flexibility—such as multi-data source queries, expression-based transformations, advanced alert conditions, images in notifications, custom states, and more.&lt;/p></description></item><item><title>Create and link alert rules to panels</title><link>https://grafana.com/docs/grafana/v12.4/alerting/alerting-rules/link-alert-rules-to-panels/</link><pubDate>Fri, 03 Apr 2026 12:35:46 -0500</pubDate><guid>https://grafana.com/docs/grafana/v12.4/alerting/alerting-rules/link-alert-rules-to-panels/</guid><content><![CDATA[&lt;h1 id=&#34;create-and-link-alert-rules-to-panels&#34;&gt;Create and link alert rules to panels&lt;/h1&gt;
&lt;p&gt;Grafana allows you to link an alert rule to a dashboard panel. This can help you:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Inform alert responders about where to investigate and which data to examine.&lt;/li&gt;
&lt;li&gt;Visualize the alert state directly from dashboards.&lt;/li&gt;
&lt;li&gt;Include a screenshot of the panel in notification messages.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;An alert rule is linked to a panel by setting the 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rules/annotation-label/#annotations&#34;&gt;&lt;code&gt;__dashboardUid__&lt;/code&gt; and &lt;code&gt;__panelId__&lt;/code&gt; annotations&lt;/a&gt;. Both annotations must be set together.&lt;/p&gt;
&lt;h2 id=&#34;link-alert-rules-to-panels&#34;&gt;Link alert rules to panels&lt;/h2&gt;
&lt;p&gt;When configuring the alert rule, you can set the dashboard and panel annotations as shown in this &lt;a href=&#34;https://youtu.be/ClLp-iSoaSY?si=qKWnvSVaQuvYcuw9&amp;amp;t=170&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;video&lt;/a&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Configure the alert rule.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Configure notification message&lt;/strong&gt; section, click &lt;strong&gt;Link dashboard and panel&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select an existing dashboard, then choose a panel from the selected dashboard.&lt;/li&gt;
&lt;li&gt;Complete the alert rule configuration and click &lt;strong&gt;Save rule&lt;/strong&gt; to initiate the alert rule.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can then 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/monitor-status/view-alert-state/#view-alert-state-on-panels&#34;&gt;view the alert state on the panel&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By default, notification messages include a link to the dashboard panel. Additionally, you can 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/images-in-notifications/&#34;&gt;enable displaying panel screenshots in notifications&lt;/a&gt;.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 1200px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link captioned&#34;
        href=&#34;/media/docs/alerting/panel-displays-alert-state.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload mb-0&#34;
          data-src=&#34;/media/docs/alerting/panel-displays-alert-state.png&#34;data-srcset=&#34;/media/docs/alerting/panel-displays-alert-state.png?w=320 320w, /media/docs/alerting/panel-displays-alert-state.png?w=550 550w, /media/docs/alerting/panel-displays-alert-state.png?w=750 750w, /media/docs/alerting/panel-displays-alert-state.png?w=900 900w, /media/docs/alerting/panel-displays-alert-state.png?w=1040 1040w, /media/docs/alerting/panel-displays-alert-state.png?w=1240 1240w, /media/docs/alerting/panel-displays-alert-state.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;A panel displaying the alert status and state changes.&#34;width=&#34;1674&#34;height=&#34;700&#34;title=&#34;A panel displaying the alert status and state changes.&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/alerting/panel-displays-alert-state.png&#34;
            alt=&#34;A panel displaying the alert status and state changes.&#34;width=&#34;1674&#34;height=&#34;700&#34;title=&#34;A panel displaying the alert status and state changes.&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;A panel displaying the alert status and state changes.&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h2 id=&#34;create-alert-rules-from-panels&#34;&gt;Create alert rules from panels&lt;/h2&gt;
&lt;p&gt;To streamline alert creation, you can create an alert rule directly from a panel.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to a dashboard in the &lt;strong&gt;Dashboards&lt;/strong&gt; section.&lt;/li&gt;
&lt;li&gt;Hover over the top-right corner of a panel and click the panel menu icon.&lt;/li&gt;
&lt;li&gt;From the dropdown menu, select &lt;strong&gt;More&amp;hellip;&lt;/strong&gt; &amp;gt; &lt;strong&gt;New alert rule&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;This opens the &lt;strong&gt;Edit rule&lt;/strong&gt; form and pre-fills some values:
&lt;ul&gt;
&lt;li&gt;Sets the annotations to the corresponding dashboard and panel.&lt;/li&gt;
&lt;li&gt;Sets the alert rule query using the panel query.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Complete the alert rule configuration and click &lt;strong&gt;Save rule&lt;/strong&gt; to initiate the alert rule.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can then 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/monitor-status/view-alert-state/#view-alert-state-on-panels&#34;&gt;view the alert state on the panel&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By default, notification messages include a link to the dashboard panel. Additionally, you can 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/images-in-notifications/&#34;&gt;enable displaying panel screenshots in notifications&lt;/a&gt;.&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;Changes to panel and alert rule queries aren&amp;rsquo;t synchronized. If you change a query, you have to update it in both the panel and the alert rule.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;access-linked-alert-rules-from-panels&#34;&gt;Access linked alert rules from panels&lt;/h2&gt;
&lt;p&gt;This option is available only in 
    &lt;a href=&#34;/docs/grafana/v12.4/panels-visualizations/visualizations/time-series/&#34;&gt;time series panels&lt;/a&gt;. To access alert rules associated to a time series panel, complete the following steps.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Hover over the top-right corner of the panel and click the panel menu icon.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Edit&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Alert&lt;/strong&gt; tab to view existing alert rules or create a new one.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class=&#34;admonition admonition-tip&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Tip&lt;/p&gt;&lt;p&gt;For a practical example, refer to our &lt;a href=&#34;http://www.grafana.com/tutorials/alerting-get-started-pt6/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Getting started: Link alerts to visualizations tutorial&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

]]></content><description>&lt;h1 id="create-and-link-alert-rules-to-panels">Create and link alert rules to panels&lt;/h1>
&lt;p>Grafana allows you to link an alert rule to a dashboard panel. This can help you:&lt;/p>
&lt;ul>
&lt;li>Inform alert responders about where to investigate and which data to examine.&lt;/li>
&lt;li>Visualize the alert state directly from dashboards.&lt;/li>
&lt;li>Include a screenshot of the panel in notification messages.&lt;/li>
&lt;/ul>
&lt;p>An alert rule is linked to a panel by setting the
&lt;a href="/docs/grafana/v12.4/alerting/fundamentals/alert-rules/annotation-label/#annotations">&lt;code>__dashboardUid__&lt;/code> and &lt;code>__panelId__&lt;/code> annotations&lt;/a>. Both annotations must be set together.&lt;/p></description></item><item><title>Import data source-managed rules to Grafana-managed rules</title><link>https://grafana.com/docs/grafana/v12.4/alerting/alerting-rules/alerting-migration/</link><pubDate>Fri, 03 Apr 2026 12:35:46 -0500</pubDate><guid>https://grafana.com/docs/grafana/v12.4/alerting/alerting-rules/alerting-migration/</guid><content><![CDATA[&lt;h1 id=&#34;import-data-source-managed-rules-to-grafana-managed-rules&#34;&gt;Import data source-managed rules to Grafana-managed rules&lt;/h1&gt;
&lt;p&gt;You can convert existing alert rules from data sources such as Mimir, Loki, and Prometheus into Grafana-managed alert rules. This enables you to operate and manage these rules using Grafana Alerting.&lt;/p&gt;
&lt;p&gt;This guide explains two methods for importing data source-managed rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Using the &lt;a href=&#34;#import-rules-with-grafana-alerting&#34;&gt;Grafana Alerting user interface&lt;/a&gt; to import rules from connected data sources or Prometheus rule YAML files.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Using &lt;a href=&#34;#import-rules-with-command-line-tools&#34;&gt;command-line tools&lt;/a&gt; like &lt;code&gt;mimirtool&lt;/code&gt; and &lt;code&gt;cortextool&lt;/code&gt; to import rules from YAML files.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Importing rules is a safe operation: the original data source–managed rules remain intact in their original location. During import, the rules are converted into Grafana-managed rules while preserving their configuration and behavior.&lt;/p&gt;
&lt;p&gt;Choose the method that best fits your workflow. As a best practice, test and validate your import process before migrating all alert rules.&lt;/p&gt;
&lt;h2 id=&#34;how-it-works&#34;&gt;How it works&lt;/h2&gt;
&lt;p&gt;When you use any of the import methods, data source–managed rules are copied to another folder as Grafana-managed rules.&lt;/p&gt;
&lt;p&gt;The original data source–managed rules remain intact in their original location.&lt;/p&gt;
&lt;p&gt;The copied rules are converted to Grafana-managed rules, preserving their behavior by using equivalent Grafana-managed features. The following settings are applied during the conversion:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Unique UIDs&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The newly created rules are assigned unique UIDs.
If you don’t want a UID to be auto-generated, you can specify one using the &lt;code&gt;__grafana_alert_rule_uid__&lt;/code&gt; label.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Query offset&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A query offset is applied to each rule. For example, an offset of &lt;code&gt;1m&lt;/code&gt; adjusts the query&amp;rsquo;s time range to &lt;code&gt;To: now-1m&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The rule query offset is taken from the &lt;code&gt;query_offset&lt;/code&gt; value in the rule group configuration. If empty, it defaults to the 
    &lt;a href=&#34;/docs/grafana/v12.4/setup-grafana/configure-grafana/#rule_query_offset&#34;&gt;&lt;code&gt;rule_query_offset&lt;/code&gt; configuration setting&lt;/a&gt;, which is &lt;code&gt;1m&lt;/code&gt; by default.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rule query conversion&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For alert rules, adds &lt;code&gt;prometheus_math&lt;/code&gt; and &lt;code&gt;threshold&lt;/code&gt; expressions to preserve Prometheus no data behavior, ensuring the alert stays in &lt;strong&gt;Normal&lt;/strong&gt; state when &lt;code&gt;query&lt;/code&gt; returns no data.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Missing series evaluations to resolve&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rule-evaluation/stale-alert-instances/#configure-missing-series-evaluations-to-resolve&#34;&gt;Missing series evaluations to resolve&lt;/a&gt; setting is set to &lt;code&gt;1&lt;/code&gt; to replicate Prometheus’s alert eviction behavior.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rule group labels&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Labels defined at the rule group level are added as labels to each imported rule within the group.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Sequential evaluation&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Imported rules are evaluated sequentially within each rule group, mirroring Prometheus behavior. This differs from native Grafana-managed alert rules, where the evaluation order is not enforced. For more details, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rule-evaluation/&#34;&gt;evaluation strategies&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Feature compatibility&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The rule group &lt;code&gt;limit&lt;/code&gt; option and the &lt;code&gt;query&lt;/code&gt; function within alert rule templates are not currently supported in Grafana-managed rules. If the &lt;code&gt;limit&lt;/code&gt; option is present, the import fails. However, rules with &lt;code&gt;query&lt;/code&gt; in templates are imported.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&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;Rules with the label &lt;code&gt;__grafana_origin&lt;/code&gt; are not included in rule imports. These rules are typically created by apps such as &lt;strong&gt;Kubernetes Monitoring&lt;/strong&gt;, &lt;strong&gt;Synthetic Monitoring&lt;/strong&gt;, and other &lt;strong&gt;Grafana plugins&lt;/strong&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;import-rules-with-grafana-alerting&#34;&gt;Import rules with Grafana Alerting&lt;/h2&gt;
&lt;p&gt;You can use the Grafana Alerting user interface to import rules from the following sources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Connected Mimir and Loki data sources with the ruler API enabled&lt;/li&gt;
&lt;li&gt;Prometheus YAML rule files&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Imported rules using this method are editable in the user interface. Like regular Grafana-managed rules, you can later export them for provisioning.&lt;/p&gt;
&lt;h4 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h4&gt;
&lt;p&gt;To use Grafana Alerting to migrate rules, you need the following &lt;a href=&#34;/docs/grafana/latest/administration/roles-and-permissions/access-control/&#34;&gt;RBAC permissions&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Alerting&lt;/strong&gt;: &lt;code&gt;Rules Writer&lt;/code&gt;, &lt;code&gt;Set provisioning status&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Datasources&lt;/strong&gt;: &lt;code&gt;Reader&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Folders&lt;/strong&gt;: &lt;code&gt;Creator&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The Folders permission is optional and only necessary if you want to create new folders for your target namespace. If your account doesn&amp;rsquo;t have permissions to view a namespace, the tool creates a new one.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To convert data source-managed alert rules to Grafana managed alerts:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Go to &lt;strong&gt;Alerting &amp;gt; Alert rules&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Navigate to the Data source-managed alert rules section and click &lt;strong&gt;Import to Grafana-managed rules&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Choose the &lt;strong&gt;Import source&lt;/strong&gt; from which you want to import rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Select &lt;strong&gt;Existing data source-managed rules&lt;/strong&gt; to import rules from connected Mimir or Loki data sources with the ruler API enabled.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Prometheus YAML file&lt;/strong&gt; to import rules by uploading a Prometheus YAML rule file.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Data source&lt;/strong&gt; dropdown, select the data source that the imported alert rules will query.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) In Additional settings, select a target folder or designate a new folder to import the rules into.&lt;/p&gt;
&lt;p&gt;If you import the rules into an existing folder, don&amp;rsquo;t choose a folder with existing alert rules, as they could get overwritten.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Select a Namespace and/or Group to determine which rules are imported.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Turn on &lt;strong&gt;Pause imported alerting rules&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Pausing stops alert rule evaluation and doesn’t create any alert instances for the newly created Grafana-managed alert rules.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Turn on &lt;strong&gt;Pause imported recording rules&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Pausing stops alert rule evaluation behavior for the newly created Grafana-managed alert rules.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) In the &lt;strong&gt;Target data source&lt;/strong&gt; of the &lt;strong&gt;Recording rules&lt;/strong&gt; section, you can select the data source to which the imported recording rules will write metrics. By default, it is the data source selected in the &lt;strong&gt;Data source&lt;/strong&gt; dropdown.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Import&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;A preview shows the rules that will be imported. If your target folder contains folders with the same name of the imported folders, a warning displays to inform you. You can explore the warning to see a list of folders that might be overwritten.&lt;/p&gt;
&lt;p&gt;Click &lt;strong&gt;Yes, import&lt;/strong&gt; to import the rules.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;import-rules-with-command-line-tools&#34;&gt;Import rules with command-line tools&lt;/h2&gt;
&lt;p&gt;You can also use command-line tools to import data source-managed rules as Grafana-managed rules: use &lt;code&gt;mimirtool&lt;/code&gt; for Mimir and Prometheus rules, and &lt;code&gt;cortextool&lt;/code&gt; for Loki rules.&lt;/p&gt;
&lt;p&gt;Both tools provide &lt;code&gt;rules&lt;/code&gt; commands to import rules groups. For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;rules load&lt;/code&gt; can import rule groups from files.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rules sync&lt;/code&gt; can read rule files and applies only the differences compared to existing Grafana-managed rules. This is useful for automation workflows and pipelines.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By default, rules imported using the API or command-line tools are &lt;strong&gt;Provisioned&lt;/strong&gt; and not editable in the user interface. To make them editable, enable the &lt;a href=&#34;#x-disable-provenance&#34;&gt;X-Disable-Provenance&lt;/a&gt; header.&lt;/p&gt;
&lt;h4 id=&#34;before-you-begin-1&#34;&gt;Before you begin&lt;/h4&gt;
&lt;p&gt;You need to have installed &lt;a href=&#34;/docs/mimir/latest/manage/tools/mimirtool/&#34;&gt;&lt;code&gt;mimirtool&lt;/code&gt;&lt;/a&gt; or &lt;a href=&#34;https://github.com/grafana/cortex-tools&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;cortextool&lt;/code&gt;&lt;/a&gt; (version &lt;code&gt;0.11.3&lt;/code&gt; or later).&lt;/p&gt;
&lt;p&gt;You need a service account with the following &lt;a href=&#34;/docs/grafana/latest/administration/roles-and-permissions/access-control/&#34;&gt;RBAC permissions&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Alerting&lt;/strong&gt;: &lt;code&gt;Rules Reader&lt;/code&gt;, &lt;code&gt;Rules Writer&lt;/code&gt;, &lt;code&gt;Set provisioning status&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Datasources&lt;/strong&gt;: &lt;code&gt;Reader&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Folders&lt;/strong&gt;: &lt;code&gt;Creator&lt;/code&gt;, &lt;code&gt;Reader&lt;/code&gt;, &lt;code&gt;Writer&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You need to a service account token with your service account. For more details, refer to &lt;a href=&#34;/docs/grafana/latest/administration/service-accounts/&#34;&gt;service accounts and service account tokens&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;mimirtool&#34;&gt;mimirtool&lt;/h3&gt;
&lt;p&gt;To convert and import them into a Grafana instance, you can use the &lt;code&gt;mimirtool rules load&lt;/code&gt; command:&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;Bash&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-bash&#34;&gt;MIMIR_ADDRESS=&amp;lt;GRAFANA_BASE_URL&amp;gt;/api/convert/ \
MIMIR_AUTH_TOKEN=&amp;lt;SERVICE_ACCOUNT_TOKEN&amp;gt; \
MIMIR_TENANT_ID=1 \
mimirtool rules load rule_file.yaml \
  --extra-headers &amp;#34;X-Grafana-Alerting-Datasource-UID=&amp;lt;DATASOURCE_UID_QUERY_TARGET&amp;gt;&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This command imports Prometheus alert rules defined in &lt;code&gt;rule_file.yaml&lt;/code&gt; as Grafana-managed alert rules. It&amp;rsquo;s important to know that:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;When using the &lt;code&gt;&amp;lt;GRAFANA_BASE_URL&amp;gt;/api/convert/&lt;/code&gt; endpoint, &lt;code&gt;mimirtool&lt;/code&gt; interacts with Grafana—not with a Mimir instance. In this case, &lt;code&gt;MIMIR_TENANT_ID&lt;/code&gt; must always be set to &lt;code&gt;1&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&#34;#x-grafana-alerting-datasource-uid&#34;&gt;&lt;code&gt;X-Grafana-Alerting-Datasource-UID&lt;/code&gt; header&lt;/a&gt; configures the data source that the imported alert rules will query. Use multiple &lt;code&gt;--extra-headers&lt;/code&gt; flags to include other &lt;a href=&#34;#optional-headers&#34;&gt;optional headers&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Similarly, the &lt;code&gt;rules sync&lt;/code&gt; command can import and update Grafana-managed alert rules.&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;Bash&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-bash&#34;&gt;MIMIR_ADDRESS=&amp;lt;GRAFANA_BASE_URL&amp;gt;/api/convert/ \
MIMIR_AUTH_TOKEN=&amp;lt;SERVICE_ACCOUNT_TOKEN&amp;gt; \
MIMIR_TENANT_ID=1 \
mimirtool rules sync rule_file.yaml \
  --extra-headers &amp;#34;X-Grafana-Alerting-Datasource-UID=&amp;lt;DATASOURCE_UID_QUERY_TARGET&amp;gt;&amp;#34; \
  --concurrency 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;--concurrency&lt;/code&gt; flag must be set to &lt;code&gt;1&lt;/code&gt;, as the default value of &lt;code&gt;8&lt;/code&gt; may cause API errors.&lt;/p&gt;
&lt;p&gt;This &lt;code&gt;sync&lt;/code&gt; command reads rules from the file, compares them with the existing Grafana-managed rules in the instance, and applies only the differences—creating, updating, or deleting rules as needed.&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;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-output&#34;&gt;## Sync Summary: 0 Groups Created, 1 Groups Updated, 0 Groups Deleted&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For more information other Mimirtool commands and options, see the &lt;a href=&#34;/docs/mimir/latest/manage/tools/mimirtool/#rules&#34;&gt;Mimirtool documentation&lt;/a&gt; and the &lt;a href=&#34;/docs/mimir/latest/references/http-api/#ruler-rules:~:text=config/v1/rules-,Get%20rule%20groups%20by%20namespace,DELETE%20%3Cprometheus%2Dhttp%2Dprefix%3E/config/v1/rules/%7Bnamespace%7D,-Delete%20tenant%20configuration&#34;&gt;Mimir HTTP Rule API documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;cortextool&#34;&gt;cortextool&lt;/h3&gt;
&lt;p&gt;For Loki alert rules, use &lt;a href=&#34;https://github.com/grafana/cortex-tools&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;cortextool&lt;/code&gt;&lt;/a&gt; (version &lt;code&gt;0.11.3&lt;/code&gt; or later) with the &lt;code&gt;--backend=loki&lt;/code&gt; flag. 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;Bash&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-bash&#34;&gt;CORTEX_ADDRESS=&amp;lt;GRAFANA_BASE_URL&amp;gt;/api/convert/ \
CORTEX_AUTH_TOKEN=&amp;lt;SERVICE_ACCOUNT_TOKEN&amp;gt; \
CORTEX_TENANT_ID=1 \
cortextool rules load loki_rules.yaml \
  --extra-headers &amp;#34;X-Grafana-Alerting-Datasource-UID=&amp;lt;LOKI_DATASOURCE_UID_QUERY_TARGET&amp;gt;&amp;#34; \
  --backend=loki&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;optional-headers&#34;&gt;Optional Headers&lt;/h3&gt;
&lt;p&gt;Additional configuration headers for more granular import control include the following:&lt;/p&gt;
&lt;h4 id=&#34;x-disable-provenance&#34;&gt;&lt;code&gt;X-Disable-Provenance&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;When this header is set to &lt;code&gt;true&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The imported rules are not marked as provisioned.&lt;/li&gt;
&lt;li&gt;They can then be edited in the Grafana UI.&lt;/li&gt;
&lt;li&gt;They are excluded from the &lt;code&gt;GET&lt;/code&gt; and &lt;code&gt;DELETE&lt;/code&gt; operations on the &lt;a href=&#34;#compatible-endpoints&#34;&gt;&lt;code&gt;/api/convert&lt;/code&gt; endpoints&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Do not enable this header when using the &lt;code&gt;rules sync&lt;/code&gt; command, as it relies on the &lt;code&gt;GET&lt;/code&gt; and &lt;code&gt;DELETE&lt;/code&gt; operations to detect and update existing rules.&lt;/p&gt;
&lt;h4 id=&#34;x-grafana-alerting-alert-rules-paused&#34;&gt;&lt;code&gt;X-Grafana-Alerting-Alert-Rules-Paused&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Set to &lt;code&gt;true&lt;/code&gt; to import alert rules in paused state.&lt;/p&gt;
&lt;h4 id=&#34;x-grafana-alerting-recording-rules-paused&#34;&gt;&lt;code&gt;X-Grafana-Alerting-Recording-Rules-Paused&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Set to &lt;code&gt;true&lt;/code&gt; to import recording rules in paused state.&lt;/p&gt;
&lt;h4 id=&#34;x-grafana-alerting-datasource-uid&#34;&gt;&lt;code&gt;X-Grafana-Alerting-Datasource-UID&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The UID of the data source to use for alert rule queries.&lt;/p&gt;
&lt;p&gt;If not specified in the header, Grafana uses the configured default from &lt;code&gt;unified_alerting.prometheus_conversion.default_datasource_uid&lt;/code&gt;. If neither the header nor the configuration option is provided, the request fails.&lt;/p&gt;
&lt;h4 id=&#34;x-grafana-alerting-target-datasource-uid&#34;&gt;&lt;code&gt;X-Grafana-Alerting-Target-Datasource-UID&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The UID of the target data source for recording rules. If not specified, the value from &lt;code&gt;X-Grafana-Alerting-Datasource-UID&lt;/code&gt; is used.&lt;/p&gt;
&lt;h4 id=&#34;x-grafana-alerting-folder-uid&#34;&gt;&lt;code&gt;X-Grafana-Alerting-Folder-UID&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Enter the UID of the target destination folder for imported rules.&lt;/p&gt;
&lt;h4 id=&#34;x-grafana-alerting-notification-settings&#34;&gt;&lt;code&gt;X-Grafana-Alerting-Notification-Settings&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;JSON-encoded &lt;a href=&#34;#alertrulenotificationsettings-object&#34;&gt;&lt;code&gt;AlertRuleNotificationSettings&lt;/code&gt; object&lt;/a&gt; that allows setting the contact point for the alert rules.&lt;/p&gt;
&lt;div class=&#34;collapse&#34; x-data=&#34;app_collapse()&#34;&gt;
  &lt;button class=&#34;collapse-trigger&#34; @click=&#34;toggle()&#34;&gt;
    &lt;span class=&#34;body-large&#34;&gt;AlertRuleNotificationSettings object&lt;/span&gt;
    &lt;span class=&#34;collapse-trigger__icon&#34; :class=&#34;{ &#39;collapse-trigger__icon-open&#39; : open }&#34;&gt;
      
  &lt;svg width=&#34;27&#34; height=&#34;26&#34; viewBox=&#34;0 0 27 26&#34; fill=&#34;none&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path opacity=&#34;0.2&#34; d=&#34;M1.73047 12.8359C1.73047 19.4634 7.10305 24.8359 13.7305 24.8359C20.3579 24.8359 25.7305 19.4634 25.7305 12.8359C25.7305 6.20852 20.3579 0.835937 13.7305 0.835937C7.10305 0.835937 1.73047 6.20852 1.73047 12.8359Z&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;path d=&#34;M18.2344 12.8359L9.23438 12.8359&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;path d=&#34;M13.7344 8.33594L13.7344 17.3359&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;/svg&gt;


    &lt;/span&gt;
  &lt;/button&gt;
  &lt;div class=&#34;collapse-content&#34; x-ref=&#34;content&#34; hidden=&#34;until-found&#34;&gt;
    &lt;div class=&#34;collapse-content__inner&#34; x-ref=&#34;content-inner&#34;&gt;&lt;h5 id=&#34;alertrulenotificationsettings-object&#34;&gt;AlertRuleNotificationSettings object&lt;/h5&gt;
&lt;p&gt;When you set &lt;code&gt;X-Grafana-Alerting-Notification-Settings&lt;/code&gt;, the header value must be a JSON-encoded object with the following keys:&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;Field&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
              &lt;th&gt;Example&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;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;grafana-default&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Name of the contact point (receiver) to which alerts are routed. Must exist in Grafana before import.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;group_by&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;[]string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;[&amp;quot;alertname&amp;quot;,&amp;quot;grafana_folder&amp;quot;,&amp;quot;cluster&amp;quot;]&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Label set used by Alertmanager to aggregate alerts into a single notification.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;group_wait&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;30s&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How long Alertmanager waits before sending the first notification for a new group.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;group_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;5m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Time to wait before adding new alerts to an existing group&amp;rsquo;s next notification.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;repeat_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;4h&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Minimum time before a previously-sent notification is repeated. Must not be less than &lt;code&gt;group_interval&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;mute_time_intervals&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;[]string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;[&amp;quot;maintenance&amp;quot;]&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;One or more mute time interval names that silence alerts during those windows.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;active_time_intervals&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;[]string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;[&amp;quot;maintenance&amp;quot;]&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;List of active time interval names. Alerts are suppressed unless the current time matches one of them.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id=&#34;compatible-endpoints&#34;&gt;Compatible endpoints&lt;/h3&gt;
&lt;p&gt;The API endpoints listed in this section are supported in Grafana and are used by &lt;code&gt;mimirtool&lt;/code&gt; and &lt;code&gt;cortextool&lt;/code&gt;, as shown earlier. These endpoints are compatible with &lt;a href=&#34;/docs/mimir/latest/references/http-api/&#34;&gt;Mimir HTTP API&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In these endpoints, a &amp;ldquo;namespace&amp;rdquo; corresponds to a folder title in Grafana.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;POST&lt;/code&gt; endpoints can be used to import data source–managed alert rules. They accept requests in both YAML and JSON. If no media type is specified, YAML is assumed.&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;Endpoint&lt;/th&gt;
              &lt;th&gt;Method&lt;/th&gt;
              &lt;th&gt;Summary&lt;/th&gt;
              &lt;th&gt;Mimir equivalent&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;POST&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;/convert/prometheus/config/v1/rules&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;#create-or-update-multiple-rule-groups&#34;&gt;Create or update multiple rule groups&lt;/a&gt; across multiple namespaces. Requires &lt;a href=&#34;#x-grafana-alerting-datasource-uid&#34;&gt;&lt;code&gt;X-Grafana-Alerting-Datasource-UID&lt;/code&gt;&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;None&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;POST&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;/convert/prometheus/config/v1/rules/:namespaceTitle&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Create or update a single rule group in a namespace. Requires &lt;a href=&#34;#x-grafana-alerting-datasource-uid&#34;&gt;&lt;code&gt;X-Grafana-Alerting-Datasource-UID&lt;/code&gt;&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/mimir/latest/references/http-api/#set-rule-group&#34;&gt;Set rule group&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The &lt;code&gt;GET&lt;/code&gt; and &lt;code&gt;DELETE&lt;/code&gt; endpoints work only with provisioned and imported alert rules. All &lt;code&gt;GET&lt;/code&gt; endpoints support both JSON and YAML response formats based on the &lt;code&gt;Accept&lt;/code&gt; header: use &lt;code&gt;application/json&lt;/code&gt; for JSON responses, or &lt;code&gt;application/yaml&lt;/code&gt; for YAML responses. YAML is the default format when no &lt;code&gt;Accept&lt;/code&gt; header is specified.&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;Endpoint&lt;/th&gt;
              &lt;th&gt;Method&lt;/th&gt;
              &lt;th&gt;Summary&lt;/th&gt;
              &lt;th&gt;Mimir equivalent&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;GET&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;/convert/prometheus/config/v1/rules&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Get all imported rule groups across all namespaces.&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/mimir/latest/references/http-api/#list-rule-groups&#34;&gt;List rule groups&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;GET&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;/convert/prometheus/config/v1/rules/:namespaceTitle&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Get imported rule groups in a specific namespace.&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/mimir/latest/references/http-api/#get-rule-groups-by-namespace&#34;&gt;Get rule groups by namespace&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;GET&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;/convert/prometheus/config/v1/rules/:namespaceTitle/:group&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Get imported rule group in a specific namespace.&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/mimir/latest/references/http-api/#get-rule-group&#34;&gt;Get rule group&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;DELETE&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;/convert/prometheus/config/v1/rules/:namespaceTitle&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Delete all imported alert rules in a namespace.&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/mimir/latest/references/http-api/#delete-namespace&#34;&gt;Delete namespace&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;DELETE&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;/convert/prometheus/config/v1/rules/:namespaceTitle/:group&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Delete a specific imported rule group.&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/mimir/latest/references/http-api/#delete-rule-group&#34;&gt;Delete rule group&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h4 id=&#34;create-or-update-multiple-rule-groups&#34;&gt;Create or update multiple rule groups&lt;/h4&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;POST /convert/prometheus/config/v1/rules&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Creates or updates multiple rule groups across multiple namespaces. This endpoint expects a request with a map of namespace titles to arrays of rule groups, and returns &lt;code&gt;202&lt;/code&gt; on success.&lt;/p&gt;
&lt;p&gt;This endpoint has no Mimir equivalent and is Grafana-specific for bulk operations.&lt;/p&gt;
&lt;h5 id=&#34;example-request-body&#34;&gt;Example request body&lt;/h5&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;YAML&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-yaml&#34;&gt;namespace1:
  - name: MyGroupName1
    rules:
      - alert: MyAlertName1
        expr: up == 0
        labels:
          severity: warning
namespace2:
  - name: MyGroupName2
    rules:
      - alert: MyAlertName2
        expr: rate(http_requests_total[5m]) &amp;gt; 0.1
        labels:
          severity: critical&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="import-data-source-managed-rules-to-grafana-managed-rules">Import data source-managed rules to Grafana-managed rules&lt;/h1>
&lt;p>You can convert existing alert rules from data sources such as Mimir, Loki, and Prometheus into Grafana-managed alert rules. This enables you to operate and manage these rules using Grafana Alerting.&lt;/p></description></item><item><title>Configure data source-managed alert rules</title><link>https://grafana.com/docs/grafana/v12.4/alerting/alerting-rules/create-data-source-managed-rule/</link><pubDate>Fri, 03 Apr 2026 12:35:46 -0500</pubDate><guid>https://grafana.com/docs/grafana/v12.4/alerting/alerting-rules/create-data-source-managed-rule/</guid><content><![CDATA[&lt;h1 id=&#34;configure-data-source-managed-alert-rules&#34;&gt;Configure data source-managed alert rules&lt;/h1&gt;
&lt;p&gt;Data source-managed alert rules are alert rules that are stored in the data source, such as in Prometheus or Loki, rather than in Grafana.&lt;/p&gt;
&lt;p&gt;In Grafana Alerting, you can:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create and edit data source-managed rules for Grafana Mimir and Grafana Loki data sources.&lt;/li&gt;
&lt;li&gt;View rules from Prometheus data sources when 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/prometheus/configure/&#34;&gt;Manage alerts via Alerting UI&lt;/a&gt; is enabled. However, you cannot create or edit these rules in Grafana.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/alerting-migration/&#34;&gt;Import data source-managed rules&lt;/a&gt; from Loki, Mimir, and Prometheus into Grafana-managed rules.&lt;/li&gt;
&lt;/ol&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;Data source-managed rules are supported for horizontal scalability, but they can introduce more operational complexity than Grafana-managed alert rules.&lt;/p&gt;
&lt;p&gt;We recommend using 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/create-grafana-managed-rule/&#34;&gt;Grafana-managed alert rules&lt;/a&gt; whenever possible, as they provide a richer feature set and better integration with the full Grafana Alerting workflow.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;comparison-with-grafana-managed-rules&#34;&gt;Comparison with Grafana-managed rules&lt;/h2&gt;
&lt;p&gt;The table below compares Grafana-managed and data source-managed alert rules.&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;&lt;div style=&#34;width:200px&#34;&gt;Feature&lt;/div&gt;&lt;/th&gt;
              &lt;th&gt;&lt;div style=&#34;width:200px&#34;&gt;Grafana-managed alert rule&lt;/div&gt;&lt;/th&gt;
              &lt;th&gt;&lt;div style=&#34;width:200px&#34;&gt;Data source-managed alert rule&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Supported data sources&lt;/td&gt;
              &lt;td&gt;All backend data sources enabling the 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/set-up/configure-rbac/&#34;&gt;&lt;code&gt;alerting&lt;/code&gt; option&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Only supports creating rules for Mimir and Loki data sources&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Mix and match data sources&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;Add 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rules/queries-conditions/#advanced-options-expressions&#34;&gt;expressions&lt;/a&gt; to transform&lt;wbr /&gt; your data and set 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rules/queries-conditions/#alert-condition&#34;&gt;alert conditions&lt;/a&gt;&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;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rule-evaluation/nodata-and-error-states/&#34;&gt;No data and error states&lt;/a&gt;&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;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rule-evaluation/stale-alert-instances/&#34;&gt;Stale alert instances&lt;/a&gt;&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;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/images-in-notifications/&#34;&gt;Images in alert notifications&lt;/a&gt;&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;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/set-up/configure-rbac/&#34;&gt;Role-based access control&lt;/a&gt;&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;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/monitor-status/view-alert-state-history/&#34;&gt;Alert state history&lt;/a&gt;&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;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/monitor-status/view-alert-rules/#view-compare-and-restore-alert-rules-versions&#34;&gt;Alert version history&lt;/a&gt;&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;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/set-up/provision-alerting-resources/terraform-provisioning/&#34;&gt;Terraform provisioning&lt;/a&gt;&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;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/create-recording-rules/&#34;&gt;Recording rules&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Organization&lt;/td&gt;
              &lt;td&gt;Organize and manage access with folders&lt;/td&gt;
              &lt;td&gt;Use namespaces&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Alert rule evaluation&lt;/td&gt;
              &lt;td&gt;Alert evaluation is done in Grafana&lt;/td&gt;
              &lt;td&gt;Alert rule evaluation is done in the data source and allow for horizontal scaling&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Scaling&lt;/td&gt;
              &lt;td&gt;Alert rules are stored in the Grafana database.&lt;/td&gt;
              &lt;td&gt;Alert rules are stored within the data source and allow for horizontal scaling&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The following diagram shows the architecture of a Mimir setup that uses data source-managed alert rules.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 750px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/media/docs/alerting/mimir-managed-alerting-architecture-v2.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/media/docs/alerting/mimir-managed-alerting-architecture-v2.png&#34;data-srcset=&#34;/media/docs/alerting/mimir-managed-alerting-architecture-v2.png?w=320 320w, /media/docs/alerting/mimir-managed-alerting-architecture-v2.png?w=550 550w, /media/docs/alerting/mimir-managed-alerting-architecture-v2.png?w=750 750w, /media/docs/alerting/mimir-managed-alerting-architecture-v2.png?w=900 900w, /media/docs/alerting/mimir-managed-alerting-architecture-v2.png?w=1040 1040w, /media/docs/alerting/mimir-managed-alerting-architecture-v2.png?w=1240 1240w, /media/docs/alerting/mimir-managed-alerting-architecture-v2.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Data source-managed alerting architecture based on Grafana Mimir&#34;width=&#34;1866&#34;height=&#34;816&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/alerting/mimir-managed-alerting-architecture-v2.png&#34;
            alt=&#34;Data source-managed alerting architecture based on Grafana Mimir&#34;width=&#34;1866&#34;height=&#34;816&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h2 id=&#34;create-data-source-managed-alert-rules&#34;&gt;Create data source-managed alert rules&lt;/h2&gt;
&lt;p&gt;To create or edit data source-managed alert rules, follow these instructions.&lt;/p&gt;
&lt;h3 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h3&gt;
&lt;p&gt;Verify that you have write permission to the Mimir or Loki data source. Otherwise, you cannot create or update data source-managed alert rules.&lt;/p&gt;
&lt;h4 id=&#34;enable-the-ruler-api&#34;&gt;Enable the Ruler API&lt;/h4&gt;
&lt;p&gt;For more information, refer to the &lt;a href=&#34;/docs/mimir/latest/references/http-api/#ruler&#34;&gt;Mimir Ruler API&lt;/a&gt; or &lt;a href=&#34;/docs/loki/latest/api/#ruler&#34;&gt;Loki Ruler API&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Mimir&lt;/strong&gt; - use the &lt;code&gt;/prometheus&lt;/code&gt; prefix. The Prometheus data source supports both Grafana Mimir and Prometheus, and Grafana expects that both the &lt;a href=&#34;/docs/mimir/latest/operators-guide/reference-http-api/#querier--query-frontend&#34;&gt;Query API&lt;/a&gt; and &lt;a href=&#34;/docs/mimir/latest/operators-guide/reference-http-api/#ruler&#34;&gt;Ruler API&lt;/a&gt; are under the same URL. You cannot provide a separate URL for the Ruler API.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Loki&lt;/strong&gt; - The &lt;code&gt;local&lt;/code&gt; rule storage type, default for the Loki data source, supports only viewing of rules. To edit rules, configure one of the other rule storage types.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;permissions&#34;&gt;Permissions&lt;/h4&gt;
&lt;p&gt;Alert rules for Mimir or Loki instances can be edited or deleted by users with &lt;strong&gt;Editor&lt;/strong&gt; or &lt;strong&gt;Admin&lt;/strong&gt; roles.&lt;/p&gt;
&lt;p&gt;If you do not want to manage alert rules for a particular data source, go to its settings and clear the &lt;strong&gt;Manage alerts via Alerting UI&lt;/strong&gt; checkbox.&lt;/p&gt;
&lt;h4 id=&#34;provisioning&#34;&gt;Provisioning&lt;/h4&gt;
&lt;p&gt;Note that if you delete an alert resource created in the UI, you can no longer retrieve it.&lt;/p&gt;
&lt;p&gt;To backup and manage alert rules, you can 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/set-up/provision-alerting-resources/&#34;&gt;provision alerting resources&lt;/a&gt; using options such as configuration files, Terraform, or the Alerting API.&lt;/p&gt;
&lt;h3 id=&#34;set-alert-rule-name&#34;&gt;Set alert rule name&lt;/h3&gt;


&lt;div data-shared=&#34;alerts/configure-alert-rule-name.md&#34;&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;Alert rules&lt;/strong&gt; -&amp;gt; &lt;strong&gt;&#43; New alert rule&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter a name to identify your alert rule.&lt;/p&gt;
&lt;p&gt;This name is displayed in the alert rule list. It is also the &lt;code&gt;alertname&lt;/code&gt; label for every alert instance that is created from this rule.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;

        
&lt;h3 id=&#34;define-query-and-condition&#34;&gt;Define query and condition&lt;/h3&gt;
&lt;p&gt;Define a query to get the data you want to measure and a condition that needs to be met before an alert rule fires.&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;By default, new alert rules are Grafana-managed. To switch to &lt;strong&gt;Data source-managed&lt;/strong&gt;, follow these instructions.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Select a Prometheus-based data source from the drop-down list.&lt;/p&gt;
&lt;p&gt;You can also click &lt;strong&gt;Open advanced data source picker&lt;/strong&gt; to find more options.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter a PromQL or LogQL query, including the alert condition.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Rule type&lt;/strong&gt; option, select &lt;strong&gt;Data source-managed&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Preview alerts&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;set-alert-evaluation-behavior&#34;&gt;Set alert evaluation behavior&lt;/h3&gt;
&lt;p&gt;Use 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rule-evaluation/&#34;&gt;alert rule evaluation&lt;/a&gt; to determine how frequently an alert rule should be evaluated and how quickly it should change its state.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Select a namespace or click &lt;strong&gt;&#43; New namespace&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select an evaluation group or click &lt;strong&gt;&#43; New evaluation group&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If you are creating a new evaluation group, specify the interval for the group.&lt;/p&gt;
&lt;p&gt;All rules within the same group are evaluated sequentially over the same time interval. You can reorder them from the &lt;strong&gt;Alert rules&lt;/strong&gt; page.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter a pending period.&lt;/p&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rule-evaluation/#pending-period&#34;&gt;pending period&lt;/a&gt; is the period in which an alert rule can be in breach of the condition until it fires.&lt;/p&gt;
&lt;p&gt;Once a condition is met, the alert goes into the &lt;strong&gt;Pending&lt;/strong&gt; state. If the condition remains active for the duration specified, the alert transitions to the &lt;strong&gt;Firing&lt;/strong&gt; state, else it reverts to the &lt;strong&gt;Normal&lt;/strong&gt; state.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-labels-and-notifications&#34;&gt;Configure labels and notifications&lt;/h3&gt;
&lt;p&gt;Add 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rules/annotation-label/#labels&#34;&gt;labels&lt;/a&gt; to your alert rules to set which 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/notifications/notification-policies/&#34;&gt;notification policy&lt;/a&gt; should handle your firing alert instances.&lt;/p&gt;
&lt;p&gt;All alert rules and instances, irrespective of their labels, match the default notification policy. If there are no nested policies, or no nested policies match the labels in the alert rule or alert instance, then the default notification policy is the matching policy.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Add labels if you want to change the way your notifications are routed.&lt;/p&gt;
&lt;p&gt;Add custom labels by selecting existing key-value pairs from the drop down, or add new labels by entering the new key or value.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-notification-message&#34;&gt;Configure notification message&lt;/h3&gt;
&lt;p&gt;Use 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rules/annotation-label/#annotations&#34;&gt;annotations&lt;/a&gt; to add information to alert messages that can help respond to the alert.&lt;/p&gt;
&lt;p&gt;Annotations are included by default in notification messages, and can use text or 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/templates/&#34;&gt;templates&lt;/a&gt; to display dynamic data from queries.&lt;/p&gt;
&lt;p&gt;Grafana provides several optional annotations.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Optional: Add a summary.&lt;/p&gt;
&lt;p&gt;Short summary of what happened and why.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: Add a description.&lt;/p&gt;
&lt;p&gt;Description of what the alert rule does.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: Add a Runbook URL.&lt;/p&gt;
&lt;p&gt;Webpage where you keep your runbook for the alert&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: Add a custom annotation.&lt;/p&gt;
&lt;p&gt;Add any additional information that could help address the alert.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: &lt;strong&gt;Link dashboard and panel&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;
    &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; to facilitate alert investigation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save rule&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="configure-data-source-managed-alert-rules">Configure data source-managed alert rules&lt;/h1>
&lt;p>Data source-managed alert rules are alert rules that are stored in the data source, such as in Prometheus or Loki, rather than in Grafana.&lt;/p></description></item><item><title>Create recording rules</title><link>https://grafana.com/docs/grafana/v12.4/alerting/alerting-rules/create-recording-rules/</link><pubDate>Fri, 03 Apr 2026 12:35:46 -0500</pubDate><guid>https://grafana.com/docs/grafana/v12.4/alerting/alerting-rules/create-recording-rules/</guid><content><![CDATA[&lt;h1 id=&#34;configure-recording-rules&#34;&gt;Configure recording rules&lt;/h1&gt;
&lt;p&gt;Recording rules allows you to periodically pre-compute frequently used or computationally expensive queries, saving the results as a new time series metric.&lt;/p&gt;
&lt;p&gt;For instance, you can create a recording rule generating a new metric, &lt;code&gt;error_9001_count&lt;/code&gt;, which counts occurrences of a specific log error within one minute. Then, query the &lt;code&gt;error_9001_count&lt;/code&gt; metric in dashboards and alert rules.&lt;/p&gt;
&lt;p&gt;Recording rules can be helpful in various scenarios, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Faster queries&lt;/strong&gt; are needed: Performing heavy aggregations or querying large data sets is quicker with precomputed results than real-time queries.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reducing system load:&lt;/strong&gt; Precomputing specific queries in advance can reduce system overload caused by multiple simultaneous queries.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Simplifying complex aggregations:&lt;/strong&gt; Create a new metric from complex aggregations to facilitate alert and dashboard setup.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reusing queries across alerts:&lt;/strong&gt; Improve efficiency by reusing the same query across similar alert rules and dashboards.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The evaluation group of the recording rule determines how often the metric is pre-computed.&lt;/p&gt;
&lt;h2 id=&#34;recommendations&#34;&gt;Recommendations&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use frequent evaluation intervals&lt;/strong&gt;. Set frequent evaluation intervals for recording rules. Long intervals, such as an hour, can cause the recorded metric to be stale and lead to misaligned alert rule evaluations, especially when combined with a long pending period.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Align alert evaluation with recording frequency&lt;/strong&gt;. The evaluation interval of an alert rule that depends on a recorded metric should be aligned with the recording rule&amp;rsquo;s interval. If a recording rule runs every 3 minutes, the alert rule should also be evaluated at a similar frequency to ensure it acts on fresh data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use &lt;code&gt;_over_time&lt;/code&gt; functions for instant queries&lt;/strong&gt;. Since all alert rules are ultimately executed as an instant query, you can use functions like &lt;code&gt;max_over_time(my_metric[5m])&lt;/code&gt; as an instant query. This allows you to get an aggregated value over a period without using a range query and a reduce expression.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;types-of-recording-rules&#34;&gt;Types of recording rules&lt;/h2&gt;
&lt;p&gt;Similar to alert rules, Grafana supports two types of recording rules:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/create-recording-rules/create-grafana-managed-recording-rules/&#34;&gt;Grafana-managed recording rules&lt;/a&gt;, which can query any Grafana data source supported by alerting. It&amp;rsquo;s the recommended option.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/create-recording-rules/create-data-source-managed-recording-rules/&#34;&gt;Data source-managed recording rules&lt;/a&gt;, which can query Prometheus-based data sources like Mimir or Loki.&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="configure-recording-rules">Configure recording rules&lt;/h1>
&lt;p>Recording rules allows you to periodically pre-compute frequently used or computationally expensive queries, saving the results as a new time series metric.&lt;/p></description></item><item><title>Template annotations and labels</title><link>https://grafana.com/docs/grafana/v12.4/alerting/alerting-rules/templates/</link><pubDate>Fri, 03 Apr 2026 12:35:46 -0500</pubDate><guid>https://grafana.com/docs/grafana/v12.4/alerting/alerting-rules/templates/</guid><content><![CDATA[&lt;h1 id=&#34;template-annotations-and-labels&#34;&gt;Template annotations and labels&lt;/h1&gt;
&lt;p&gt;You can use templates to customize alert and notification messages, including dynamic data from alert rule queries.&lt;/p&gt;
&lt;p&gt;In Grafana Alerting, you can template alert messages in two ways.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Template annotations and labels&lt;/strong&gt;: In the alert rule definition, you can template annotations and labels to include extra information from query data to the alert, adding meaningful details based on the query results.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Template notifications&lt;/strong&gt;: You can template notifications to control the content and appearance of your notifications.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;how-templating-works&#34;&gt;How templating works&lt;/h2&gt;
&lt;p&gt;In this diagram, you can see the differences between both types of templates.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 1200px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/media/docs/alerting/how-notification-templates-works.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/media/docs/alerting/how-notification-templates-works.png&#34;data-srcset=&#34;/media/docs/alerting/how-notification-templates-works.png?w=320 320w, /media/docs/alerting/how-notification-templates-works.png?w=550 550w, /media/docs/alerting/how-notification-templates-works.png?w=750 750w, /media/docs/alerting/how-notification-templates-works.png?w=900 900w, /media/docs/alerting/how-notification-templates-works.png?w=1040 1040w, /media/docs/alerting/how-notification-templates-works.png?w=1240 1240w, /media/docs/alerting/how-notification-templates-works.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;How templating works&#34;width=&#34;1072&#34;height=&#34;699&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/alerting/how-notification-templates-works.png&#34;
            alt=&#34;How templating works&#34;width=&#34;1072&#34;height=&#34;699&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/templates/&#34;&gt;Templates Introduction&lt;/a&gt; for a more detailed explanation of this diagram.&lt;/p&gt;
&lt;p&gt;Both types of templates are written in the Go templating system. However, it&amp;rsquo;s important to understand that variables and functions used in notification templates are different from those used in annotation and label templates.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Template annotations and labels&lt;/strong&gt;: These templates add extra information to individual alert instances. Template variables like 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/templates/reference/#labels&#34;&gt;&lt;code&gt;$labels&lt;/code&gt;&lt;/a&gt; and 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/templates/reference/#values&#34;&gt;&lt;code&gt;$values&lt;/code&gt;&lt;/a&gt; represent alert query data of the individual alert instance.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Template notifications&lt;/strong&gt;: Notification templates format the notification content for a group of alerts. Variables like 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/reference/#notification-data&#34;&gt;&lt;code&gt;.Alerts&lt;/code&gt;&lt;/a&gt; include all firing and resolved alerts in the notification.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;template-annotations&#34;&gt;Template annotations&lt;/h2&gt;
&lt;p&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/alert-rules/annotation-label/#annotations&#34;&gt;Annotations&lt;/a&gt; add additional information to alert instances and are often used to help identify the alert and guide responders on how to address the issue.&lt;/p&gt;
&lt;p&gt;Annotations are key-value pairs defined in the alert rule. They can contain plain text or template code that is evaluated when the alert fires.&lt;/p&gt;
&lt;p&gt;Grafana includes several optional annotations, such as &lt;code&gt;description&lt;/code&gt;, &lt;code&gt;summary&lt;/code&gt;, and &lt;code&gt;runbook_url&lt;/code&gt;, which can be edited in the alert rule. You can also create your custom annotations. For example, you might create a new annotation named &lt;code&gt;location&lt;/code&gt; to report the location of the system that triggered the alert.&lt;/p&gt;
&lt;p&gt;Here’s an example of a &lt;code&gt;summary&lt;/code&gt; annotation explaining why the alert was triggered, using plain 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;CPU usage has exceeded 80% for the last 5 minutes.&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;However, if you want to display dynamic query values in annotations, you need to use template code. Common use cases include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Displaying the query value that triggered the alert.&lt;/li&gt;
&lt;li&gt;Highlighting label information that identifies the alert, such as the environment, instance, or region.&lt;/li&gt;
&lt;li&gt;Providing specific instructions based on query values.&lt;/li&gt;
&lt;li&gt;Customizing runbook links depending on query labels.&lt;/li&gt;
&lt;li&gt;Including contact information based on query labels.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For instance, you can template the previous example to display the specific instance and CPU value that triggered the alert.&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;CPU usage for {{ $labels.instance }} has exceeded 80% ({{ $values.A.Value }}) for the last 5 minutes.&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Alternatively, you can use the &lt;code&gt;index&lt;/code&gt; function to print query values.&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;CPU usage for {{ index $labels &amp;#34;instance&amp;#34; }} has exceeded 80% ({{ index $values &amp;#34;A&amp;#34; }}) for the last 5 minutes.&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The result of the annotation would be as follows.&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;CPU usage for Instance 1 has exceeded 80% (81.2345) for the last 5 minutes.&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;how-to-template-an-annotation&#34;&gt;How to template an annotation&lt;/h3&gt;
&lt;p&gt;Complete the following steps to template an annotation.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to &lt;strong&gt;Alerts &amp;amp; IRM&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Alert rules&lt;/strong&gt; -&amp;gt; create or edit an alert rule.&lt;/li&gt;
&lt;li&gt;Scroll down to the &lt;strong&gt;Configure notification message&lt;/strong&gt; section.&lt;/li&gt;
&lt;li&gt;Copy in your template in the corresponding annotation field (&lt;code&gt;summary&lt;/code&gt;, &lt;code&gt;description&lt;/code&gt;, &lt;code&gt;runbook_url&lt;/code&gt;, &lt;code&gt;custom&lt;/code&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;preview-annotation-templates&#34;&gt;Preview annotation templates&lt;/h3&gt;
&lt;p&gt;You can template annotations when creating or editing an alert rule.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 1200px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/media/docs/alerting/alert-rule-using-annotation-template.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/media/docs/alerting/alert-rule-using-annotation-template.png&#34;data-srcset=&#34;/media/docs/alerting/alert-rule-using-annotation-template.png?w=320 320w, /media/docs/alerting/alert-rule-using-annotation-template.png?w=550 550w, /media/docs/alerting/alert-rule-using-annotation-template.png?w=750 750w, /media/docs/alerting/alert-rule-using-annotation-template.png?w=900 900w, /media/docs/alerting/alert-rule-using-annotation-template.png?w=1040 1040w, /media/docs/alerting/alert-rule-using-annotation-template.png?w=1240 1240w, /media/docs/alerting/alert-rule-using-annotation-template.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;An alert rule templating the annotation summary&#34;width=&#34;900&#34;height=&#34;498&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/alerting/alert-rule-using-annotation-template.png&#34;
            alt=&#34;An alert rule templating the annotation summary&#34;width=&#34;900&#34;height=&#34;498&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Two common methods are used to test and preview annotation templates:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Trigger the alert and 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/monitor-status/view-alert-state/&#34;&gt;view the alert instance state in the Grafana UI&lt;/a&gt;, where all annotations of the alert instance are displayed.&lt;/li&gt;
&lt;li&gt;Use a notification template that displays all annotations, then 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/configure-notifications/template-notifications/manage-notification-templates/#preview-notification-templates&#34;&gt;preview the notification template&lt;/a&gt; using the alert instance.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;template-labels&#34;&gt;Template labels&lt;/h2&gt;
&lt;p&gt;The set of 
    &lt;a href=&#34;/docs/grafana/v12.4/latest/alerting/fundamentals/alert-rules/annotation-label/&#34;&gt;labels&lt;/a&gt; for an alert instance is used to uniquely identify that alert among all other alert instances.&lt;/p&gt;
&lt;p&gt;Labels determine how alerts are routed and managed for notifications, making their design key to the effectiveness of your alerting system.&lt;/p&gt;
&lt;p&gt;Labels can be returned from an alert rule query, such as the &lt;code&gt;pod&lt;/code&gt; label in a Kubernetes Prometheus query. You can also define additional labels in the alert rule to provide extra information for processing alerts.&lt;/p&gt;
&lt;p&gt;Like annotations, labels are key-value pairs that can contain plain text or template code evaluated when the alert fires.&lt;/p&gt;
&lt;p&gt;Template labels when the labels returned by your queries are insufficient. For instance:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A new label based on a query value can group a subset of alerts differently, changing how notifications are sent.&lt;/li&gt;
&lt;li&gt;A new label based on a query value can be used in a notification policy to alter the notification contact point.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here’s an example of templating a &lt;code&gt;severity&lt;/code&gt; label based on the query value.&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 (gt $values.A.Value 90.0) -}}
critical
{{ else if (gt $values.A.Value 80.0) -}}
high
{{ else if (gt $values.A.Value 60.0) -}}
medium
{{ else -}}
low
{{- end }}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this example, the value of the &lt;code&gt;severity&lt;/code&gt; label is determined by the query value, and the possible options are &lt;code&gt;critical&lt;/code&gt;, &lt;code&gt;high&lt;/code&gt;, &lt;code&gt;medium&lt;/code&gt;, or &lt;code&gt;low&lt;/code&gt;. You can then use the &lt;code&gt;severity&lt;/code&gt; label to change their notifications—for instance, sending &lt;code&gt;critical&lt;/code&gt; alerts immediately or routing &lt;code&gt;low&lt;/code&gt; alerts to a specific team for further review.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; An alert instance is uniquely identified by its set of labels.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Avoid displaying query values in labels, as this can create numerous alert instances—one for each distinct label set. Instead, use annotations for query values.&lt;/li&gt;
&lt;li&gt;If a templated label&amp;rsquo;s value changes, it maps to a different alert instance, and the previous instance is considered &lt;strong&gt;stale&lt;/strong&gt;. Learn all the details in this 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/best-practices/dynamic-labels/&#34;&gt;example using dynamic labels&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/blockquote&gt;
&lt;h3 id=&#34;how-to-template-a-label&#34;&gt;How to template a label&lt;/h3&gt;
&lt;p&gt;Complete the following steps to template a label.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to &lt;strong&gt;Alerts &amp;amp; IRM&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Alert rules&lt;/strong&gt; -&amp;gt; create or edit an alert rule.&lt;/li&gt;
&lt;li&gt;Scroll down to the &lt;strong&gt;Configure labels and notifications&lt;/strong&gt; section.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;&#43; Add labels&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;strong&gt;key&lt;/strong&gt; that identifies the label.&lt;/li&gt;
&lt;li&gt;Copy in your template in the &lt;strong&gt;value&lt;/strong&gt; field.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;preview-label-templates&#34;&gt;Preview label templates&lt;/h3&gt;
&lt;p&gt;You can template label values when creating or editing an alert rule.&lt;/p&gt;
&lt;p&gt;To preview label values, select &lt;code&gt;Use notification policy&lt;/code&gt;, and then click on &lt;code&gt;Preview routing&lt;/code&gt;.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 1200px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/media/docs/alerting/alert-instance-routing-preview.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/media/docs/alerting/alert-instance-routing-preview.png&#34;data-srcset=&#34;/media/docs/alerting/alert-instance-routing-preview.png?w=320 320w, /media/docs/alerting/alert-instance-routing-preview.png?w=550 550w, /media/docs/alerting/alert-instance-routing-preview.png?w=750 750w, /media/docs/alerting/alert-instance-routing-preview.png?w=900 900w, /media/docs/alerting/alert-instance-routing-preview.png?w=1040 1040w, /media/docs/alerting/alert-instance-routing-preview.png?w=1240 1240w, /media/docs/alerting/alert-instance-routing-preview.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Routing preview displays label values&#34;width=&#34;2614&#34;height=&#34;1040&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/alerting/alert-instance-routing-preview.png&#34;
            alt=&#34;Routing preview displays label values&#34;width=&#34;2614&#34;height=&#34;1040&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h2 id=&#34;more-information&#34;&gt;More information&lt;/h2&gt;
&lt;p&gt;For further details on how to template alert rules, 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/alerting-rules/templates/examples/&#34;&gt;Annotation and label examples&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;div class=&#34;admonition admonition-tip&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Tip&lt;/p&gt;&lt;p&gt;For a practical example of templating, refer to our &lt;a href=&#34;/tutorials/alerting-get-started-pt4/&#34;&gt;Getting Started with Templating tutorial&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

]]></content><description>&lt;h1 id="template-annotations-and-labels">Template annotations and labels&lt;/h1>
&lt;p>You can use templates to customize alert and notification messages, including dynamic data from alert rule queries.&lt;/p>
&lt;p>In Grafana Alerting, you can template alert messages in two ways.&lt;/p></description></item></channel></rss>