<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Alert rules on Grafana Labs</title><link>https://grafana.com/docs/grafana/v11.4/alerting/fundamentals/alert-rules/</link><description>Recent content in Alert rules on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/grafana/v11.4/alerting/fundamentals/alert-rules/index.xml" rel="self" type="application/rss+xml"/><item><title>Queries and conditions</title><link>https://grafana.com/docs/grafana/v11.4/alerting/fundamentals/alert-rules/queries-conditions/</link><pubDate>Sun, 08 Mar 2026 02:10:29 +0000</pubDate><guid>https://grafana.com/docs/grafana/v11.4/alerting/fundamentals/alert-rules/queries-conditions/</guid><content><![CDATA[&lt;h1 id=&#34;queries-and-conditions&#34;&gt;Queries and conditions&lt;/h1&gt;
&lt;p&gt;In Grafana, queries fetch and transform data from 
    &lt;a href=&#34;/docs/grafana/v11.4/datasources/&#34;&gt;data sources,&lt;/a&gt; which include databases like MySQL or PostgreSQL, time series databases like Prometheus or InfluxDB, and services like Amazon CloudWatch or Azure Monitor.&lt;/p&gt;
&lt;p&gt;A query specifies the data to extract from a data source, with the syntax varying based on the type of data source used.&lt;/p&gt;
&lt;p&gt;In Alerting, an alert rule defines of one or more queries and expressions that select the data you want to measure and a &lt;a href=&#34;#alert-condition&#34;&gt;condition&lt;/a&gt; that needs to be met before an alert rule fires.&lt;/p&gt;
&lt;h2 id=&#34;data-source-queries&#34;&gt;Data source queries&lt;/h2&gt;
&lt;p&gt;Alerting queries are the same type of queries available in Grafana panels. Queries in Grafana can be applied in various ways, depending on the data source and query language being used. However, not all 
    &lt;a href=&#34;/docs/grafana/v11.4/alerting/fundamentals/alert-rules/#supported-data-sources&#34;&gt;data sources support Alerting&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Each data source’s query editor provides a customized user interface to help you write queries that take advantage of its unique capabilities. For additional information about queries in Grafana, refer to 
    &lt;a href=&#34;/docs/grafana/v11.4/panels-visualizations/query-transform-data/&#34;&gt;Query and transform data&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Some common types of query components include:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Metrics or data fields&lt;/strong&gt;: Specify the specific metrics or data fields you want to retrieve, such as CPU usage, network traffic, or sensor readings.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Time range&lt;/strong&gt;: Define the time range for which you want to fetch data, such as the last hour, a specific day, or a custom time range.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Filters&lt;/strong&gt;: Apply filters to narrow down the data based on specific criteria, such as filtering data by a specific tag, host, or application.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Aggregations&lt;/strong&gt;: Perform aggregations on the data to calculate metrics like averages, sums, or counts over a given time period.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Grouping&lt;/strong&gt;: Group the data by specific dimensions or tags to create aggregated views or breakdowns.&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;Grafana doesn&amp;rsquo;t support alert queries with template variables. More details &lt;a href=&#34;https://community.grafana.com/t/template-variables-are-not-supported-in-alert-queries-while-setting-up-alert/2514&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;expression-queries&#34;&gt;Expression queries&lt;/h2&gt;
&lt;p&gt;In Grafana, an expression is used to perform calculations, transformations, or aggregations on the data source queried data. It allows you to create custom metrics or modify existing metrics based on mathematical operations, functions, or logical expressions.&lt;/p&gt;
&lt;p&gt;By leveraging expression queries, users can perform tasks such as calculating the percentage change between two values, applying functions like logarithmic or trigonometric functions, aggregating data over specific time ranges or dimensions, and implementing conditional logic to handle different scenarios.&lt;/p&gt;
&lt;p&gt;In Alerting, you can only use expressions for Grafana-managed alert rules. For each expression, you can choose from the math, reduce, and resample expressions. These are called multi-dimensional rules, because they generate an alert instance for each series.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reduce&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Aggregates time series values in the selected time range into a single value. It&amp;rsquo;s not necessary for &lt;a href=&#34;#alert-on-numeric-data&#34;&gt;rules using numeric data&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Math&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Performs free-form math functions/operations on time series and number data. Can be used to preprocess time series data or to define an alert condition for number data. For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;$B &amp;gt; 70&lt;/code&gt; should fire if the value of B (query or expression) is more than 70.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$B &amp;lt; $C * 100&lt;/code&gt; should fire if the value of B is less than the value of C multiplied by 100.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If queries being compared have multiple series in their results, series from different queries are matched if they have the same labels or one is a subset of the other.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Resample&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Realigns a time range to a new set of timestamps, this is useful when comparing time series data from different data sources where the timestamps would otherwise not align.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Threshold&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Checks if any time series data matches the threshold condition.&lt;/p&gt;
&lt;p&gt;The threshold expression allows you to compare two single values. It returns &lt;code&gt;0&lt;/code&gt; when the condition is false and &lt;code&gt;1&lt;/code&gt; if the condition is true. The following threshold functions are available:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is above (x &amp;gt; y)&lt;/li&gt;
&lt;li&gt;Is below (x &amp;lt; y)&lt;/li&gt;
&lt;li&gt;Is within range (x &amp;gt; y1 AND x &amp;lt; y2)&lt;/li&gt;
&lt;li&gt;Is outside range (x &amp;lt; y1 AND x &amp;gt; y2)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Classic condition (legacy)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Classic conditions exist mainly for compatibility reasons and should be avoided if possible.&lt;/p&gt;
&lt;p&gt;Classic condition checks if any time series data matches the alert condition. It always produce one alert instance only, no matter how many time series meet the condition.&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;Condition operators&lt;/th&gt;
              &lt;th&gt;How it works&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;and&lt;/td&gt;
              &lt;td&gt;Two conditions before and after must be true for the overall condition to be true.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;or&lt;/td&gt;
              &lt;td&gt;If one of conditions before and after are true, the overall condition is true.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;logic-or&lt;/td&gt;
              &lt;td&gt;If the condition before &lt;code&gt;logic-or&lt;/code&gt; is true, the overall condition is immediately true, without evaluating subsequent conditions. For instance, &lt;code&gt;TRUE and TRUE logic-or FALSE and FALSE&lt;/code&gt; evaluate to &lt;code&gt;TRUE&lt;/code&gt;, because the preceding condition returns &lt;code&gt;TRUE&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;aggregations&#34;&gt;Aggregations&lt;/h2&gt;
&lt;p&gt;Grafana Alerting provides the following aggregation functions to enable you to further refine your query.&lt;/p&gt;
&lt;p&gt;These functions are available for &lt;strong&gt;Reduce&lt;/strong&gt; and &lt;strong&gt;Classic condition&lt;/strong&gt; expressions only.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Function&lt;/th&gt;
              &lt;th&gt;Expression&lt;/th&gt;
              &lt;th&gt;What it does&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;avg&lt;/td&gt;
              &lt;td&gt;Reduce / Classic&lt;/td&gt;
              &lt;td&gt;Displays the average of the values&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;min&lt;/td&gt;
              &lt;td&gt;Reduce / Classic&lt;/td&gt;
              &lt;td&gt;Displays the lowest value&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;max&lt;/td&gt;
              &lt;td&gt;Reduce / Classic&lt;/td&gt;
              &lt;td&gt;Displays the highest value&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;sum&lt;/td&gt;
              &lt;td&gt;Reduce / Classic&lt;/td&gt;
              &lt;td&gt;Displays the sum of all values&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;count&lt;/td&gt;
              &lt;td&gt;Reduce / Classic&lt;/td&gt;
              &lt;td&gt;Counts the number of values in the result&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;last&lt;/td&gt;
              &lt;td&gt;Reduce / Classic&lt;/td&gt;
              &lt;td&gt;Displays the last value&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;median&lt;/td&gt;
              &lt;td&gt;Reduce / Classic&lt;/td&gt;
              &lt;td&gt;Displays the median value&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;diff&lt;/td&gt;
              &lt;td&gt;Classic&lt;/td&gt;
              &lt;td&gt;Displays the difference between the newest and oldest value&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;diff_abs&lt;/td&gt;
              &lt;td&gt;Classic&lt;/td&gt;
              &lt;td&gt;Displays the absolute value of diff&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;percent_diff&lt;/td&gt;
              &lt;td&gt;Classic&lt;/td&gt;
              &lt;td&gt;Displays the percentage value of the difference between newest and oldest value&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;percent_diff_abs&lt;/td&gt;
              &lt;td&gt;Classic&lt;/td&gt;
              &lt;td&gt;Displays the absolute value of percent_diff&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;count_non_null&lt;/td&gt;
              &lt;td&gt;Classic&lt;/td&gt;
              &lt;td&gt;Displays a count of values in the result set that aren&amp;rsquo;t &lt;code&gt;null&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;alert-condition&#34;&gt;Alert condition&lt;/h2&gt;
&lt;p&gt;An alert condition is the query or expression that determines whether the alert fires or not depending on the value it yields. There can be only one condition which determines the triggering of the alert.&lt;/p&gt;
&lt;p&gt;After you have defined your queries and expressions, choose one of them as the alert rule condition. By default, the last expression added is used as the alert condition.&lt;/p&gt;
&lt;p&gt;When the queried data satisfies the defined condition, Grafana triggers the associated alert, which can be configured to send notifications through various channels like email, Slack, or PagerDuty.&lt;/p&gt;
&lt;p&gt;For details about how the alert evaluation triggers notifications, refer to 
    &lt;a href=&#34;/docs/grafana/v11.4/alerting/fundamentals/alert-rule-evaluation/&#34;&gt;Alert rule evaluation&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;recovery-threshold&#34;&gt;Recovery threshold&lt;/h2&gt;
&lt;p&gt;To reduce the noise of flapping alerts, you can set a recovery threshold different to the alert threshold.&lt;/p&gt;
&lt;p&gt;Flapping alerts occur when a metric hovers around the alert threshold condition and may lead to frequent state changes, resulting in too many notifications being generated.&lt;/p&gt;
&lt;p&gt;It can be tricky to create an alert rule for a noisy metric. That is, when the value of a metric continually goes above and below a threshold. This is called flapping and results in a series of firing - resolved - firing notifications and a noisy alert state history.&lt;/p&gt;
&lt;p&gt;For example, if you have an alert for latency with a threshold of 1000ms and the number fluctuates around 1000 (say 980 -&amp;gt;1010 -&amp;gt; 990 -&amp;gt; 1020, and so on) then each of those triggers a notification.&lt;/p&gt;
&lt;p&gt;To solve this problem, you can set a (custom) recovery threshold, which basically means having two thresholds instead of one:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;An alert is triggered when the first threshold is crossed.&lt;/li&gt;
&lt;li&gt;An alert is resolved only when the second threshold is crossed.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For example, you could set a threshold of 1000ms and a recovery threshold of 900ms. This way, an alert rule only stops firing when it goes under 900ms and flapping is reduced.&lt;/p&gt;
&lt;p&gt;For details about how the alert evaluation triggers notifications, refer to 
    &lt;a href=&#34;/docs/grafana/v11.4/alerting/fundamentals/alert-rule-evaluation/&#34;&gt;Alert rule evaluation&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;alert-on-numeric-data&#34;&gt;Alert on numeric data&lt;/h2&gt;
&lt;p&gt;Among certain data sources numeric data that is not time series can be directly alerted on, or passed into Server Side Expressions (SSE). This allows for more processing and resulting efficiency within the data source, and it can also simplify alert rules.
When alerting on numeric data instead of time series data, there is no need to reduce each labeled time series into a single number. Instead labeled numbers are returned to Grafana instead.&lt;/p&gt;
&lt;h3 id=&#34;tabular-data&#34;&gt;Tabular Data&lt;/h3&gt;
&lt;p&gt;This feature is supported with backend data sources that query tabular data:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SQL data sources such as MySQL, Postgres, MSSQL, and Oracle.&lt;/li&gt;
&lt;li&gt;The Azure Kusto based services: Azure Monitor (Logs), Azure Monitor (Azure Resource Graph), and Azure Data Explorer.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A query with Grafana managed alerts or SSE is considered numeric with these data sources, if:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &amp;ldquo;Format AS&amp;rdquo; option is set to &amp;ldquo;Table&amp;rdquo; in the data source query.&lt;/li&gt;
&lt;li&gt;The table response returned to Grafana from the query includes only one numeric (e.g. int, double, float) column, and optionally additional string columns.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If there are string columns then those columns become labels. The name of column becomes the label name, and the value for each row becomes the value of the corresponding label. If multiple rows are returned, then each row should be uniquely identified their labels.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For a MySQL table called &amp;ldquo;DiskSpace&amp;rdquo;:&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;Time&lt;/th&gt;
              &lt;th&gt;Host&lt;/th&gt;
              &lt;th&gt;Disk&lt;/th&gt;
              &lt;th&gt;PercentFree&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;2021-June-7&lt;/td&gt;
              &lt;td&gt;web1&lt;/td&gt;
              &lt;td&gt;/etc&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;2021-June-7&lt;/td&gt;
              &lt;td&gt;web2&lt;/td&gt;
              &lt;td&gt;/var&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;2021-June-7&lt;/td&gt;
              &lt;td&gt;web3&lt;/td&gt;
              &lt;td&gt;/var&lt;/td&gt;
              &lt;td&gt;8&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;You can query the data filtering on time, but without returning the time series to Grafana. For example, an alert that would trigger per Host, Disk when there is less than 5% free space:&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;SQL&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-sql&#34;&gt;SELECT Host, Disk, CASE WHEN PercentFree &amp;lt; 5.0 THEN PercentFree ELSE 0 END FROM (
  SELECT
      Host,
      Disk,
      Avg(PercentFree)
  FROM DiskSpace
  Group By
    Host,
    Disk
  Where __timeFilter(Time)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This query returns the following Table response to Grafana:&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;Host&lt;/th&gt;
              &lt;th&gt;Disk&lt;/th&gt;
              &lt;th&gt;PercentFree&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;web1&lt;/td&gt;
              &lt;td&gt;/etc&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;web2&lt;/td&gt;
              &lt;td&gt;/var&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;web3&lt;/td&gt;
              &lt;td&gt;/var&lt;/td&gt;
              &lt;td&gt;0&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;When this query is used as the &lt;strong&gt;condition&lt;/strong&gt; in an alert rule, then the non-zero is alerting. As a result, three alert instances are produced:&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;Labels&lt;/th&gt;
              &lt;th&gt;Status&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;{Host=web1,disk=/etc}&lt;/td&gt;
              &lt;td&gt;Alerting&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;{Host=web2,disk=/var}&lt;/td&gt;
              &lt;td&gt;Alerting&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;{Host=web3,disk=/var}&lt;/td&gt;
              &lt;td&gt;Normal&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;]]></content><description>&lt;h1 id="queries-and-conditions">Queries and conditions&lt;/h1>
&lt;p>In Grafana, queries fetch and transform data from
&lt;a href="/docs/grafana/v11.4/datasources/">data sources,&lt;/a> which include databases like MySQL or PostgreSQL, time series databases like Prometheus or InfluxDB, and services like Amazon CloudWatch or Azure Monitor.&lt;/p></description></item><item><title>Labels and annotations</title><link>https://grafana.com/docs/grafana/v11.4/alerting/fundamentals/alert-rules/annotation-label/</link><pubDate>Sun, 08 Mar 2026 02:10:29 +0000</pubDate><guid>https://grafana.com/docs/grafana/v11.4/alerting/fundamentals/alert-rules/annotation-label/</guid><content><![CDATA[&lt;h1 id=&#34;labels-and-annotations&#34;&gt;Labels and annotations&lt;/h1&gt;
&lt;p&gt;Labels and annotations add additional information about an alert using key/value pairs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#labels&#34;&gt;Labels&lt;/a&gt; are used to differentiate an alert from all other alerts and decide how to manage them.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#annotations&#34;&gt;Annotations&lt;/a&gt; provide extra details for alert responders to help them understand and address potential issues.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;labels&#34;&gt;Labels&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Labels&lt;/strong&gt; are unique identifiers of an 
    &lt;a href=&#34;/docs/grafana/v11.4/alerting/fundamentals/#alert-instances&#34;&gt;alert instance&lt;/a&gt;. You can use them for searching, silencing, and routing notifications.&lt;/p&gt;
&lt;p&gt;Examples of labels are &lt;code&gt;server=server1&lt;/code&gt; or &lt;code&gt;team=backend&lt;/code&gt;. Each alert rule can have more than one label and the complete set of labels for an alert rule is called its label set. It is this label set that identifies the alert.&lt;/p&gt;
&lt;p&gt;For example, an alert instance might have the label set &lt;code&gt;{alertname=&amp;quot;High CPU usage&amp;quot;,server=&amp;quot;server1&amp;quot;}&lt;/code&gt; while another alert instance might have the label set &lt;code&gt;{alertname=&amp;quot;High CPU usage&amp;quot;,server=&amp;quot;server2&amp;quot;}&lt;/code&gt;. These are two separate alert instances because although their &lt;code&gt;alertname&lt;/code&gt; labels are the same, their &lt;code&gt;server&lt;/code&gt; labels are different.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 2294px;&#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;/static/img/docs/alerting/unified/multi-dimensional-alert.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;/static/img/docs/alerting/unified/multi-dimensional-alert.png&#34;data-srcset=&#34;/static/img/docs/alerting/unified/multi-dimensional-alert.png?w=320 320w, /static/img/docs/alerting/unified/multi-dimensional-alert.png?w=550 550w, /static/img/docs/alerting/unified/multi-dimensional-alert.png?w=750 750w, /static/img/docs/alerting/unified/multi-dimensional-alert.png?w=900 900w, /static/img/docs/alerting/unified/multi-dimensional-alert.png?w=1040 1040w, /static/img/docs/alerting/unified/multi-dimensional-alert.png?w=1240 1240w, /static/img/docs/alerting/unified/multi-dimensional-alert.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Image shows an example of an alert instance and the labels used on the alert instance.&#34;width=&#34;2294&#34;height=&#34;442&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/alerting/unified/multi-dimensional-alert.png&#34;
            alt=&#34;Image shows an example of an alert instance and the labels used on the alert instance.&#34;width=&#34;2294&#34;height=&#34;442&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Labels are a fundamental component of alerting:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The complete set of labels for an alert is what uniquely identifies an alert instance.&lt;/li&gt;
&lt;li&gt;The alerting UI shows labels for every alert instance generated during evaluation of that rule.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v11.4/alerting/fundamentals/notifications/notification-policies/&#34;&gt;Notification policies&lt;/a&gt; and 
    &lt;a href=&#34;/docs/grafana/v11.4/alerting/configure-notifications/create-silence/&#34;&gt;silences&lt;/a&gt; use labels to match alert instances and route them to contact points or stop their notifications.&lt;/li&gt;
&lt;li&gt;Contact points can include information from labels in notification messages.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;label-types&#34;&gt;Label types&lt;/h3&gt;
&lt;p&gt;An alert&amp;rsquo;s label set can contain three types of labels:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;User-configured labels&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Labels that you manually configure in the alert rule to identify the generated alert instances and manage the alerts. Common custom labels, depending on the use case, are: &lt;code&gt;severity&lt;/code&gt;, &lt;code&gt;priority&lt;/code&gt;, &lt;code&gt;team&lt;/code&gt;, and &lt;code&gt;service&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Additionally, you can use a 
    &lt;a href=&#34;/docs/grafana/v11.4/alerting/fundamentals/templates/&#34;&gt;template&lt;/a&gt; to customize the label value and generate dynamic values from query data.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Query labels&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Query labels are labels returned by the data source query.&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/query-labels-and-values.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/query-labels-and-values.png&#34;data-srcset=&#34;/media/docs/alerting/query-labels-and-values.png?w=320 320w, /media/docs/alerting/query-labels-and-values.png?w=550 550w, /media/docs/alerting/query-labels-and-values.png?w=750 750w, /media/docs/alerting/query-labels-and-values.png?w=900 900w, /media/docs/alerting/query-labels-and-values.png?w=1040 1040w, /media/docs/alerting/query-labels-and-values.png?w=1240 1240w, /media/docs/alerting/query-labels-and-values.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;An alert rule query returning labels from the query.&#34;width=&#34;1275&#34;height=&#34;367&#34;title=&#34;An alert rule query returning labels from the query.&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/alerting/query-labels-and-values.png&#34;
            alt=&#34;An alert rule query returning labels from the query.&#34;width=&#34;1275&#34;height=&#34;367&#34;title=&#34;An alert rule query returning labels from the query.&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;An alert rule query returning labels from the query.&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Query labels can generate multiple alert instances from the same alert rule, helping to distinguish alerts from different data. In this example, the &lt;code&gt;instance&lt;/code&gt; label generates an alert instance for each server.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reserved labels&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Reserved labels are automatically added by Grafana:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;alertname&lt;/code&gt;: the name of the alert rule.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;grafana_folder&lt;/code&gt;: the title of the folder containing the alert.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Labels prefixed with &lt;code&gt;grafana_&lt;/code&gt; are reserved by Grafana for special use. You can disable reserved labels via the 
    &lt;a href=&#34;/docs/grafana/v11.4/setup-grafana/configure-grafana/#unified_alertingreserved_labels&#34;&gt;&lt;code&gt;unified_alerting.reserved_labels&lt;/code&gt;&lt;/a&gt; option.&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;Two alert rules cannot produce alert instances with the same labels. If two alert rules have the same labels such as &lt;code&gt;foo=bar,bar=baz&lt;/code&gt; and &lt;code&gt;foo=bar,bar=baz&lt;/code&gt; then one of the generated alert instances is discarded.&lt;/p&gt;
&lt;p&gt;Ensure the label set for an alert does not have two or more labels with the same name.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If a configured label has the same name as a data source query label, it replaces the data source label.&lt;/li&gt;
&lt;li&gt;If a configured label has the same name as a reserved label, it is omitted.&lt;/li&gt;
&lt;/ul&gt;&lt;/blockquote&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;Label key format&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;Grafana has a built-in Alertmanager that supports both Unicode label keys and values. If you are using an external Prometheus Alertmanager, label keys must be compatible with their &lt;a href=&#34;https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;data model&lt;/a&gt;.
This means that label keys must only contain &lt;em&gt;ASCII letters&lt;/em&gt;, &lt;em&gt;numbers&lt;/em&gt;, and &lt;em&gt;underscores&lt;/em&gt;.
Label keys must also be matched by the regular expression &lt;code&gt;[a-zA-Z_][a-zA-Z0-9_]*&lt;/code&gt;.
Any invalid characters are removed or replaced by the Grafana alerting engine before being sent to the external Alertmanager according to the following rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Whitespace is removed.&lt;/li&gt;
&lt;li&gt;ASCII characters are replaced with &lt;code&gt;_&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;All other characters are replaced with their lower-case hex representation.
If this is the first character it&amp;rsquo;s prefixed with &lt;code&gt;_&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Example: A label key/value pair &lt;code&gt;Alert! 🔔=&amp;quot;🔥&amp;quot;&lt;/code&gt; will become &lt;code&gt;Alert_0x1f514=&amp;quot;🔥&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If multiple label keys are sanitized to the same value, the duplicates have a short hash of the original label appended as a suffix.&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;h2 id=&#34;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;p&gt;Annotations add additional information to alert instances, helping responders identify and address potential issues.&lt;/p&gt;
&lt;p&gt;Annotations are displayed in Grafana and are included by default in notifications. Grafana provides several optional annotations that you can edit:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;summary&lt;/code&gt;: A short summary of what the alert has detected and why.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;description&lt;/code&gt;: A detailed description of what happened and what the alert does.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;runbook_url&lt;/code&gt;: The runbook page to guide operators managing a potential incident.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dashboardUId&lt;/code&gt; and &lt;code&gt;panelId&lt;/code&gt;: 
    &lt;a href=&#34;/docs/grafana/v11.4/alerting/alerting-rules/link-alert-rules-to-panels/&#34;&gt;Link the alert to a dashboard and panel&lt;/a&gt; to facilitate alert investigation.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, you can edit the annotation &lt;code&gt;summary&lt;/code&gt; to explain why the alert was triggered:&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;And edit the &lt;code&gt;description&lt;/code&gt; annotation to provide more context and how to respond:&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;The web server&amp;#39;s CPU has exceeded 80% for more than 5 minutes.

This indicates that the system is under heavy load and may result in an outage.

Consider scaling the server&amp;#39;s resources and investigating bottlenecks.&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Like labels, annotations can use a 
    &lt;a href=&#34;/docs/grafana/v11.4/alerting/fundamentals/templates/&#34;&gt;template&lt;/a&gt; to include dynamic data from queries.&lt;/p&gt;
]]></content><description>&lt;h1 id="labels-and-annotations">Labels and annotations&lt;/h1>
&lt;p>Labels and annotations add additional information about an alert using key/value pairs:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="#labels">Labels&lt;/a> are used to differentiate an alert from all other alerts and decide how to manage them.&lt;/li>
&lt;li>&lt;a href="#annotations">Annotations&lt;/a> provide extra details for alert responders to help them understand and address potential issues.&lt;/li>
&lt;/ul>
&lt;h2 id="labels">Labels&lt;/h2>
&lt;p>&lt;strong>Labels&lt;/strong> are unique identifiers of an
&lt;a href="/docs/grafana/v11.4/alerting/fundamentals/#alert-instances">alert instance&lt;/a>. You can use them for searching, silencing, and routing notifications.&lt;/p></description></item></channel></rss>