<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Prometheus data source on Grafana Labs</title><link>https://grafana.com/docs/grafana/v13.1/datasources/prometheus/</link><description>Recent content in Prometheus data source on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/grafana/v13.1/datasources/prometheus/index.xml" rel="self" type="application/rss+xml"/><item><title>Configure the Prometheus data source</title><link>https://grafana.com/docs/grafana/v13.1/datasources/prometheus/configure/</link><pubDate>Tue, 23 Jun 2026 13:06:40 +0000</pubDate><guid>https://grafana.com/docs/grafana/v13.1/datasources/prometheus/configure/</guid><content><![CDATA[&lt;h1 id=&#34;configure-the-prometheus-data-source&#34;&gt;Configure the Prometheus data source&lt;/h1&gt;
&lt;p&gt;This document provides instructions for configuring the Prometheus data source and explains the available configuration options. Grafana includes built-in support for Prometheus, so you don&amp;rsquo;t need to install a plugin. For general information on adding a data source to Grafana, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/#add-a-data-source&#34;&gt;Add a data source&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;You need the &lt;code&gt;Organization administrator&lt;/code&gt; role to configure the data source. You can also &lt;a href=&#34;#provision-the-data-source&#34;&gt;configure it via YAML&lt;/a&gt; using Grafana provisioning or &lt;a href=&#34;#terraform&#34;&gt;using Terraform&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Know which type of Prometheus-compatible database you&amp;rsquo;re connecting to (Prometheus, Mimir, Cortex, or Thanos), as the configuration options vary by type.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Have your Prometheus server URL ready. If using TLS/SSL, gather any necessary security certificates and client keys.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If using Basic authentication, have your username and password ready.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;add-the-data-source&#34;&gt;Add the data source&lt;/h2&gt;
&lt;p&gt;To add the Prometheus data source, complete the following steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;Connections&lt;/strong&gt; in the left-side menu.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Connections&lt;/strong&gt;, click &lt;strong&gt;Add new connection&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter &lt;code&gt;Prometheus&lt;/code&gt; in the search bar.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Prometheus data source&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add new data source&lt;/strong&gt; in the upper right.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Grafana takes you to the &lt;strong&gt;Settings&lt;/strong&gt; tab where you set up your Prometheus configuration.&lt;/p&gt;
&lt;h2 id=&#34;configuration-options&#34;&gt;Configuration options&lt;/h2&gt;
&lt;p&gt;The following sections describe the configuration options available on the Settings tab. These sections follow the order in which they appear in the UI.&lt;/p&gt;
&lt;h3 id=&#34;name-and-default&#34;&gt;Name and default&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Name&lt;/strong&gt; - The data source name. Sets the name you use to refer to the data source in panels and queries. Examples: &lt;code&gt;prometheus-1&lt;/code&gt;, &lt;code&gt;prom-metrics&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Default&lt;/strong&gt; - Toggle to select as the default data source in dashboard panels.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;connection&#34;&gt;Connection&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Prometheus server URL&lt;/strong&gt; - The URL of your Prometheus server. &lt;p&gt;If Prometheus is running locally, use &lt;code&gt;http://localhost:9090&lt;/code&gt;. If it&amp;rsquo;s hosted on a networked server, provide the server&amp;rsquo;s URL along with the port where Prometheus is running. Example: &lt;code&gt;http://prometheus.example.orgname:9090&lt;/code&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;When running Grafana and Prometheus in separate containers, localhost refers to each container&amp;rsquo;s own network namespace. This means that &lt;code&gt;localhost:9090&lt;/code&gt; points to port 9090 inside the Grafana container, not on the host machine.&lt;/p&gt;
&lt;p&gt;Use the IP address of the Prometheus container, or the hostname if you are using Docker Compose. Alternatively, you can use &lt;code&gt;http://host.docker.internal:9090&lt;/code&gt; to reference the host machine.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;authentication&#34;&gt;Authentication&lt;/h3&gt;
&lt;p&gt;There are three authentication options for the Prometheus data source.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Basic authentication&lt;/strong&gt; - The most common authentication method.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;User&lt;/strong&gt; - The username you use to connect to the data source.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Password&lt;/strong&gt; - The password you use to connect to the data source.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Forward OAuth identity&lt;/strong&gt; - Forward the OAuth access token (and also the OIDC ID token if available) of the user querying the data source.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;No authentication&lt;/strong&gt; - Allows access to the data source without any authentication.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Additional authentication methods (Azure AD, AWS SigV4) are available depending on your deployment:&lt;/p&gt;


&lt;div class=&#34;admonition admonition-warning&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Warning&lt;/p&gt;&lt;p&gt;Azure AD and SigV4 authentication on the core Prometheus data source are &lt;strong&gt;deprecated&lt;/strong&gt; in Grafana 13. Existing data sources using these methods are automatically migrated to dedicated plugins on startup. For new setups, use the &lt;a href=&#34;/grafana/plugins/grafana-azureprometheus-datasource/&#34;&gt;Azure Monitor Managed Service for Prometheus&lt;/a&gt; or &lt;a href=&#34;/grafana/plugins/grafana-amazonprometheus-datasource/&#34;&gt;Amazon Managed Service for Prometheus&lt;/a&gt; plugins instead. For migration details, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/configure/azure-authentication/&#34;&gt;Azure authentication (deprecated)&lt;/a&gt; or 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/configure/aws-authentication/&#34;&gt;AWS authentication (deprecated)&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Azure AD authentication&lt;/strong&gt; - Available in Grafana Enterprise and self-managed instances where &lt;code&gt;azure_auth_enabled = true&lt;/code&gt; is configured. On Grafana Cloud, this option requires a server-side feature flag that isn&amp;rsquo;t enabled by default — contact &lt;a href=&#34;/profile/org#support&#34;&gt;Grafana Support&lt;/a&gt; to request it be enabled for your stack. Refer to &lt;a href=&#34;#azure-authentication-settings-deprecated&#34;&gt;Azure authentication settings&lt;/a&gt; for configuration details.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AWS SigV4 authentication&lt;/strong&gt; - Available in self-managed Grafana instances where &lt;code&gt;sigv4_auth_enabled = true&lt;/code&gt; is configured. On Grafana Cloud, this option isn&amp;rsquo;t available by default — contact &lt;a href=&#34;/profile/org#support&#34;&gt;Grafana Support&lt;/a&gt; to request it be enabled for your stack.&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;If Azure AD or SigV4 options don&amp;rsquo;t appear in the authentication drop-down, the required feature flag isn&amp;rsquo;t enabled on your instance. For Grafana Cloud, submit a support request. For self-managed instances, update the Grafana configuration file.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;tls-settings&#34;&gt;TLS settings&lt;/h3&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;Use TLS (Transport Layer Security) for an additional layer of security when working with Prometheus. For information on setting up TLS encryption with Prometheus refer to &lt;a href=&#34;https://prometheus.io/docs/guides/tls-encryption/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Securing Prometheus API and UI Endpoints Using TLS Encryption&lt;/a&gt;. You must add TLS settings to your Prometheus configuration file &lt;strong&gt;prior&lt;/strong&gt; to setting these options in Grafana.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Add self-signed certificate&lt;/strong&gt; - Check the box to authenticate with a CA certificate. Follow the instructions of the CA (Certificate Authority) to download the certificate file. Required for verifying self-signed TLS certificates.
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CA certificate&lt;/strong&gt; - Add your certificate.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;TLS client authentication&lt;/strong&gt; - Check the box to enable TLS client authentication.
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Server name&lt;/strong&gt; - Add the server name, which is used to verify the hostname on the returned certificate.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Client certificate&lt;/strong&gt; - The client certificate is generated from a Certificate Authority or is self-signed. Follow the instructions of the CA to download the certificate file.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Client key&lt;/strong&gt; - Add your client key, which can also be generated from a CA or be self-signed. The client key encrypts data between the client and server.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Skip TLS verify&lt;/strong&gt; - Toggle on to bypass TLS certificate validation. Skipping TLS certificate validation is not recommended unless absolutely necessary or for testing purposes.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;http-headers&#34;&gt;HTTP headers&lt;/h3&gt;
&lt;p&gt;Pass along additional information and metadata about the request or response.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Header&lt;/strong&gt; - Add a custom header. This allows custom headers to be passed based on the needs of your Prometheus instance.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Value&lt;/strong&gt; - The value of the header.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;advanced-http-settings&#34;&gt;Advanced HTTP settings&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Allowed cookies&lt;/strong&gt; - Specify cookies by name that should be forwarded to the data source. The Grafana proxy deletes all forwarded cookies by default.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Timeout&lt;/strong&gt; - The HTTP request timeout in seconds.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;alerting&#34;&gt;Alerting&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Manage alerts via Alerting UI&lt;/strong&gt; - Toggled on by default. This enables 
    &lt;a href=&#34;/docs/grafana/v13.1/alerting/fundamentals/alert-rules/&#34;&gt;data source-managed rules in Grafana Alerting&lt;/a&gt; for this data source. For &lt;code&gt;Mimir&lt;/code&gt;, it enables managing data source-managed rules and alerts. For &lt;code&gt;Prometheus&lt;/code&gt;, it only supports viewing existing rules and alerts, which are displayed as data source-managed. Change this by setting the 
    &lt;a href=&#34;/docs/grafana/v13.1/setup-grafana/configure-grafana/#default_manage_alerts_ui_toggle&#34;&gt;&lt;code&gt;default_manage_alerts_ui_toggle&lt;/code&gt;&lt;/a&gt; option in the &lt;code&gt;grafana.ini&lt;/code&gt; configuration file.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Allow as recording rules target&lt;/strong&gt; - Toggled on by default. This allows the data source to be selected as a target destination for writing 
    &lt;a href=&#34;/docs/grafana/v13.1/alerting/alerting-rules/create-recording-rules/create-grafana-managed-recording-rules/&#34;&gt;Grafana-managed recording rules&lt;/a&gt;. When enabled, this data source appears in the target data source list when creating or importing recording rules. Change this by setting the 
    &lt;a href=&#34;/docs/grafana/v13.1/setup-grafana/configure-grafana/#default_allow_recording_rules_target_alerts_ui_toggle&#34;&gt;&lt;code&gt;default_allow_recording_rules_target_alerts_ui_toggle&lt;/code&gt;&lt;/a&gt; option in the &lt;code&gt;grafana.ini&lt;/code&gt; configuration file.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;interval-behavior&#34;&gt;Interval behavior&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Scrape interval&lt;/strong&gt; - Sets the standard scrape and evaluation interval in Prometheus. The default is &lt;code&gt;15s&lt;/code&gt;. Set it to match the typical scrape and evaluation interval in your Prometheus configuration file. If you set a higher value than your Prometheus configuration, Grafana evaluates data at this interval, resulting in less data points.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Query timeout&lt;/strong&gt; - Sets the Prometheus query timeout. The default is &lt;code&gt;60s&lt;/code&gt;. Without a timeout, complex or inefficient queries can run indefinitely, consuming CPU and memory resources.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;query-editor&#34;&gt;Query editor&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Default editor&lt;/strong&gt; - Sets the default query editor. Options are &lt;code&gt;Builder&lt;/code&gt; or &lt;code&gt;Code&lt;/code&gt;. &lt;code&gt;Builder&lt;/code&gt; mode helps you build queries using a visual interface. &lt;code&gt;Code&lt;/code&gt; mode is geared for the experienced Prometheus user with prior expertise in PromQL. For more details on editor types, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/query-editor/&#34;&gt;Prometheus query editor&lt;/a&gt;. You can switch between editors in the query editor UI.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Disable metrics lookup&lt;/strong&gt; - Toggle on to disable the metrics chooser and metric and label support in the query field&amp;rsquo;s autocomplete. This can improve performance for large Prometheus instances.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;performance&#34;&gt;Performance&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Prometheus type&lt;/strong&gt; - Select the type of your Prometheus-compatible database. Setting this incorrectly may cause unexpected behavior when querying metrics and labels. Cortex is end-of-life; if you&amp;rsquo;re running Cortex, consider migrating to &lt;a href=&#34;/oss/mimir/&#34;&gt;Mimir&lt;/a&gt;.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Capability&lt;/th&gt;
              &lt;th&gt;Prometheus&lt;/th&gt;
              &lt;th&gt;Mimir&lt;/th&gt;
              &lt;th&gt;Thanos&lt;/th&gt;
              &lt;th&gt;Cortex&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Regex label matching in variable queries&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Metadata API (metric type/help)&lt;/td&gt;
              &lt;td&gt;Yes (2.4&#43;)&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Exemplars&lt;/td&gt;
              &lt;td&gt;Yes (2.26&#43;)&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Data source-managed alert rules (read/write)&lt;/td&gt;
              &lt;td&gt;Read only&lt;/td&gt;
              &lt;td&gt;Read/Write&lt;/td&gt;
              &lt;td&gt;Read only&lt;/td&gt;
              &lt;td&gt;Read/Write&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Recording rules target (write-back)&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;LBAC (Team-based access control)&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Yes (Cloud/GEM)&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Native histograms&lt;/td&gt;
              &lt;td&gt;Yes (2.40&#43;)&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Grafana uses this setting to determine which API endpoints and features to enable. For example, when set to Mimir, Grafana uses regular expression-optimized label queries that significantly improve autocomplete and variable loading performance for large metric sets.&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;Team-based Label-Based Access Control (LBAC) for the Prometheus data source requires the backend to be &lt;strong&gt;Grafana Cloud Metrics (Mimir)&lt;/strong&gt; or &lt;strong&gt;Grafana Enterprise Metrics (GEM)&lt;/strong&gt;. LBAC doesn&amp;rsquo;t work with external Prometheus-compatible endpoints such as Google Managed Prometheus, self-hosted Prometheus, or Thanos, even if you enable the &lt;code&gt;teamHttpHeadersMimir&lt;/code&gt; setting. The LBAC enforcement relies on Mimir-specific HTTP headers that other backends don&amp;rsquo;t support.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cache level&lt;/strong&gt; - Sets the browser caching level for editor queries. Options: &lt;code&gt;Low&lt;/code&gt;, &lt;code&gt;Medium&lt;/code&gt;, &lt;code&gt;High&lt;/code&gt;, or &lt;code&gt;None&lt;/code&gt;. Higher cache settings are recommended for high-cardinality data sources.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Incremental querying (beta)&lt;/strong&gt; - Toggle on to enable incremental querying. Instead of always requesting fresh data from the Prometheus instance, Grafana caches query results and only fetches new records. This helps reduce database and network load.
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Query overlap window&lt;/strong&gt; - Specify a duration (for example, &lt;code&gt;10m&lt;/code&gt;, &lt;code&gt;120s&lt;/code&gt;, or &lt;code&gt;0s&lt;/code&gt;). The default is &lt;code&gt;10m&lt;/code&gt;. This buffer is added to each incremental request to account for delayed data ingestion.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Disable recording rules (beta)&lt;/strong&gt; - Toggle on to disable recording rules. When disabled, Grafana won&amp;rsquo;t fetch and parse recording rules from Prometheus, improving dashboard performance by reducing processing overhead.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;other&#34;&gt;Other&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Custom query parameters&lt;/strong&gt; - Add custom parameters to the Prometheus query URL for more control over query execution. Examples: &lt;code&gt;timeout&lt;/code&gt;, &lt;code&gt;partial_response&lt;/code&gt;, &lt;code&gt;dedup&lt;/code&gt;, or &lt;code&gt;max_source_resolution&lt;/code&gt;. Join multiple parameters with &lt;code&gt;&amp;amp;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;HTTP method&lt;/strong&gt; - Select either the &lt;code&gt;POST&lt;/code&gt; or &lt;code&gt;GET&lt;/code&gt; HTTP method to query your data source. &lt;code&gt;POST&lt;/code&gt; is recommended and selected by default, as it supports larger queries. Select &lt;code&gt;GET&lt;/code&gt; if your network restricts &lt;code&gt;POST&lt;/code&gt; requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Series limit&lt;/strong&gt; - Maximum number of returned series. The limit applies to all resources (metrics, labels, and values) for both endpoints (series and labels). Leave empty to use the default limit (40000). Set to &lt;code&gt;0&lt;/code&gt; to disable the limit — this may cause performance issues.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use series endpoint&lt;/strong&gt; - Toggle on to use the series endpoint (&lt;code&gt;/api/v1/series&lt;/code&gt;) with the &lt;code&gt;match[]&lt;/code&gt; parameter instead of the label values endpoint (&lt;code&gt;/api/v1/label/&amp;lt;label_name&amp;gt;/values&lt;/code&gt;). The label values endpoint is generally more performant, but the series endpoint supports the &lt;code&gt;POST&lt;/code&gt; method.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;exemplars&#34;&gt;Exemplars&lt;/h3&gt;
&lt;p&gt;Support for exemplars is available only for the Prometheus data source. An exemplar is a trace that represents a specific measurement taken within a given time interval. For more information, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/fundamentals/exemplars/&#34;&gt;Introduction to exemplars&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Click the &lt;strong&gt;&#43; sign&lt;/strong&gt; to add exemplars.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Internal link&lt;/strong&gt; - Toggle on to enable an internal link. This displays the data source selector, where you can choose the backend tracing data store for your exemplar data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;URL&lt;/strong&gt; - &lt;em&gt;(Visible if you disable &lt;code&gt;Internal link&lt;/code&gt;)&lt;/em&gt; Defines the external link&amp;rsquo;s URL trace backend. You can interpolate the value from the field by using the 
    &lt;a href=&#34;/docs/grafana/v13.1/panels-visualizations/configure-data-links/#value-variables&#34;&gt;&lt;code&gt;${__value.raw}&lt;/code&gt; macro&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data source&lt;/strong&gt; - &lt;em&gt;(Visible when &lt;code&gt;Internal link&lt;/code&gt; is enabled)&lt;/em&gt; Select the tracing data source that the exemplar links to.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;URL label&lt;/strong&gt; - Adds a custom display label to override the value of the &lt;code&gt;Label name&lt;/code&gt; field.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Label name&lt;/strong&gt; - The name of the field in the &lt;code&gt;labels&lt;/code&gt; object used to obtain the traceID property.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Remove exemplar link&lt;/strong&gt; - Click the &lt;strong&gt;X&lt;/strong&gt; to remove existing links.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can add multiple exemplar configurations.&lt;/p&gt;
&lt;h3 id=&#34;private-data-source-connect&#34;&gt;Private data source connect&lt;/h3&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;Private data source connect (PDC) is only available for Grafana Cloud users.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;PDC allows you to establish a private, secured connection between a Grafana Cloud instance and data sources within a private network without opening the network to inbound traffic.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Private data source connect network&lt;/strong&gt; - Select the PDC network where your data source is available.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;PDC supports both querying and writing to Prometheus-compatible data sources. This means 
    &lt;a href=&#34;/docs/grafana/v13.1/alerting/alerting-rules/create-recording-rules/create-grafana-managed-recording-rules/&#34;&gt;Grafana-managed recording rules&lt;/a&gt; can write their results to a Prometheus or Mimir instance behind a PDC connection.&lt;/p&gt;
&lt;p&gt;If you use PDC with SigV4 (AWS Signature Version 4 Authentication), the PDC agent must allow internet egress to &lt;code&gt;sts.&amp;lt;region&amp;gt;.amazonaws.com:443&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Click &lt;strong&gt;Manage private data source connect networks&lt;/strong&gt; to view your PDC configuration details.&lt;/p&gt;
&lt;p&gt;For more information, refer to &lt;a href=&#34;/docs/grafana-cloud/connect-externally-hosted/private-data-source-connect/&#34;&gt;Private data source connect (PDC)&lt;/a&gt; and &lt;a href=&#34;/docs/grafana-cloud/connect-externally-hosted/private-data-source-connect/configure-pdc/#configure-grafana-private-data-source-connect-pdc&#34;&gt;Configure PDC&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For troubleshooting PDC connectivity issues (DNS resolution, &amp;ldquo;host unreachable&amp;rdquo; errors, or parallel connection tuning), refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/troubleshooting/#pdc-connectivity-errors&#34;&gt;PDC connectivity errors&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;save-and-test&#34;&gt;Save and test&lt;/h2&gt;
&lt;p&gt;After you have configured your Prometheus data source options, click &lt;strong&gt;Save &amp;amp; test&lt;/strong&gt; at the bottom to test your data source connection.&lt;/p&gt;
&lt;p&gt;You should see a confirmation message:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Successfully queried the Prometheus API.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can also remove a connection by clicking &lt;strong&gt;Delete&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id=&#34;provision-the-data-source&#34;&gt;Provision the data source&lt;/h2&gt;
&lt;p&gt;You can define and configure the data source in YAML files as part of the Grafana provisioning system, or use Terraform with the Grafana provider.&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;After you have provisioned a data source, you cannot edit it through the UI.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;provision-with-yaml&#34;&gt;Provision with YAML&lt;/h3&gt;
&lt;p&gt;For more information about provisioning, and for available configuration options, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/administration/provisioning/&#34;&gt;Provision Grafana&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example Prometheus data source configuration:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;apiVersion: 1

datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    url: http://localhost:9090
    jsonData:
      httpMethod: POST
      manageAlerts: true
      allowAsRecordingRulesTarget: true
      prometheusType: Prometheus
      prometheusVersion: 3.3.0
      cacheLevel: &amp;#39;High&amp;#39;
      disableRecordingRules: false
      seriesEndpoint: false
      timeInterval: 10s
      incrementalQueryOverlapWindow: 10m
      exemplarTraceIdDestinations:
        - datasourceUid: my_jaeger_uid
          name: traceID
        - name: traceID
          url: &amp;#39;http://localhost:3000/explore?orgId=1&amp;amp;left=%5B%22now-1h%22,%22now%22,%22Jaeger%22,%7B%22query%22:%22$${__value.raw}%22%7D%5D&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;provision-with-terraform&#34;&gt;Provision with Terraform&lt;/h3&gt;
&lt;p&gt;You can configure the Prometheus data source using &lt;a href=&#34;https://www.terraform.io/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Terraform&lt;/a&gt; with the &lt;a href=&#34;https://registry.terraform.io/providers/grafana/grafana/latest/docs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana Terraform provider&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For more information about provisioning resources with Terraform, refer to &lt;a href=&#34;/docs/grafana-cloud/developer-resources/infrastructure-as-code/terraform/&#34;&gt;Grafana as code using Terraform&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The following example creates a Prometheus data source with common settings:&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;hcl&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-hcl&#34;&gt;resource &amp;#34;grafana_data_source&amp;#34; &amp;#34;prometheus&amp;#34; {
  name = &amp;#34;Prometheus&amp;#34;
  type = &amp;#34;prometheus&amp;#34;
  url  = &amp;#34;http://localhost:9090&amp;#34;

  json_data_encoded = jsonencode({
    httpMethod                    = &amp;#34;POST&amp;#34;
    manageAlerts                  = true
    prometheusType                = &amp;#34;Prometheus&amp;#34;
    prometheusVersion             = &amp;#34;3.3.0&amp;#34;
    cacheLevel                    = &amp;#34;High&amp;#34;
    disableRecordingRules         = false
    incrementalQuerying           = true
    incrementalQueryOverlapWindow = &amp;#34;10m&amp;#34;
    timeInterval                  = &amp;#34;15s&amp;#34;
    exemplarTraceIdDestinations = [{
      datasourceUid = &amp;#34;my_tempo_uid&amp;#34;
      name          = &amp;#34;traceID&amp;#34;
    }]
  })
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The following example creates a Prometheus data source with basic authentication:&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;hcl&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-hcl&#34;&gt;resource &amp;#34;grafana_data_source&amp;#34; &amp;#34;prometheus_auth&amp;#34; {
  name = &amp;#34;Prometheus (authenticated)&amp;#34;
  type = &amp;#34;prometheus&amp;#34;
  url  = &amp;#34;https://prometheus.example.com:9090&amp;#34;

  basic_auth_enabled  = true
  basic_auth_username = &amp;#34;grafana&amp;#34;

  json_data_encoded = jsonencode({
    httpMethod     = &amp;#34;POST&amp;#34;
    prometheusType = &amp;#34;Mimir&amp;#34;
    timeInterval   = &amp;#34;15s&amp;#34;
  })

  secure_json_data_encoded = jsonencode({
    basicAuthPassword = var.prometheus_password
  })
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For all available configuration options, refer to the &lt;a href=&#34;https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/data_source&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana provider data source resource documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;azure-authentication-settings-deprecated&#34;&gt;Azure authentication settings (deprecated)&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-warning&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Warning&lt;/p&gt;&lt;p&gt;Azure AD authentication on the core Prometheus data source is &lt;strong&gt;deprecated&lt;/strong&gt; in Grafana 13. Data sources using this method are automatically migrated to the dedicated &lt;a href=&#34;/grafana/plugins/grafana-azureprometheus-datasource/&#34;&gt;Azure Monitor Managed Service for Prometheus&lt;/a&gt; plugin on startup. For migration details, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/configure/azure-authentication/&#34;&gt;Azure authentication (deprecated)&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;If you still need to configure Azure AD authentication on the core Prometheus data source (for example, on older Grafana versions), refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/azure-monitor/#configure-azure-active-directory-ad-authentication&#34;&gt;Configure Azure Active Directory (AD) authentication&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In Grafana Enterprise or self-managed OSS, update the &lt;code&gt;.ini&lt;/code&gt; configuration file. Refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/setup-grafana/configure-grafana/#configuration-file-location&#34;&gt;Configuration file location&lt;/a&gt; to locate your &lt;code&gt;.ini&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;Add the following setting in the &lt;strong&gt;[auth]&lt;/strong&gt; section:&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;[auth]
azure_auth_enabled = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;If you are using Azure authentication, don&amp;rsquo;t enable &lt;code&gt;Forward OAuth identity&lt;/code&gt;. Both methods use the same HTTP authorization headers, and the OAuth token will override your Azure credentials.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;troubleshooting&#34;&gt;Troubleshooting&lt;/h2&gt;
&lt;p&gt;If you encounter issues after configuring your Prometheus data source, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/troubleshooting/&#34;&gt;Troubleshoot Prometheus data source issues&lt;/a&gt;.&lt;/p&gt;
]]></content><description>&lt;h1 id="configure-the-prometheus-data-source">Configure the Prometheus data source&lt;/h1>
&lt;p>This document provides instructions for configuring the Prometheus data source and explains the available configuration options. Grafana includes built-in support for Prometheus, so you don&amp;rsquo;t need to install a plugin. For general information on adding a data source to Grafana, refer to
&lt;a href="/docs/grafana/v13.1/datasources/#add-a-data-source">Add a data source&lt;/a>.&lt;/p></description></item><item><title>Prometheus query editor</title><link>https://grafana.com/docs/grafana/v13.1/datasources/prometheus/query-editor/</link><pubDate>Tue, 23 Jun 2026 13:06:40 +0000</pubDate><guid>https://grafana.com/docs/grafana/v13.1/datasources/prometheus/query-editor/</guid><content><![CDATA[&lt;h1 id=&#34;prometheus-query-editor&#34;&gt;Prometheus query editor&lt;/h1&gt;
&lt;p&gt;The Prometheus query editor lets you write PromQL queries against your Prometheus-compatible data sources. It includes a visual query builder for constructing queries without writing PromQL, a code editor with autocomplete and syntax highlighting, and configurable output formats for different visualization types.&lt;/p&gt;
&lt;p&gt;You can access the query editor from the 
    &lt;a href=&#34;/docs/grafana/v13.1/explore/&#34;&gt;Explore page&lt;/a&gt; or from any dashboard panel by clicking the panel title and selecting &lt;strong&gt;Edit&lt;/strong&gt;. For general documentation on querying data sources in Grafana, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/panels-visualizations/query-transform-data/&#34;&gt;Query and transform data&lt;/a&gt;. For more information about PromQL, see &lt;a href=&#34;http://prometheus.io/docs/querying/basics/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Querying Prometheus&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The query editor has two modes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#builder-mode&#34;&gt;Builder mode&lt;/a&gt; — Visual interface for constructing queries without writing PromQL directly.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#code-mode&#34;&gt;Code mode&lt;/a&gt; — Text editor with autocomplete for writing PromQL directly.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/prometheus/builder-code-v11-mode.png&#34;
  alt=&#34;Query editor mode&#34; width=&#34;1130&#34;
     height=&#34;216&#34;/&gt;&lt;/p&gt;
&lt;p&gt;Grafana synchronizes both modes, allowing you to switch between them. Grafana also displays a warning message if it detects an issue with the query while switching modes.&lt;/p&gt;
&lt;h2 id=&#34;query-options&#34;&gt;Query options&lt;/h2&gt;
&lt;p&gt;The following options are available in both Builder and Code modes. They control how the query is executed and how results are displayed.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 500px;&#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;/static/img/docs/prometheus/options.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;/static/img/docs/prometheus/options.png&#34;data-srcset=&#34;/static/img/docs/prometheus/options.png?w=320 320w, /static/img/docs/prometheus/options.png?w=550 550w, /static/img/docs/prometheus/options.png?w=750 750w, /static/img/docs/prometheus/options.png?w=900 900w, /static/img/docs/prometheus/options.png?w=1040 1040w, /static/img/docs/prometheus/options.png?w=1240 1240w, /static/img/docs/prometheus/options.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Query options&#34;width=&#34;820&#34;height=&#34;114&#34;title=&#34;Query options&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/prometheus/options.png&#34;
            alt=&#34;Query options&#34;width=&#34;820&#34;height=&#34;114&#34;title=&#34;Query options&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Query options&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;legend&#34;&gt;Legend&lt;/h3&gt;
&lt;p&gt;Controls the display name for time series in the panel legend.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Auto&lt;/strong&gt; — Displays unique labels only, hiding labels that are common across all returned series. This produces cleaner legends when many series share the same labels.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Verbose&lt;/strong&gt; — Displays all label names for every series.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Custom&lt;/strong&gt; — Lets you define the legend using label templates. For example, &lt;code&gt;{{hostname}}&lt;/code&gt; is replaced with the value of the &lt;code&gt;hostname&lt;/code&gt; label. To switch to a different legend mode, clear the input and click outside the field.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;min-step&#34;&gt;Min step&lt;/h3&gt;
&lt;p&gt;Sets the minimum interval between data points returned by the query. For example, setting this to &lt;code&gt;1h&lt;/code&gt; means data is returned at hourly intervals at minimum. This setting supports the &lt;code&gt;$__interval&lt;/code&gt; and &lt;code&gt;$__rate_interval&lt;/code&gt; macros.&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;The time range of the query is aligned to the step size, which may adjust the actual start and end times of the returned data.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;format&#34;&gt;Format&lt;/h3&gt;
&lt;p&gt;Determines how query results are interpreted and displayed in a panel.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Time series&lt;/strong&gt; — The default format. Returns data as time-indexed series suitable for graph panels.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Table&lt;/strong&gt; — Displays data in a tabular format. Works only in a 
    &lt;a href=&#34;/docs/grafana/v13.1/panels-visualizations/visualizations/table/&#34;&gt;Table panel&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Heatmap&lt;/strong&gt; — Displays histogram-type metrics in a 
    &lt;a href=&#34;/docs/grafana/v13.1/panels-visualizations/visualizations/heatmap/&#34;&gt;Heatmap panel&lt;/a&gt; by converting cumulative histograms to regular ones and sorting the series by bucket boundary.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;type&#34;&gt;Type&lt;/h3&gt;
&lt;p&gt;Determines the query type.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Both&lt;/strong&gt; — The default. Runs both a Range query and an Instant query and returns combined results.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Range&lt;/strong&gt; — Returns a set of time series where each series includes multiple data points over the selected time range. Use this for graph visualizations (lines, bars, points, stacked).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Instant&lt;/strong&gt; — Returns a single data point per series (the most recent value within the selected time range). Use this for stat panels, tables, or gauges. To visualize instant query results in a time series panel, add a field override with the &lt;code&gt;Transform&lt;/code&gt; property set to &lt;code&gt;Constant&lt;/code&gt;. For more information, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/panels-visualizations/visualizations/time-series/#transform&#34;&gt;Time Series Transform option&lt;/a&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;Grafana adjusts the query time range to align with the dynamically calculated step interval. This ensures consistent metric visualization and supports Prometheus result caching. However, this alignment can cause minor visual differences, such as a slight gap at the graph&amp;rsquo;s right edge or a shifted start time. For example, a &lt;code&gt;15s&lt;/code&gt; step aligns timestamps to Unix times divisible by 15 seconds. A &lt;code&gt;1w&lt;/code&gt; Min step aligns the range to the start of the week (Thursday at 00:00 UTC in Prometheus).&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;exemplars&#34;&gt;Exemplars&lt;/h3&gt;
&lt;p&gt;Toggle on to include exemplars in the graph. Exemplars link aggregated metric data to specific trace examples, letting you jump from a spike directly to a relevant trace. For more information, see 
    &lt;a href=&#34;/docs/grafana/v13.1/fundamentals/exemplars/&#34;&gt;Introduction to exemplars&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;Exemplars are not available with Instant query types.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;builder-mode&#34;&gt;Builder mode&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Builder mode&lt;/strong&gt; helps you build queries using a visual interface. This option is best for users who have limited experience with PromQL.&lt;/p&gt;
&lt;p&gt;Builder mode contains the following components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Kick start your query&lt;/strong&gt; — Click to view predefined operation patterns that help you quickly build queries with multiple operations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Rate query starters&lt;/li&gt;
&lt;li&gt;Histogram query starters&lt;/li&gt;
&lt;li&gt;Binary query starters&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Click the arrow next to each to see the available options.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Explain&lt;/strong&gt; — Toggle on to display a step-by-step explanation of all query components and operations.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 500px;&#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;/static/img/docs/prometheus/explain-results.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;/static/img/docs/prometheus/explain-results.png&#34;data-srcset=&#34;/static/img/docs/prometheus/explain-results.png?w=320 320w, /static/img/docs/prometheus/explain-results.png?w=550 550w, /static/img/docs/prometheus/explain-results.png?w=750 750w, /static/img/docs/prometheus/explain-results.png?w=900 900w, /static/img/docs/prometheus/explain-results.png?w=1040 1040w, /static/img/docs/prometheus/explain-results.png?w=1240 1240w, /static/img/docs/prometheus/explain-results.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Explain results&#34;width=&#34;1673&#34;height=&#34;366&#34;title=&#34;Explain results&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/prometheus/explain-results.png&#34;
            alt=&#34;Explain results&#34;width=&#34;1673&#34;height=&#34;366&#34;title=&#34;Explain results&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Explain results&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;select-a-metric&#34;&gt;Select a metric&lt;/h3&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 500px;&#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;/static/img/docs/prometheus/metrics-and-labels.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;/static/img/docs/prometheus/metrics-and-labels.png&#34;data-srcset=&#34;/static/img/docs/prometheus/metrics-and-labels.png?w=320 320w, /static/img/docs/prometheus/metrics-and-labels.png?w=550 550w, /static/img/docs/prometheus/metrics-and-labels.png?w=750 750w, /static/img/docs/prometheus/metrics-and-labels.png?w=900 900w, /static/img/docs/prometheus/metrics-and-labels.png?w=1040 1040w, /static/img/docs/prometheus/metrics-and-labels.png?w=1240 1240w, /static/img/docs/prometheus/metrics-and-labels.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Metric and label filters&#34;width=&#34;641&#34;height=&#34;120&#34;title=&#34;Metric and label filters&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/prometheus/metrics-and-labels.png&#34;
            alt=&#34;Metric and label filters&#34;width=&#34;641&#34;height=&#34;120&#34;title=&#34;Metric and label filters&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Metric and label filters&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Metric&lt;/strong&gt; — Select a metric from the drop-down. The data source provides available metrics based on the selected time range. You can type to search and filter the list. Click the book icon to open &lt;a href=&#34;#metrics-explorer&#34;&gt;Metrics explorer&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Label filters&lt;/strong&gt; — Select labels and values to filter the metric. Use the &lt;code&gt;&#43;&lt;/code&gt; button to add filters and the &lt;code&gt;x&lt;/code&gt; button to remove them. When a metric is selected, the data source requests available labels and their values from the server.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;add-operations&#34;&gt;Add operations&lt;/h3&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 500px;&#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;/static/img/docs/prometheus/operations.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;/static/img/docs/prometheus/operations.png&#34;data-srcset=&#34;/static/img/docs/prometheus/operations.png?w=320 320w, /static/img/docs/prometheus/operations.png?w=550 550w, /static/img/docs/prometheus/operations.png?w=750 750w, /static/img/docs/prometheus/operations.png?w=900 900w, /static/img/docs/prometheus/operations.png?w=1040 1040w, /static/img/docs/prometheus/operations.png?w=1240 1240w, /static/img/docs/prometheus/operations.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Operations&#34;width=&#34;652&#34;height=&#34;102&#34;title=&#34;Operations&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/prometheus/operations.png&#34;
            alt=&#34;Operations&#34;width=&#34;652&#34;height=&#34;102&#34;title=&#34;Operations&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Operations&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Click &lt;strong&gt;&#43; Operations&lt;/strong&gt; to add operations to your query. The query editor groups operations into the following categories:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Aggregations&lt;/a&gt; — &lt;code&gt;sum&lt;/code&gt;, &lt;code&gt;avg&lt;/code&gt;, &lt;code&gt;count&lt;/code&gt;, &lt;code&gt;min&lt;/code&gt;, &lt;code&gt;max&lt;/code&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/functions/#functions&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Range functions&lt;/a&gt; — &lt;code&gt;rate&lt;/code&gt;, &lt;code&gt;increase&lt;/code&gt;, &lt;code&gt;irate&lt;/code&gt;, &lt;code&gt;avg_over_time&lt;/code&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/functions/#functions&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Functions&lt;/a&gt; — &lt;code&gt;abs&lt;/code&gt;, &lt;code&gt;ceil&lt;/code&gt;, &lt;code&gt;histogram_quantile&lt;/code&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/operators/#binary-operators&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Binary operations&lt;/a&gt; — arithmetic and comparison operators.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/functions/#trigonometric-functions&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Trigonometric functions&lt;/a&gt; — &lt;code&gt;acos&lt;/code&gt;, &lt;code&gt;asin&lt;/code&gt;, &lt;code&gt;atan&lt;/code&gt;, etc.&lt;/li&gt;
&lt;li&gt;Time functions — &lt;code&gt;time&lt;/code&gt;, &lt;code&gt;timestamp&lt;/code&gt;, &lt;code&gt;day_of_week&lt;/code&gt;, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All operations display function parameters beneath the operation header. Some operations allow you to apply specific labels (for example, &lt;code&gt;by&lt;/code&gt; or &lt;code&gt;without&lt;/code&gt; clauses).&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 500px;&#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;/static/img/docs/prometheus/use-function-by-label-9-5.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;/static/img/docs/prometheus/use-function-by-label-9-5.png&#34;data-srcset=&#34;/static/img/docs/prometheus/use-function-by-label-9-5.png?w=320 320w, /static/img/docs/prometheus/use-function-by-label-9-5.png?w=550 550w, /static/img/docs/prometheus/use-function-by-label-9-5.png?w=750 750w, /static/img/docs/prometheus/use-function-by-label-9-5.png?w=900 900w, /static/img/docs/prometheus/use-function-by-label-9-5.png?w=1040 1040w, /static/img/docs/prometheus/use-function-by-label-9-5.png?w=1240 1240w, /static/img/docs/prometheus/use-function-by-label-9-5.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Functions and labels&#34;width=&#34;614&#34;height=&#34;429&#34;title=&#34;Functions and labels&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/prometheus/use-function-by-label-9-5.png&#34;
            alt=&#34;Functions and labels&#34;width=&#34;614&#34;height=&#34;429&#34;title=&#34;Functions and labels&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Functions and labels&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;If you add an operation in a way that would create an invalid query, the query editor automatically places it in the correct position to maintain a valid query structure.&lt;/p&gt;
&lt;h3 id=&#34;hints&#34;&gt;Hints&lt;/h3&gt;
&lt;p&gt;The query editor can detect which operations are most appropriate for certain selected metrics. When it does, it displays a hint next to the &lt;strong&gt;&#43; Operations&lt;/strong&gt; button. Click the hint to add the suggested operation.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 500px;&#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;/static/img/docs/prometheus/hint-example.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;/static/img/docs/prometheus/hint-example.png&#34;data-srcset=&#34;/static/img/docs/prometheus/hint-example.png?w=320 320w, /static/img/docs/prometheus/hint-example.png?w=550 550w, /static/img/docs/prometheus/hint-example.png?w=750 750w, /static/img/docs/prometheus/hint-example.png?w=900 900w, /static/img/docs/prometheus/hint-example.png?w=1040 1040w, /static/img/docs/prometheus/hint-example.png?w=1240 1240w, /static/img/docs/prometheus/hint-example.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Hint&#34;width=&#34;655&#34;height=&#34;197&#34;title=&#34;Hint&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/prometheus/hint-example.png&#34;
            alt=&#34;Hint&#34;width=&#34;655&#34;height=&#34;197&#34;title=&#34;Hint&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Hint&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;metrics-explorer&#34;&gt;Metrics explorer&lt;/h3&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 500px;&#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;/static/img/docs/prometheus/screenshot-grafana-prometheus-metrics-explorer-2.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;/static/img/docs/prometheus/screenshot-grafana-prometheus-metrics-explorer-2.png&#34;data-srcset=&#34;/static/img/docs/prometheus/screenshot-grafana-prometheus-metrics-explorer-2.png?w=320 320w, /static/img/docs/prometheus/screenshot-grafana-prometheus-metrics-explorer-2.png?w=550 550w, /static/img/docs/prometheus/screenshot-grafana-prometheus-metrics-explorer-2.png?w=750 750w, /static/img/docs/prometheus/screenshot-grafana-prometheus-metrics-explorer-2.png?w=900 900w, /static/img/docs/prometheus/screenshot-grafana-prometheus-metrics-explorer-2.png?w=1040 1040w, /static/img/docs/prometheus/screenshot-grafana-prometheus-metrics-explorer-2.png?w=1240 1240w, /static/img/docs/prometheus/screenshot-grafana-prometheus-metrics-explorer-2.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Metrics explorer&#34;width=&#34;1322&#34;height=&#34;643&#34;title=&#34;Metrics explorer&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/prometheus/screenshot-grafana-prometheus-metrics-explorer-2.png&#34;
            alt=&#34;Metrics explorer&#34;width=&#34;1322&#34;height=&#34;643&#34;title=&#34;Metrics explorer&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Metrics explorer&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Click the book icon next to the metric selector to open the Metrics explorer. It displays all metrics in a paginated list showing the name, type, and description for each metric.&lt;/p&gt;
&lt;p&gt;The following options are available under &lt;strong&gt;Additional Settings&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Include description in search&lt;/strong&gt; — Search by both name and description.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Include results with no metadata&lt;/strong&gt; — Include metrics that lack type or description metadata.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Disable text wrap&lt;/strong&gt; — Disable text wrapping for long metric names.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Enable regex search&lt;/strong&gt; — Filter metric names by regular expression, which uses an additional API call.&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;The Metrics explorer (Builder mode) and &lt;a href=&#34;#metrics-browser&#34;&gt;Metrics browser (Code mode)&lt;/a&gt; are separate components. The Metrics explorer does not browse labels, but the Metrics browser can display all labels on a metric.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;code-mode&#34;&gt;Code mode&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Code mode&lt;/strong&gt; is for experienced Prometheus users who prefer writing PromQL directly. For more information about PromQL, see &lt;a href=&#34;http://prometheus.io/docs/querying/basics/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Querying Prometheus&lt;/a&gt;.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 500px;&#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;/static/img/docs/prometheus/code-mode.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;/static/img/docs/prometheus/code-mode.png&#34;data-srcset=&#34;/static/img/docs/prometheus/code-mode.png?w=320 320w, /static/img/docs/prometheus/code-mode.png?w=550 550w, /static/img/docs/prometheus/code-mode.png?w=750 750w, /static/img/docs/prometheus/code-mode.png?w=900 900w, /static/img/docs/prometheus/code-mode.png?w=1040 1040w, /static/img/docs/prometheus/code-mode.png?w=1240 1240w, /static/img/docs/prometheus/code-mode.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Code mode&#34;width=&#34;1688&#34;height=&#34;171&#34;title=&#34;Code mode&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/prometheus/code-mode.png&#34;
            alt=&#34;Code mode&#34;width=&#34;1688&#34;height=&#34;171&#34;title=&#34;Code mode&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Code mode&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Code mode provides:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Autocomplete&lt;/strong&gt; — Suggests metrics, labels, functions, aggregations, and keywords as you type. The drop-down includes documentation for suggested items where available.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Syntax highlighting&lt;/strong&gt; — Color-codes PromQL syntax for readability.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Metrics browser&lt;/strong&gt; — Click the arrow next to &lt;strong&gt;Metrics browser&lt;/strong&gt; to open it.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;metrics-browser&#34;&gt;Metrics browser&lt;/h3&gt;
&lt;p&gt;The Metrics browser helps you build basic queries by exploring available metrics and labels.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 1335px;&#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/prometheus/Metrics-browser-V10-prom-query-editor.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/prometheus/Metrics-browser-V10-prom-query-editor.png&#34;data-srcset=&#34;/media/docs/prometheus/Metrics-browser-V10-prom-query-editor.png?w=320 320w, /media/docs/prometheus/Metrics-browser-V10-prom-query-editor.png?w=550 550w, /media/docs/prometheus/Metrics-browser-V10-prom-query-editor.png?w=750 750w, /media/docs/prometheus/Metrics-browser-V10-prom-query-editor.png?w=900 900w, /media/docs/prometheus/Metrics-browser-V10-prom-query-editor.png?w=1040 1040w, /media/docs/prometheus/Metrics-browser-V10-prom-query-editor.png?w=1240 1240w, /media/docs/prometheus/Metrics-browser-V10-prom-query-editor.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Prometheus query editor metrics browser&#34;width=&#34;1335&#34;height=&#34;675&#34;title=&#34;Metrics browser&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/prometheus/Metrics-browser-V10-prom-query-editor.png&#34;
            alt=&#34;Prometheus query editor metrics browser&#34;width=&#34;1335&#34;height=&#34;675&#34;title=&#34;Metrics browser&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Metrics browser&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Step 1&lt;/strong&gt; — Select a metric. The browser narrows available labels to those applicable to the metric.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Step 2&lt;/strong&gt; — Select one or more labels.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Step 3&lt;/strong&gt; — Select values for each label to tighten the query scope.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Step 4&lt;/strong&gt; — Choose an action:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use query&lt;/strong&gt; — Insert the selector into the query editor.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use as rate query&lt;/strong&gt; — Insert the selector wrapped in &lt;code&gt;rate(...[$__rate_interval])&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Validate selector&lt;/strong&gt; — Verify the selector is valid and display the number of matching series.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Clear&lt;/strong&gt; — Reset your selections.&lt;/li&gt;
&lt;/ul&gt;
&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;If you don&amp;rsquo;t remember the exact metric name, start by selecting a few labels to filter the list and narrow down your options.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;All lists in the Metrics browser include a search field. In the &lt;strong&gt;Values&lt;/strong&gt; section, a single search field filters across all selected labels.&lt;/p&gt;
&lt;h2 id=&#34;common-query-patterns&#34;&gt;Common query patterns&lt;/h2&gt;
&lt;p&gt;The following examples show frequently used PromQL patterns. Each example includes the PromQL expression and guidance on which query options to use.&lt;/p&gt;
&lt;h3 id=&#34;request-rate-per-service&#34;&gt;Request rate per service&lt;/h3&gt;
&lt;p&gt;Calculate the per-second rate of HTTP requests, broken down by service:&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;promql&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-promql&#34;&gt;sum(rate(http_requests_total[$__rate_interval])) by (service)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&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;Option&lt;/th&gt;
              &lt;th&gt;Setting&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Legend&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{service}}&lt;/code&gt; (Custom)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Type&lt;/td&gt;
              &lt;td&gt;Range&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Min step&lt;/td&gt;
              &lt;td&gt;Leave empty (uses &lt;code&gt;$__interval&lt;/code&gt;)&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;&lt;strong&gt;Builder mode steps:&lt;/strong&gt; Select &lt;code&gt;http_requests_total&lt;/code&gt; → Add operation &lt;strong&gt;Range functions &amp;gt; Rate&lt;/strong&gt; → Add operation &lt;strong&gt;Aggregations &amp;gt; Sum&lt;/strong&gt; → Set &lt;code&gt;by&lt;/code&gt; label to &lt;code&gt;service&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;error-rate-percentage&#34;&gt;Error rate percentage&lt;/h3&gt;
&lt;p&gt;Calculate the percentage of requests that returned 5xx errors:&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;promql&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-promql&#34;&gt;sum(rate(http_requests_total{status=~&amp;#34;5..&amp;#34;}[$__rate_interval])) / sum(rate(http_requests_total[$__rate_interval])) * 100&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&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;Option&lt;/th&gt;
              &lt;th&gt;Setting&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Legend&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;Error rate %&lt;/code&gt; (Custom)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Type&lt;/td&gt;
              &lt;td&gt;Range&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Format&lt;/td&gt;
              &lt;td&gt;Time series&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;histogram-quantile-p95-latency&#34;&gt;Histogram quantile (p95 latency)&lt;/h3&gt;
&lt;p&gt;Calculate the 95th percentile request duration from a histogram metric:&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;promql&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-promql&#34;&gt;histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[$__rate_interval])) by (le))&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&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;Option&lt;/th&gt;
              &lt;th&gt;Setting&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Legend&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;p95 latency&lt;/code&gt; (Custom)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Type&lt;/td&gt;
              &lt;td&gt;Range&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;&lt;strong&gt;Builder mode steps:&lt;/strong&gt; Select &lt;code&gt;http_request_duration_seconds_bucket&lt;/code&gt; → Add &lt;strong&gt;Range functions &amp;gt; Rate&lt;/strong&gt; → Add &lt;strong&gt;Aggregations &amp;gt; Sum&lt;/strong&gt; with &lt;code&gt;by&lt;/code&gt; label &lt;code&gt;le&lt;/code&gt; → Add &lt;strong&gt;Functions &amp;gt; Histogram quantile&lt;/strong&gt; with value &lt;code&gt;0.95&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;aggregation-by-label-cpu-usage-per-instance&#34;&gt;Aggregation by label (CPU usage per instance)&lt;/h3&gt;
&lt;p&gt;Calculate average CPU usage percentage, grouped by instance:&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;promql&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-promql&#34;&gt;100 - (avg by (instance) (rate(node_cpu_seconds_total{mode=&amp;#34;idle&amp;#34;}[$__rate_interval])) * 100)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&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;Option&lt;/th&gt;
              &lt;th&gt;Setting&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Legend&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{instance}}&lt;/code&gt; (Custom)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Type&lt;/td&gt;
              &lt;td&gt;Range&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Min step&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;15s&lt;/code&gt; (match your scrape interval)&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;multi-query-expressions-available-memory-percentage&#34;&gt;Multi-query expressions (available memory percentage)&lt;/h3&gt;
&lt;p&gt;Use multiple queries and expressions to calculate derived values. In the query editor, add multiple queries (A, B) and a math expression (C):&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Query A&lt;/strong&gt; — Total memory:&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;promql&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-promql&#34;&gt;node_memory_MemTotal_bytes&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Query B&lt;/strong&gt; — Available memory:&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;promql&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-promql&#34;&gt;node_memory_MemAvailable_bytes&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Expression C&lt;/strong&gt; — Percentage available (click &lt;strong&gt;&#43; Expression&lt;/strong&gt; → &lt;strong&gt;Math&lt;/strong&gt;):&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;$B / $A * 100&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Set queries A and B to &lt;strong&gt;Type: Instant&lt;/strong&gt; and hide them from visualization (click the eye icon). Display only expression C.&lt;/p&gt;
&lt;h3 id=&#34;alert-compatible-query-target-down&#34;&gt;Alert-compatible query (target down)&lt;/h3&gt;
&lt;p&gt;A simple alert query that fires when a scrape target is down:&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;promql&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-promql&#34;&gt;up{job=&amp;#34;my-service&amp;#34;} == 0&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&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;Option&lt;/th&gt;
              &lt;th&gt;Setting&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Type&lt;/td&gt;
              &lt;td&gt;Both&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Format&lt;/td&gt;
              &lt;td&gt;Time series&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&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;Alert queries don&amp;rsquo;t support template variables (&lt;code&gt;$variable&lt;/code&gt;). Use fixed label values when writing queries intended for alert rules.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;use-the-query-inspector&#34;&gt;Use the query inspector&lt;/h2&gt;
&lt;p&gt;The query inspector helps you debug queries that return unexpected results or no data. To open it:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;Query inspector&lt;/strong&gt; in the panel edit view (below the query editor).&lt;/li&gt;
&lt;li&gt;Review the following tabs:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Query&lt;/strong&gt; — Shows the exact request sent to Prometheus, including the evaluated PromQL expression, time range, and step interval. Use this to verify that template variables resolved correctly.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data&lt;/strong&gt; — Shows the raw response data. If empty, your query matched no series.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stats&lt;/strong&gt; — Shows request timing and response size.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Common debugging steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;No data returned&lt;/strong&gt; — Check the Query tab to see if template variables resolved to empty values. Try the query directly in the Prometheus built-in expression browser (&lt;code&gt;/graph&lt;/code&gt;) to rule out Grafana-specific issues.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fewer series than expected&lt;/strong&gt; — Check that your label filters aren&amp;rsquo;t too restrictive. Remove filters one at a time to isolate which filter is excluding data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&amp;ldquo;Too many data points&amp;rdquo; or timeout&lt;/strong&gt; — Reduce the time range, increase the Min step, or add aggregations to reduce cardinality. Refer to &lt;a href=&#34;#query-high-cardinality-data&#34;&gt;Query high-cardinality data&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;query-high-cardinality-data&#34;&gt;Query high-cardinality data&lt;/h2&gt;
&lt;p&gt;High-cardinality metrics (those with many unique label combinations) can cause queries to timeout or exceed memory limits when queried over long time ranges. Follow these practices to query high-cardinality data effectively:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Aggregate first, then filter&lt;/strong&gt; — Use &lt;code&gt;sum()&lt;/code&gt;, &lt;code&gt;avg()&lt;/code&gt;, or &lt;code&gt;count()&lt;/code&gt; to reduce the number of series before applying other operations. For example, &lt;code&gt;sum(rate(metric[5m])) by (service)&lt;/code&gt; is far cheaper than querying all individual pod-level series.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use recording rules for repeated queries&lt;/strong&gt; — If a dashboard panel queries the same expensive expression on every load, create a &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus recording rule&lt;/a&gt; to pre-compute the result.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scope with template variables&lt;/strong&gt; — Use dashboard 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/template-variables/&#34;&gt;template variables&lt;/a&gt; to select a specific &lt;code&gt;namespace&lt;/code&gt;, &lt;code&gt;cluster&lt;/code&gt;, or &lt;code&gt;job&lt;/code&gt; rather than querying all labels at once.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Increase Min step for overview panels&lt;/strong&gt; — For panels showing trends over days or weeks, set a higher &lt;strong&gt;Min step&lt;/strong&gt; (for example, &lt;code&gt;5m&lt;/code&gt; or &lt;code&gt;15m&lt;/code&gt;) to reduce the number of data points requested.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Set Max data points&lt;/strong&gt; — Use the &lt;strong&gt;Max data points&lt;/strong&gt; query option to cap resolution for wide time ranges.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use Adaptive Metrics (Grafana Cloud)&lt;/strong&gt; — &lt;a href=&#34;/docs/grafana-cloud/cost-management-and-billing/reduce-costs/metrics-costs/control-metrics-usage-via-adaptive-metrics/&#34;&gt;Adaptive Metrics&lt;/a&gt; automatically reduces the cardinality of metrics that aren&amp;rsquo;t queried at full resolution.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If your queries hit memory or sample limits, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/troubleshooting/#memory-limit-exceeded-for-high-cardinality-queries&#34;&gt;Memory limit exceeded for high-cardinality queries&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;expected-promql-behaviors&#34;&gt;Expected PromQL behaviors&lt;/h2&gt;
&lt;p&gt;The following behaviors are frequently misinterpreted as bugs but are expected Prometheus behavior.&lt;/p&gt;
&lt;h3 id=&#34;increase-returns-fractional-values-on-integer-counters&#34;&gt;&lt;code&gt;increase()&lt;/code&gt; returns fractional values on integer counters&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;increase()&lt;/code&gt; uses linear interpolation to estimate the increase over the specified time window. Because scrape timestamps rarely align exactly with the window boundaries, the result is interpolated — which produces fractional values even for integer counters.&lt;/p&gt;
&lt;p&gt;This is expected. If you need integer results, wrap the expression in &lt;code&gt;ceil()&lt;/code&gt; or &lt;code&gt;floor()&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;promql&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-promql&#34;&gt;ceil(increase(http_requests_total[5m]))&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;rate-appears-to-grow-over-time&#34;&gt;&lt;code&gt;rate()&lt;/code&gt; appears to grow over time&lt;/h3&gt;
&lt;p&gt;If &lt;code&gt;rate()&lt;/code&gt; shows an ever-increasing value instead of a steady per-second rate, the most common cause is multiple instances writing to the same time series without unique distinguishing labels. Prometheus merges these into a single series with an artificially growing counter.&lt;/p&gt;
&lt;p&gt;To fix this, ensure every scrape target has unique labels (for example, &lt;code&gt;instance&lt;/code&gt;, &lt;code&gt;pod&lt;/code&gt;, or &lt;code&gt;node&lt;/code&gt;). Then aggregate explicitly:&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;promql&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-promql&#34;&gt;sum(rate(http_requests_total[5m])) by (job)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you see this after a deployment or scaling event, verify your service discovery is assigning unique &lt;code&gt;instance&lt;/code&gt; labels to each target.&lt;/p&gt;
&lt;h3 id=&#34;counter-reset-spikes-after-pod-restarts&#34;&gt;Counter reset spikes after pod restarts&lt;/h3&gt;
&lt;p&gt;When a monitored process restarts, its counters reset to zero. Prometheus handles this with counter reset detection — &lt;code&gt;rate()&lt;/code&gt; and &lt;code&gt;increase()&lt;/code&gt; account for resets and don&amp;rsquo;t produce negative values. However, you may still see a brief spike at the reset point because the first scrape after a restart reports the full counter value accumulated since the restart.&lt;/p&gt;
&lt;p&gt;To minimize the visual impact:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;rate()&lt;/code&gt; over a window that spans multiple scrape intervals (for example, &lt;code&gt;$__rate_interval&lt;/code&gt;) so the spike is averaged out.&lt;/li&gt;
&lt;li&gt;For critical dashboards, apply smoothing with a longer range vector or use &lt;code&gt;avg_over_time()&lt;/code&gt; on top of &lt;code&gt;rate()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If you&amp;rsquo;re seeing large spikes from frequent pod restarts, investigate the restart frequency rather than trying to hide the spikes in queries.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;label-cardinality-causes-too-many-time-series-errors&#34;&gt;Label cardinality causes &amp;ldquo;too many time series&amp;rdquo; errors&lt;/h3&gt;
&lt;p&gt;If adding a label filter doesn&amp;rsquo;t reduce the result count, you may have high-cardinality labels (such as &lt;code&gt;request_id&lt;/code&gt; or &lt;code&gt;user_id&lt;/code&gt;) on your metrics. Use the Prometheus TSDB status page (&lt;code&gt;/tsdb-status&lt;/code&gt;) or the Grafana Metrics explorer to identify high-cardinality label combinations, then either drop unnecessary labels at scrape time or use aggregation in your queries.&lt;/p&gt;
&lt;h2 id=&#34;related-resources&#34;&gt;Related resources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/template-variables/&#34;&gt;Template variables&lt;/a&gt; — Use variables like &lt;code&gt;$namespace&lt;/code&gt; or &lt;code&gt;$job&lt;/code&gt; to create dynamic, reusable dashboards.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/annotations/&#34;&gt;Annotations&lt;/a&gt; — Overlay Prometheus events on your panels.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/alerting/&#34;&gt;Alerting&lt;/a&gt; — Create alert rules from your Prometheus queries.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/troubleshooting/&#34;&gt;Troubleshooting&lt;/a&gt; — Resolve common query errors and performance issues.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="prometheus-query-editor">Prometheus query editor&lt;/h1>
&lt;p>The Prometheus query editor lets you write PromQL queries against your Prometheus-compatible data sources. It includes a visual query builder for constructing queries without writing PromQL, a code editor with autocomplete and syntax highlighting, and configurable output formats for different visualization types.&lt;/p></description></item><item><title>Prometheus template variables</title><link>https://grafana.com/docs/grafana/v13.1/datasources/prometheus/template-variables/</link><pubDate>Tue, 23 Jun 2026 13:06:40 +0000</pubDate><guid>https://grafana.com/docs/grafana/v13.1/datasources/prometheus/template-variables/</guid><content><![CDATA[&lt;h1 id=&#34;prometheus-template-variables&#34;&gt;Prometheus template variables&lt;/h1&gt;
&lt;p&gt;Template variables let you create dynamic, reusable dashboards by replacing hard-coded values (such as server names, namespaces, or job labels) with selectable variables. Grafana displays these variables as dropdown menus at the top of the dashboard, letting viewers change the displayed data without editing queries.&lt;/p&gt;
&lt;p&gt;For an introduction to templating and template variables, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/dashboards/variables/&#34;&gt;Templating&lt;/a&gt; and 
    &lt;a href=&#34;/docs/grafana/v13.1/dashboards/variables/add-template-variables/&#34;&gt;Add and manage variables&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;query-variable-types&#34;&gt;Query variable types&lt;/h2&gt;
&lt;p&gt;Query variables query Prometheus to populate dropdown values. When creating a query variable, select a Prometheus data source and choose a query type:&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;Query Type&lt;/th&gt;
              &lt;th&gt;Required inputs&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Example&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Label names&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;metric&lt;/code&gt; (optional)&lt;/td&gt;
              &lt;td&gt;Returns all label names, optionally filtered by metric regular expression.&lt;/td&gt;
              &lt;td&gt;Metric: &lt;code&gt;http_requests_total&lt;/code&gt; → returns &lt;code&gt;job&lt;/code&gt;, &lt;code&gt;instance&lt;/code&gt;, &lt;code&gt;method&lt;/code&gt;, &lt;code&gt;status&lt;/code&gt;, etc.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Label values&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;label&lt;/code&gt; (required), &lt;code&gt;metric&lt;/code&gt; (optional)&lt;/td&gt;
              &lt;td&gt;Returns values for a specific label, optionally filtered by metric.&lt;/td&gt;
              &lt;td&gt;Label: &lt;code&gt;job&lt;/code&gt;, Metric: &lt;code&gt;http_requests_total&lt;/code&gt; → returns &lt;code&gt;api-server&lt;/code&gt;, &lt;code&gt;web&lt;/code&gt;, &lt;code&gt;worker&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Metrics&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;metric&lt;/code&gt; (optional)&lt;/td&gt;
              &lt;td&gt;Returns metric names matching the specified regular expression.&lt;/td&gt;
              &lt;td&gt;Metric: &lt;code&gt;node_.*&lt;/code&gt; → returns &lt;code&gt;node_cpu_seconds_total&lt;/code&gt;, &lt;code&gt;node_memory_MemFree_bytes&lt;/code&gt;, etc.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Query result&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;query&lt;/code&gt; (required)&lt;/td&gt;
              &lt;td&gt;Runs a PromQL query and returns the results as variable values.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;query_result(up{job=&amp;quot;prometheus&amp;quot;})&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Series query&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;metric&lt;/code&gt;, &lt;code&gt;label&lt;/code&gt;, or both&lt;/td&gt;
              &lt;td&gt;Returns time series matching the specified metric and/or label selectors.&lt;/td&gt;
              &lt;td&gt;Metric: &lt;code&gt;http_requests_total&lt;/code&gt;, Label: &lt;code&gt;job=&amp;quot;api&amp;quot;&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Classic query&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;query string&lt;/td&gt;
              &lt;td&gt;&lt;em&gt;Deprecated.&lt;/em&gt; Legacy syntax using functions like &lt;code&gt;label_values(metric, label)&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;label_values(http_requests_total, job)&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;For details on metric names, label names, and label values, refer to the &lt;a href=&#34;http://prometheus.io/docs/concepts/data_model/#metric-names-and-labels&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus data model&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;query-type-examples&#34;&gt;Query type examples&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Label values — Populate a dropdown with all jobs:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a new variable with &lt;strong&gt;Type: Query&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select your Prometheus data source.&lt;/li&gt;
&lt;li&gt;Set &lt;strong&gt;Query type&lt;/strong&gt; to &lt;code&gt;Label values&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Set &lt;strong&gt;Label&lt;/strong&gt; to &lt;code&gt;job&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Leave &lt;strong&gt;Metric&lt;/strong&gt; empty to query across all metrics.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The variable dropdown now shows all unique &lt;code&gt;job&lt;/code&gt; label values.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Label values — Filtered by metric:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Set &lt;strong&gt;Label&lt;/strong&gt; to &lt;code&gt;instance&lt;/code&gt; and &lt;strong&gt;Metric&lt;/strong&gt; to &lt;code&gt;node_cpu_seconds_total&lt;/code&gt; to show only instances that report CPU metrics.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Metrics — Find available metrics by pattern:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Set &lt;strong&gt;Query type&lt;/strong&gt; to &lt;code&gt;Metrics&lt;/code&gt; and enter &lt;code&gt;http_.*_total&lt;/code&gt; in the &lt;strong&gt;Metric&lt;/strong&gt; field to populate the dropdown with all HTTP counter metrics.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Query result — Dynamic top-N filtering:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Set &lt;strong&gt;Query type&lt;/strong&gt; to &lt;code&gt;Query result&lt;/code&gt; and enter:&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;promql&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-promql&#34;&gt;query_result(topk(5, sum(rate(http_requests_total[$__range])) by (instance)))&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Set &lt;strong&gt;Regex&lt;/strong&gt; to &lt;code&gt;/&amp;quot;([^&amp;quot;]&#43;)&amp;quot;/&lt;/code&gt; to extract the instance values from the result.&lt;/p&gt;
&lt;p&gt;Set &lt;strong&gt;Refresh&lt;/strong&gt; to &lt;code&gt;On time range change&lt;/code&gt; so the top 5 instances update as you change the dashboard time range.&lt;/p&gt;
&lt;h3 id=&#34;query-options&#34;&gt;Query options&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Option&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;strong&gt;Data source&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;The Prometheus data source to query.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Regex&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Optional regular expression to extract a portion of the returned values. Use capture groups — for example, &lt;code&gt;/.*instance=&amp;quot;([^&amp;quot;]&#43;)&amp;quot;.*/&lt;/code&gt; extracts the instance label value from a series string.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Sort&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Sort order for dropdown values: &lt;code&gt;Disabled&lt;/code&gt;, &lt;code&gt;Alphabetical (asc)&lt;/code&gt;, &lt;code&gt;Alphabetical (desc)&lt;/code&gt;, &lt;code&gt;Numerical (asc)&lt;/code&gt;, &lt;code&gt;Numerical (desc)&lt;/code&gt;, &lt;code&gt;Alphabetical (case-insensitive, asc)&lt;/code&gt;, &lt;code&gt;Alphabetical (case-insensitive, desc)&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Refresh&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;When to update values: &lt;code&gt;On dashboard load&lt;/code&gt; or &lt;code&gt;On time range change&lt;/code&gt;. Use &lt;code&gt;On time range change&lt;/code&gt; for variables that depend on &lt;code&gt;$__range&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;selection-options&#34;&gt;Selection options&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Multi-value&lt;/strong&gt; — Allows selecting multiple values at once. Grafana joins them with a pipe (&lt;code&gt;|&lt;/code&gt;) for regular expression matching.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Include All option&lt;/strong&gt; — Adds an &amp;ldquo;All&amp;rdquo; option that selects every value. Combined with multi-value, this generates a regular expression like &lt;code&gt;value1|value2|value3&lt;/code&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;When &lt;strong&gt;Multi-value&lt;/strong&gt; or &lt;strong&gt;Include All&lt;/strong&gt; is enabled, use &lt;code&gt;=~&lt;/code&gt; (regular expression match) instead of &lt;code&gt;=&lt;/code&gt; (exact match) in your queries, since the variable value becomes a regex pattern.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Example with multi-value:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;promql&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-promql&#34;&gt;rate(http_requests_total{job=~&amp;#34;$job&amp;#34;}[$__rate_interval])&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;use-interval-and-range-variables&#34;&gt;Use interval and range variables&lt;/h3&gt;
&lt;p&gt;You can use global built-in variables in query variable definitions:&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;Variable&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;$__interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Calculated interval based on time range and panel width.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__interval_ms&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as &lt;code&gt;$__interval&lt;/code&gt; in milliseconds.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__range&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Duration of the current dashboard time range (for example, &lt;code&gt;1h&lt;/code&gt;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__range_s&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Duration in seconds.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__range_ms&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Duration in milliseconds.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;For details, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/dashboards/variables/add-template-variables/#global-variables&#34;&gt;Global built-in variables&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;label_values&lt;/code&gt; function (Classic query type) doesn&amp;rsquo;t support these variables. Use &lt;code&gt;Query result&lt;/code&gt; type with &lt;code&gt;query_result()&lt;/code&gt; instead:&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;promql&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-promql&#34;&gt;query_result(max_over_time(up{job=&amp;#34;$job&amp;#34;}[${__range_s}s]) == 1)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Set the variable&amp;rsquo;s &lt;strong&gt;Refresh&lt;/strong&gt; to &lt;code&gt;On time range change&lt;/code&gt; to update values when the time range changes.&lt;/p&gt;
&lt;!-- vale Grafana.Spelling = NO --&gt;
&lt;h2 id=&#34;use-__rate_interval&#34;&gt;Use &lt;code&gt;$__rate_interval&lt;/code&gt;&lt;/h2&gt;
&lt;!-- vale Grafana.Spelling = YES --&gt;
&lt;p&gt;&lt;code&gt;$__rate_interval&lt;/code&gt; is a Grafana-specific variable designed for use with &lt;code&gt;rate()&lt;/code&gt; and &lt;code&gt;increase()&lt;/code&gt;. It guarantees a range window large enough to capture at least four scrape samples, preventing gaps or inaccuracies in results.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Always use &lt;code&gt;$__rate_interval&lt;/code&gt; instead of a fixed interval or &lt;code&gt;$__interval&lt;/code&gt;:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;promql&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-promql&#34;&gt;rate(http_requests_total[$__rate_interval])&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Not:&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;promql&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-promql&#34;&gt;rate(http_requests_total[5m])       # breaks at different zoom levels
rate(http_requests_total[$__interval])  # can be too small for rate()&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- vale Grafana.Spelling = NO --&gt;
&lt;h3 id=&#34;how-__rate_interval-is-calculated&#34;&gt;How &lt;code&gt;$__rate_interval&lt;/code&gt; is calculated&lt;/h3&gt;
&lt;!-- vale Grafana.Spelling = YES --&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;max($__interval &amp;#43; scrape_interval, 4 * scrape_interval)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Where &lt;code&gt;scrape_interval&lt;/code&gt; is:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The per-query &lt;strong&gt;Min step&lt;/strong&gt; setting, if set.&lt;/li&gt;
&lt;li&gt;Otherwise, the data source&amp;rsquo;s &lt;strong&gt;Scrape interval&lt;/strong&gt; setting (under Interval behavior in the data source configuration).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The panel-level &lt;code&gt;min interval&lt;/code&gt; is affected by the resolution setting and doesn&amp;rsquo;t factor into this calculation.&lt;/p&gt;
&lt;!-- vale Grafana.Spelling = NO --&gt;
&lt;h3 id=&#34;configure-__rate_interval-correctly&#34;&gt;Configure &lt;code&gt;$__rate_interval&lt;/code&gt; correctly&lt;/h3&gt;
&lt;!-- vale Grafana.Spelling = YES --&gt;
&lt;p&gt;For &lt;code&gt;$__rate_interval&lt;/code&gt; to produce reliable results, the scrape interval must match your actual Prometheus scrape configuration:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the Prometheus data source configuration.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Interval behavior&lt;/strong&gt;, set the &lt;strong&gt;Scrape interval&lt;/strong&gt; to match the &lt;code&gt;scrape_interval&lt;/code&gt; in your Prometheus configuration file (for example, &lt;code&gt;30s&lt;/code&gt; or &lt;code&gt;1m&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;If different targets have different scrape intervals, set the data source scrape interval to the &lt;strong&gt;longest&lt;/strong&gt; interval in use, or use the per-query &lt;strong&gt;Min step&lt;/strong&gt; to override on specific panels.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;common-pitfalls&#34;&gt;Common pitfalls&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Missing or incorrect scrape interval setting:&lt;/strong&gt; If the data source scrape interval is left at the default &lt;code&gt;15s&lt;/code&gt; but your actual Prometheus scrape interval is &lt;code&gt;60s&lt;/code&gt;, &lt;code&gt;$__rate_interval&lt;/code&gt; calculates too small a window. This causes &lt;code&gt;rate()&lt;/code&gt; to return no data because there aren&amp;rsquo;t enough data points in the window.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Different values in edit mode versus dashboard:&lt;/strong&gt; When editing a query, the panel displays at full width. On the dashboard, the panel may be narrower, which increases &lt;code&gt;$__interval&lt;/code&gt; and therefore &lt;code&gt;$__rate_interval&lt;/code&gt;. Queries that work in edit mode may produce different results (or gaps) on the dashboard.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;LBAC-enabled data sources:&lt;/strong&gt; Data sources using Label-Based Access Control (LBAC) may not inherit the scrape interval setting from the parent data source. Set the &lt;strong&gt;Min step&lt;/strong&gt; explicitly on each query panel to ensure a correct &lt;code&gt;$__rate_interval&lt;/code&gt; calculation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Recording rules with fixed intervals:&lt;/strong&gt; If you use &lt;code&gt;$__rate_interval&lt;/code&gt; in a recording rule query, the interval depends on the evaluation context. For recording rules, use a fixed interval (for example, &lt;code&gt;[5m]&lt;/code&gt;) rather than &lt;code&gt;$__rate_interval&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For troubleshooting &lt;code&gt;$__rate_interval&lt;/code&gt; issues, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/troubleshooting/#rate_interval-returns-no-data-or-incorrect-values&#34;&gt;&lt;code&gt;$__rate_interval&lt;/code&gt; returns no data or incorrect values&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For additional background, refer to &lt;a href=&#34;/blog/2020/09/28/new-in-grafana-7.2-__rate_interval-for-prometheus-rate-queries-that-just-work/&#34;&gt;$__rate_interval for Prometheus rate queries that just work&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;variable-syntax&#34;&gt;Variable syntax&lt;/h2&gt;
&lt;p&gt;The Prometheus data source supports three variable syntaxes:&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;Syntax&lt;/th&gt;
              &lt;th&gt;Example&lt;/th&gt;
              &lt;th&gt;Use case&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$varname&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;rate(http_requests_total{job=~&amp;quot;$job&amp;quot;}[$__rate_interval])&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Simple, readable. Cannot be used mid-word.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;${varname}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;rate(http_requests_total{job=~&amp;quot;${job}&amp;quot;}[$__rate_interval])&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Use when the variable is adjacent to other text (for example, &lt;code&gt;${env}-cluster&lt;/code&gt;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;[[varname]]&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;rate(http_requests_total{job=~&amp;quot;[[job]]&amp;quot;}[$__rate_interval])&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Legacy syntax. Supported for backward compatibility.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&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;If &lt;strong&gt;Multi-value&lt;/strong&gt; or &lt;strong&gt;Include All&lt;/strong&gt; is enabled, the variable value becomes a regular expression pattern (for example, &lt;code&gt;value1|value2&lt;/code&gt;). Use &lt;code&gt;=~&lt;/code&gt; instead of &lt;code&gt;=&lt;/code&gt; in your label matchers.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;filters-variable&#34;&gt;Filters variable&lt;/h2&gt;
&lt;p&gt;Prometheus supports the 
    &lt;a href=&#34;/docs/grafana/v13.1/dashboards/variables/add-template-variables/#add-ad-hoc-filters&#34;&gt;Filters&lt;/a&gt; variable type (formerly called &amp;ldquo;ad hoc filters&amp;rdquo;), which lets dashboard viewers dynamically add label filters without editing queries.&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;The &lt;strong&gt;Filter and Group by&lt;/strong&gt; feature extends the Filters variable by adding grouping support for Prometheus and Loki data sources. For more information, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/visualizations/dashboards/build-dashboards/filter-group-by/&#34;&gt;Filter and Group by&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;To set up a Filters variable:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a new variable with &lt;strong&gt;Type: Filters&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select your Prometheus data source.&lt;/li&gt;
&lt;li&gt;Save the dashboard.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;After you add the variable, a filter bar appears at the top of the dashboard. Viewers can add filters by selecting a label, operator (&lt;code&gt;=&lt;/code&gt;, &lt;code&gt;!=&lt;/code&gt;, &lt;code&gt;=~&lt;/code&gt;, &lt;code&gt;!~&lt;/code&gt;), and value. Grafana automatically applies these filters to &lt;strong&gt;all&lt;/strong&gt; Prometheus queries on the dashboard.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; A viewer adds the filter &lt;code&gt;namespace = production&lt;/code&gt;. All queries on the dashboard now include &lt;code&gt;{namespace=&amp;quot;production&amp;quot;}&lt;/code&gt; without any query modifications.&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;Filters are applied to all queries using the selected data source. You cannot selectively apply them to specific panels.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;related-resources&#34;&gt;Related resources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/query-editor/&#34;&gt;Query editor&lt;/a&gt; — Use variables in PromQL queries.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/annotations/&#34;&gt;Annotations&lt;/a&gt; — Use template variables in annotation queries.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/troubleshooting/&#34;&gt;Troubleshooting&lt;/a&gt; — Resolve variable-related query issues.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="prometheus-template-variables">Prometheus template variables&lt;/h1>
&lt;p>Template variables let you create dynamic, reusable dashboards by replacing hard-coded values (such as server names, namespaces, or job labels) with selectable variables. Grafana displays these variables as dropdown menus at the top of the dashboard, letting viewers change the displayed data without editing queries.&lt;/p></description></item><item><title>Prometheus annotations</title><link>https://grafana.com/docs/grafana/v13.1/datasources/prometheus/annotations/</link><pubDate>Tue, 23 Jun 2026 13:06:40 +0000</pubDate><guid>https://grafana.com/docs/grafana/v13.1/datasources/prometheus/annotations/</guid><content><![CDATA[&lt;h1 id=&#34;prometheus-annotations&#34;&gt;Prometheus annotations&lt;/h1&gt;
&lt;p&gt;Annotations overlay event data on your dashboard graphs, helping you correlate events with metrics. You can use Prometheus as a data source for annotations to display events such as deployments, alerts, or threshold crossings on your visualizations.&lt;/p&gt;
&lt;p&gt;For general information about annotations, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/dashboards/build-dashboards/annotate-visualizations/&#34;&gt;Annotate visualizations&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Before creating Prometheus annotations, ensure you have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A configured Prometheus data source in Grafana&lt;/li&gt;
&lt;li&gt;Metrics in Prometheus that represent the events you want to annotate&lt;/li&gt;
&lt;li&gt;Read access to the Prometheus instance&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;create-an-annotation-query&#34;&gt;Create an annotation query&lt;/h2&gt;
&lt;p&gt;To add a Prometheus annotation to your dashboard:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to your dashboard and click &lt;strong&gt;Dashboard settings&lt;/strong&gt; (gear icon).&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Annotations&lt;/strong&gt; in the left menu.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add annotation query&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;strong&gt;Name&lt;/strong&gt; for the annotation.&lt;/li&gt;
&lt;li&gt;Select your &lt;strong&gt;Prometheus&lt;/strong&gt; data source from the &lt;strong&gt;Data source&lt;/strong&gt; drop-down.&lt;/li&gt;
&lt;li&gt;Enter a PromQL expression in the query field.&lt;/li&gt;
&lt;li&gt;Set the &lt;strong&gt;Min step&lt;/strong&gt; to control annotation density (a larger step means fewer annotations).&lt;/li&gt;
&lt;li&gt;Configure the field mappings to control what appears in the annotation tooltip.&lt;/li&gt;
&lt;li&gt;Optionally, select a &lt;strong&gt;Color&lt;/strong&gt; for the annotation markers to distinguish different annotation types visually.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save dashboard&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;how-prometheus-annotations-work&#34;&gt;How Prometheus annotations work&lt;/h2&gt;
&lt;p&gt;Prometheus annotations work differently from SQL-based annotations. Instead of querying a table of events, you write a PromQL expression that returns time-series data. Grafana converts the query results into annotation events using these rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Grafana executes the PromQL query as a range query over the dashboard&amp;rsquo;s time window.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Every data point returned creates an annotation.&lt;/strong&gt; There is no automatic filtering of zero values — if you only want annotations at specific moments, your PromQL expression must filter the results (for example, using &lt;code&gt;&amp;gt; 0&lt;/code&gt; or the &lt;code&gt;ALERTS&lt;/code&gt; metric).&lt;/li&gt;
&lt;li&gt;Grafana uses the field mapping configuration to determine what text, title, and tags to display for each annotation.&lt;/li&gt;
&lt;li&gt;If the query returns multiple time series, each series produces its own set of annotations.&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;Because every returned data point creates an annotation, queries that return continuous data (like &lt;code&gt;node_cpu_seconds_total&lt;/code&gt;) will produce an annotation at every step interval, flooding your dashboard. Always use expressions that return data only at the moments you want annotated.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;field-mappings&#34;&gt;Field mappings&lt;/h2&gt;
&lt;p&gt;After entering your PromQL expression, use the field mapping drop-downs to control how query results are displayed as annotations. Grafana shows mapping options for:&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;Description&lt;/th&gt;
              &lt;th&gt;Default behavior&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Time&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;The timestamp for the annotation.&lt;/td&gt;
              &lt;td&gt;Uses the first time-type field (always present).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;TimeEnd&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;An end timestamp for range annotations, which display as a shaded region instead of a vertical line.&lt;/td&gt;
              &lt;td&gt;Not set (produces point annotations).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Title&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Short label displayed on the annotation marker.&lt;/td&gt;
              &lt;td&gt;Not set.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Text&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;The annotation description displayed when you hover over it.&lt;/td&gt;
              &lt;td&gt;Uses the first string-type field, or the metric/label display name if configured.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Tags&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Comma-separated tags for the annotation. Helps categorize and filter annotations.&lt;/td&gt;
              &lt;td&gt;Not set.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;To configure field mappings, select the appropriate field name from each drop-down, or enter a fixed text value.&lt;/p&gt;
&lt;h2 id=&#34;example-annotation-queries&#34;&gt;Example annotation queries&lt;/h2&gt;
&lt;p&gt;The following examples show common annotation patterns with Prometheus.&lt;/p&gt;
&lt;h3 id=&#34;alert-based-annotations-using-alerts&#34;&gt;Alert-based annotations using &lt;code&gt;ALERTS&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The most common and reliable way to create Prometheus annotations. Prometheus automatically generates an &lt;code&gt;ALERTS&lt;/code&gt; metric for all configured alerting 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;promql&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-promql&#34;&gt;ALERTS{alertstate=&amp;#34;firing&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This creates an annotation at every step interval where an alert is firing. The &lt;code&gt;ALERTS&lt;/code&gt; metric includes labels such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;alertname&lt;/code&gt; — The name of the alerting rule&lt;/li&gt;
&lt;li&gt;&lt;code&gt;alertstate&lt;/code&gt; — Either &lt;code&gt;firing&lt;/code&gt; or &lt;code&gt;pending&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Any labels defined on the alerting rule&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To limit to specific alerts or severity levels:&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;promql&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-promql&#34;&gt;ALERTS{alertname=&amp;#34;HighCPUUsage&amp;#34;, severity=&amp;#34;critical&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Configure the field mappings:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Text:&lt;/strong&gt; &lt;code&gt;alertname&lt;/code&gt; (displays the alert name on hover)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tags:&lt;/strong&gt; &lt;code&gt;severity&lt;/code&gt; (allows filtering by severity)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;service-restart-annotations&#34;&gt;Service restart annotations&lt;/h3&gt;
&lt;p&gt;Display annotations when a process restarts. The &lt;code&gt;changes()&lt;/code&gt; function detects when a value changes, and &lt;code&gt;&amp;gt; 0&lt;/code&gt; ensures annotations only appear at the moment of change:&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;promql&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-promql&#34;&gt;changes(process_start_time_seconds{job=&amp;#34;myservice&amp;#34;}[5m]) &amp;gt; 0&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;deployment-annotations&#34;&gt;Deployment annotations&lt;/h3&gt;
&lt;p&gt;If you track deployments by pushing a timestamp metric via &lt;code&gt;Pushgateway&lt;/code&gt; or a recording rule:&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;promql&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-promql&#34;&gt;changes(deployment_timestamp_seconds{environment=&amp;#34;production&amp;#34;}[10m]) &amp;gt; 0&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Configure the field mappings:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Text:&lt;/strong&gt; &lt;code&gt;environment&lt;/code&gt; (shows which environment was deployed)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tags:&lt;/strong&gt; &lt;code&gt;environment&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;threshold-crossing-annotations&#34;&gt;Threshold crossing annotations&lt;/h3&gt;
&lt;p&gt;Display annotations when available memory drops below 10%:&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;promql&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-promql&#34;&gt;node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes &amp;lt; 0.1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Comparison operators in PromQL act as filters — they only return data points where the condition is true. This means the expression above only returns data when memory is below 10%, and annotations only appear at those times. There&amp;rsquo;s no need to add an outer &lt;code&gt;&amp;gt; 0&lt;/code&gt; wrapper.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;scaling-event-annotations&#34;&gt;Scaling event annotations&lt;/h3&gt;
&lt;p&gt;Display annotations when the number of running pods changes:&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;promql&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-promql&#34;&gt;changes(kube_deployment_status_replicas{deployment=&amp;#34;my-app&amp;#34;}[5m]) &amp;gt; 0&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;error-spike-annotations&#34;&gt;Error spike annotations&lt;/h3&gt;
&lt;p&gt;Display annotations when the error rate exceeds a threshold:&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;promql&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-promql&#34;&gt;sum(rate(http_requests_total{status=~&amp;#34;5..&amp;#34;}[5m])) by (job) / sum(rate(http_requests_total[5m])) by (job) &amp;gt; 0.05&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This creates annotations when the error rate exceeds 5%.&lt;/p&gt;
&lt;h3 id=&#34;version-or-build-change-annotations&#34;&gt;Version or build change annotations&lt;/h3&gt;
&lt;p&gt;If you expose build metadata using a metric like &lt;code&gt;build_info&lt;/code&gt; (common in Go services), annotate when the version changes:&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;promql&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-promql&#34;&gt;changes(build_info{job=&amp;#34;myservice&amp;#34;}[10m]) &amp;gt; 0&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Configure the field mappings:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Text:&lt;/strong&gt; &lt;code&gt;version&lt;/code&gt; (shows the new version in the annotation tooltip)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tags:&lt;/strong&gt; &lt;code&gt;job&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If your build info metric uses a &lt;code&gt;version&lt;/code&gt; label (for example, &lt;code&gt;build_info{version=&amp;quot;1.2.3&amp;quot;}&lt;/code&gt;), the annotation tooltip displays the version that was deployed.&lt;/p&gt;
&lt;h2 id=&#34;control-annotation-density&#34;&gt;Control annotation density&lt;/h2&gt;
&lt;p&gt;The &lt;strong&gt;Min step&lt;/strong&gt; setting controls how many data points the query returns, which directly affects how many annotations appear. A larger step means fewer annotations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Min step &lt;code&gt;1m&lt;/code&gt;&lt;/strong&gt; — Up to one annotation per minute (good for short time ranges).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Min step &lt;code&gt;5m&lt;/code&gt;&lt;/strong&gt; — Up to one annotation per 5 minutes (good for day-range dashboards).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Min step &lt;code&gt;1h&lt;/code&gt;&lt;/strong&gt; — Up to one annotation per hour (good for week-range dashboards).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If your dashboard shows too many annotation markers, increase the Min step or add more specific filters to your query.&lt;/p&gt;
&lt;h2 id=&#34;use-template-variables-in-annotations&#34;&gt;Use template variables in annotations&lt;/h2&gt;
&lt;p&gt;You can use template variables in your annotation queries to filter annotations based on dashboard variable selections:&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;promql&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-promql&#34;&gt;ALERTS{alertstate=&amp;#34;firing&amp;#34;, instance=~&amp;#34;$instance&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;promql&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-promql&#34;&gt;changes(process_start_time_seconds{job=&amp;#34;$job&amp;#34;}[5m]) &amp;gt; 0&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Template variables in annotations are resolved at query time using the current dashboard variable values.&lt;/p&gt;
&lt;h2 id=&#34;range-annotations&#34;&gt;Range annotations&lt;/h2&gt;
&lt;p&gt;Range annotations display as shaded regions rather than vertical lines, representing events with duration. To create range annotations, the query result must include a &lt;strong&gt;TimeEnd&lt;/strong&gt; field mapping.&lt;/p&gt;
&lt;p&gt;Because PromQL doesn&amp;rsquo;t natively return start/end time pairs, range annotations with Prometheus are limited to scenarios where you have separate metrics for start and end times (for example, via recording rules or custom metrics pushed to &lt;code&gt;Pushgateway&lt;/code&gt;). For most use cases, point annotations (using the examples in this page) are the practical approach.&lt;/p&gt;
&lt;p&gt;If your annotations aren&amp;rsquo;t appearing or you encounter errors, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/troubleshooting/#annotation-errors&#34;&gt;Troubleshoot Prometheus data source issues&lt;/a&gt;.&lt;/p&gt;
]]></content><description>&lt;h1 id="prometheus-annotations">Prometheus annotations&lt;/h1>
&lt;p>Annotations overlay event data on your dashboard graphs, helping you correlate events with metrics. You can use Prometheus as a data source for annotations to display events such as deployments, alerts, or threshold crossings on your visualizations.&lt;/p></description></item><item><title>Prometheus alerting</title><link>https://grafana.com/docs/grafana/v13.1/datasources/prometheus/alerting/</link><pubDate>Tue, 23 Jun 2026 13:06:40 +0000</pubDate><guid>https://grafana.com/docs/grafana/v13.1/datasources/prometheus/alerting/</guid><content><![CDATA[&lt;h1 id=&#34;prometheus-alerting&#34;&gt;Prometheus alerting&lt;/h1&gt;
&lt;p&gt;You can use Grafana Alerting with Prometheus to create alerts based on your time-series data. This allows you to monitor metrics, detect anomalies, and receive notifications when specific conditions are met.&lt;/p&gt;
&lt;p&gt;For general information about Grafana Alerting, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/alerting/&#34;&gt;Grafana Alerting&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Before creating alerts with Prometheus, ensure you have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A Prometheus data source configured in Grafana&lt;/li&gt;
&lt;li&gt;Appropriate permissions to create alert rules&lt;/li&gt;
&lt;li&gt;Understanding of the PromQL metrics you want to monitor&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;alert-rule-types&#34;&gt;Alert rule types&lt;/h2&gt;
&lt;p&gt;Prometheus supports two alerting workflows in 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;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Grafana-managed alert rules&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Alert rules defined and evaluated within Grafana, using Prometheus as the query data source. You create and manage these entirely in the Grafana Alerting UI.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Data source-managed rules&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Alerting rules defined in Prometheus itself (in &lt;code&gt;prometheus.yml&lt;/code&gt; or rule files). When &lt;strong&gt;Manage alerts via Alerting UI&lt;/strong&gt; is enabled in the data source configuration, Grafana displays these existing rules in the Alerting UI. For Prometheus (unlike Mimir), this is read-only.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;create-a-grafana-managed-alert-rule&#34;&gt;Create a Grafana-managed alert rule&lt;/h2&gt;
&lt;p&gt;To create a Grafana-managed alert rule using Prometheus:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to &lt;strong&gt;Alerting&lt;/strong&gt; &amp;gt; &lt;strong&gt;Alert rules&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;New alert rule&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a name for the alert rule.&lt;/li&gt;
&lt;li&gt;Select your &lt;strong&gt;Prometheus&lt;/strong&gt; data source.&lt;/li&gt;
&lt;li&gt;Write a PromQL query in the query editor.&lt;/li&gt;
&lt;li&gt;Configure the alert condition (for example, when the last value is above a threshold).&lt;/li&gt;
&lt;li&gt;Set the evaluation interval and pending period.&lt;/li&gt;
&lt;li&gt;Configure notifications and labels.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save rule&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For detailed instructions, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/alerting/alerting-rules/create-grafana-managed-rule/&#34;&gt;Create a Grafana-managed alert rule&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;view-data-source-managed-rules&#34;&gt;View data source-managed rules&lt;/h2&gt;
&lt;p&gt;When &lt;strong&gt;Manage alerts via Alerting UI&lt;/strong&gt; is enabled in the Prometheus data source configuration, Grafana fetches and displays alerting rules defined in Prometheus. These appear in the Alerting UI alongside Grafana-managed rules but are marked as data source-managed.&lt;/p&gt;
&lt;p&gt;For Prometheus data sources, this view is read-only. To modify these rules, update your Prometheus rule files directly.&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;For Mimir and Cortex data sources, the Alerting UI supports both viewing and creating data source-managed rules. Prometheus only supports viewing.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;evaluation-groups-and-intervals&#34;&gt;Evaluation groups and intervals&lt;/h2&gt;
&lt;p&gt;Alert rules are organized into evaluation groups. Each group has an evaluation interval that determines how frequently the rules in that group are evaluated. For example, an evaluation interval of &lt;code&gt;1m&lt;/code&gt; means the alert query runs every 60 seconds.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;pending period&lt;/strong&gt; determines how long a condition must be continuously true before the alert fires. For example, with a 1-minute evaluation interval and a 5-minute pending period, the condition must be true for 5 consecutive evaluations before firing.&lt;/p&gt;
&lt;p&gt;Choose evaluation intervals based on your use case:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;15s–30s&lt;/strong&gt; — Critical infrastructure alerts where fast detection matters.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;1m&lt;/strong&gt; — Standard monitoring alerts (recommended default).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;5m&lt;/strong&gt; — Non-urgent or noisy metrics where you want to reduce evaluation load.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;example-alert-queries&#34;&gt;Example alert queries&lt;/h2&gt;
&lt;p&gt;The following examples show common alerting scenarios with Prometheus. Each example shows the PromQL query and how to configure the alert condition.&lt;/p&gt;
&lt;h3 id=&#34;alert-on-high-cpu-usage&#34;&gt;Alert on high CPU usage&lt;/h3&gt;
&lt;p&gt;Monitor CPU usage and alert when it exceeds 90%:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Query A:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;promql&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-promql&#34;&gt;100 - (avg by (instance) (rate(node_cpu_seconds_total{mode=&amp;#34;idle&amp;#34;}[$__rate_interval])) * 100)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Condition:&lt;/strong&gt; Set the threshold to alert when the last value of &lt;strong&gt;A&lt;/strong&gt; is above &lt;code&gt;90&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This approach separates the metric query from the threshold, making it easier to adjust the threshold later without editing the PromQL.&lt;/p&gt;
&lt;h3 id=&#34;alert-on-high-memory-usage&#34;&gt;Alert on high memory usage&lt;/h3&gt;
&lt;p&gt;Monitor memory usage across nodes:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Query A:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;promql&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-promql&#34;&gt;(1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Condition:&lt;/strong&gt; Alert when the last value of &lt;strong&gt;A&lt;/strong&gt; exceeds &lt;code&gt;85&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;alert-on-high-error-rate&#34;&gt;Alert on high error rate&lt;/h3&gt;
&lt;p&gt;Monitor HTTP error rates per service:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Query A:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;promql&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-promql&#34;&gt;sum(rate(http_requests_total{status=~&amp;#34;5..&amp;#34;}[$__rate_interval])) by (job)
  /
sum(rate(http_requests_total[$__rate_interval])) by (job)
  * 100&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Condition:&lt;/strong&gt; Alert when the last value of &lt;strong&gt;A&lt;/strong&gt; exceeds &lt;code&gt;5&lt;/code&gt; (meaning error rate above 5%).&lt;/p&gt;
&lt;h3 id=&#34;alert-on-target-down&#34;&gt;Alert on target down&lt;/h3&gt;
&lt;p&gt;Monitor whether Prometheus scrape targets are reachable:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Query A:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;promql&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-promql&#34;&gt;up{job=&amp;#34;myservice&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Condition:&lt;/strong&gt; Alert when the last value of &lt;strong&gt;A&lt;/strong&gt; is below &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;alert-when-a-metric-disappears&#34;&gt;Alert when a metric disappears&lt;/h3&gt;
&lt;p&gt;Use &lt;code&gt;absent()&lt;/code&gt; to detect when a metric stops being scraped entirely — for example, when a service crashes and no longer reports metrics:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Query A:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;promql&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-promql&#34;&gt;absent(up{job=&amp;#34;myservice&amp;#34;})&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Condition:&lt;/strong&gt; Alert when the last value of &lt;strong&gt;A&lt;/strong&gt; equals &lt;code&gt;1&lt;/code&gt; (the &lt;code&gt;absent()&lt;/code&gt; function returns 1 when the metric is missing, and nothing when the metric exists).&lt;/p&gt;
&lt;p&gt;For detecting staleness over a time window (metric exists but hasn&amp;rsquo;t reported recently):&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;promql&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-promql&#34;&gt;absent_over_time(up{job=&amp;#34;myservice&amp;#34;}[5m])&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;multi-condition-alert-high-latency-and-high-traffic&#34;&gt;Multi-condition alert (high latency AND high traffic)&lt;/h3&gt;
&lt;p&gt;Use multiple queries and expressions to alert only when multiple conditions are true simultaneously. This reduces noise by avoiding alerts during low-traffic periods.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Query A&lt;/strong&gt; — P95 latency:&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;promql&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-promql&#34;&gt;histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket{job=&amp;#34;api&amp;#34;}[$__rate_interval])) by (le))&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Query B&lt;/strong&gt; — Request rate:&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;promql&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-promql&#34;&gt;sum(rate(http_requests_total{job=&amp;#34;api&amp;#34;}[$__rate_interval]))&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Expression C&lt;/strong&gt; — Math (both conditions must be true):&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;$A &amp;gt; 2 &amp;amp;&amp;amp; $B &amp;gt; 100&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Condition:&lt;/strong&gt; Alert when &lt;strong&gt;C&lt;/strong&gt; has a value (it only returns data when both latency exceeds 2 seconds AND request rate exceeds 100 req/s).&lt;/p&gt;
&lt;h2 id=&#34;recording-rules&#34;&gt;Recording rules&lt;/h2&gt;
&lt;p&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/alerting/alerting-rules/create-recording-rules/create-grafana-managed-recording-rules/&#34;&gt;Grafana-managed recording rules&lt;/a&gt; pre-compute expensive PromQL expressions on a schedule and write the results back to a Prometheus-compatible data source as a new metric. This lets you query the pre-aggregated metric instead of re-evaluating the expensive expression on every dashboard load or alert evaluation.&lt;/p&gt;
&lt;h3 id=&#34;when-to-use-recording-rules&#34;&gt;When to use recording rules&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Dashboard panels that query the same expensive expression repeatedly&lt;/strong&gt; — pre-compute it once and query the result.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Alert rules on complex expressions&lt;/strong&gt; — simplify the alert query by alerting on the pre-aggregated metric.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;High-cardinality aggregations&lt;/strong&gt; — reduce thousands of series to a handful of pre-computed series.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;set-up-grafana-managed-recording-rules-for-prometheus&#34;&gt;Set up Grafana-managed recording rules for Prometheus&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Enable the data source as a recording rules target:&lt;/strong&gt; In the Prometheus data source configuration, verify that &lt;strong&gt;Allow as recording rules target&lt;/strong&gt; is toggled on (it&amp;rsquo;s on by default). This allows Grafana to write recording rule results back to this instance.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Verify write access:&lt;/strong&gt; The Prometheus-compatible backend must support remote write. Grafana Cloud Metrics (Mimir) and self-hosted Mimir support this natively. Standard Prometheus requires the &lt;code&gt;--web.enable-remote-write-receiver&lt;/code&gt; flag (Prometheus 2.33&#43;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create a recording rule:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Navigate to &lt;strong&gt;Alerting&lt;/strong&gt; &amp;gt; &lt;strong&gt;Alert rules&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;New alert rule&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select &lt;strong&gt;Recording rule&lt;/strong&gt; as the rule type (under the Grafana-managed section).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter the PromQL expression you want to pre-compute:&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;promql&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-promql&#34;&gt;sum(rate(http_requests_total[$__rate_interval])) by (service)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter a metric name for the result (for example, &lt;code&gt;service:http_requests:rate5m&lt;/code&gt;). Follow the Prometheus &lt;a href=&#34;https://prometheus.io/docs/practices/rules/#naming-and-aggregation&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;recording rule naming convention&lt;/a&gt;: &lt;code&gt;level:metric:operations&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select the &lt;strong&gt;Target data source&lt;/strong&gt; — the Prometheus instance where results will be written.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set the evaluation interval (for example, every 1 minute).&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;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Query the recorded metric:&lt;/strong&gt; After the first evaluation, the new metric is available for dashboards and alerts:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;promql&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-promql&#34;&gt;service:http_requests:rate5m{service=&amp;#34;api&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;recording-rules-with-pdc&#34;&gt;Recording rules with PDC&lt;/h3&gt;
&lt;p&gt;If your Prometheus instance is behind 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/configure/#private-data-source-connect&#34;&gt;Private data source connect (PDC)&lt;/a&gt;, Grafana can write recording rule results through the PDC tunnel. No additional configuration is needed — PDC supports both reads and writes.&lt;/p&gt;
&lt;h3 id=&#34;limitations&#34;&gt;Limitations&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Recording rules require the target data source to support remote write. Standard Prometheus needs the &lt;code&gt;--web.enable-remote-write-receiver&lt;/code&gt; flag.&lt;/li&gt;
&lt;li&gt;Thanos does not support recording rules as a write target (refer to the 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/configure/#performance&#34;&gt;Prometheus type comparison&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Recording rule evaluation uses the configured evaluation interval, not dashboard time ranges. Use a fixed range vector (for example, &lt;code&gt;[5m]&lt;/code&gt;) rather than &lt;code&gt;$__rate_interval&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For more information, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/alerting/alerting-rules/create-recording-rules/create-grafana-managed-recording-rules/&#34;&gt;Create Grafana-managed recording rules&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;limitations-1&#34;&gt;Limitations&lt;/h2&gt;
&lt;p&gt;When using Prometheus with Grafana Alerting, be aware of the following limitations.&lt;/p&gt;
&lt;h3 id=&#34;template-variables-not-supported&#34;&gt;Template variables not supported&lt;/h3&gt;
&lt;p&gt;Alert queries don&amp;rsquo;t support template variables. Grafana evaluates alert rules on the backend without dashboard context, so variables like &lt;code&gt;$instance&lt;/code&gt; or &lt;code&gt;$job&lt;/code&gt; aren&amp;rsquo;t resolved.&lt;/p&gt;
&lt;p&gt;If your dashboard query uses template variables, create a separate query for alerting with hard-coded values or use label matchers directly.&lt;/p&gt;
&lt;h3 id=&#34;query-complexity&#34;&gt;Query complexity&lt;/h3&gt;
&lt;p&gt;Complex queries with many nested functions or large result sets may timeout or fail to evaluate. Simplify queries for alerting by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Reducing the time range used in range vectors&lt;/li&gt;
&lt;li&gt;Using appropriate aggregation to limit the number of returned series&lt;/li&gt;
&lt;li&gt;Adding label filters to narrow the data scanned&lt;/li&gt;
&lt;li&gt;Using recording rules to pre-compute expensive expressions&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;oauth-token-handling-differs-between-explore-and-alerting&#34;&gt;OAuth token handling differs between Explore and Alerting&lt;/h3&gt;
&lt;p&gt;When using OAuth-authenticated Prometheus endpoints (Google Managed Prometheus, Azure Managed Prometheus), queries may succeed in Explore and dashboards but fail intermittently during alert evaluation. This happens because the alerting backend handles token refresh differently from the interactive query path.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re using GCP, consider the &lt;strong&gt;datasource-syncer&lt;/strong&gt; pattern — a sidecar process that refreshes OAuth tokens and updates the data source credentials on a schedule shorter than the token lifetime.&lt;/p&gt;
&lt;p&gt;For detailed troubleshooting steps, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/troubleshooting/#oauth-token-expiration-errors-gcp-and-azure&#34;&gt;OAuth token expiration errors&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;data-source-managed-rules-are-read-only&#34;&gt;Data source-managed rules are read-only&lt;/h3&gt;
&lt;p&gt;Grafana can display Prometheus alerting rules but can&amp;rsquo;t create or modify them through the UI. To manage Prometheus-native alerting rules, edit your Prometheus rule files directly and reload the configuration.&lt;/p&gt;
&lt;h2 id=&#34;configure-alert-state-for-execution-errors&#34;&gt;Configure alert state for execution errors&lt;/h2&gt;
&lt;p&gt;By default, when a Grafana-managed alert rule encounters an execution error or timeout (such as a network blip, i/o timeout, or a transient 502 from Prometheus), the rule enters an &lt;strong&gt;Error&lt;/strong&gt; state — which fires the alert. This can cause false alarms and spam on-call teams when the underlying issue is a brief connectivity interruption rather than a genuine threshold breach.&lt;/p&gt;
&lt;p&gt;To prevent false positives from transient errors, configure the &lt;strong&gt;Alert state if execution error or timeout&lt;/strong&gt; setting on each alert rule:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the alert rule for editing.&lt;/li&gt;
&lt;li&gt;In the alert conditions section, locate &lt;strong&gt;Alert state if execution error or timeout&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Change the value from &lt;strong&gt;Alerting&lt;/strong&gt; (default) to one of:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Keep Last State&lt;/strong&gt; — The alert retains its previous state (firing or normal) until a successful evaluation occurs. This is the recommended setting for most Prometheus alert rules.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OK&lt;/strong&gt; — The alert is set to normal during the error, preventing it from firing.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save rule&lt;/strong&gt;.&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;If your alert rules frequently enter an error state, investigate the root cause (network stability, Prometheus resource limits, query timeout settings) rather than relying solely on this setting to suppress notifications.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Common transient errors that trigger this behavior include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;sse.dependencyError&lt;/code&gt; or &lt;code&gt;sse.dataQueryError&lt;/code&gt; in alert state history&lt;/li&gt;
&lt;li&gt;&amp;ldquo;context deadline exceeded&amp;rdquo; or &amp;ldquo;i/o timeout&amp;rdquo; messages&lt;/li&gt;
&lt;li&gt;HTTP 502 or 500 responses from the Prometheus server&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For more details on troubleshooting these errors, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/troubleshooting/#transient-alert-errors-triggering-false-alarms&#34;&gt;Troubleshoot Prometheus data source issues&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;best-practices&#34;&gt;Best practices&lt;/h2&gt;
&lt;p&gt;Follow these best practices when creating Prometheus alerts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Configure error state handling:&lt;/strong&gt; Set &lt;strong&gt;Alert state if execution error or timeout&lt;/strong&gt; to &lt;strong&gt;Keep Last State&lt;/strong&gt; to prevent transient backend errors from triggering false alarms.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use &lt;code&gt;$__rate_interval&lt;/code&gt;:&lt;/strong&gt; When using &lt;code&gt;rate()&lt;/code&gt; or &lt;code&gt;increase()&lt;/code&gt; in alert queries, use &lt;code&gt;$__rate_interval&lt;/code&gt; to ensure the range window is always large enough relative to the scrape interval. Grafana resolves this variable based on the evaluation interval and scrape interval configuration.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Add label filters:&lt;/strong&gt; Include specific label matchers to focus on relevant data and improve query performance.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Set realistic pending periods:&lt;/strong&gt; Use the pending period to avoid alerting on brief spikes. For example, set a 5-minute pending period so the condition must persist before firing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Test queries first:&lt;/strong&gt; Verify your query returns expected results in Explore before creating an alert.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use meaningful names:&lt;/strong&gt; Give alert rules descriptive names that indicate what they monitor and the severity.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pre-aggregate with recording rules:&lt;/strong&gt; For complex or frequently evaluated expressions, create recording rules and alert on the pre-aggregated metric.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use &lt;code&gt;absent()&lt;/code&gt; for availability monitoring:&lt;/strong&gt; Detect when metrics stop being reported, which often indicates a crashed or unresponsive service.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you encounter errors when creating or evaluating alert rules, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/troubleshooting/#alerting-errors&#34;&gt;Troubleshoot Prometheus data source issues&lt;/a&gt;.&lt;/p&gt;
]]></content><description>&lt;h1 id="prometheus-alerting">Prometheus alerting&lt;/h1>
&lt;p>You can use Grafana Alerting with Prometheus to create alerts based on your time-series data. This allows you to monitor metrics, detect anomalies, and receive notifications when specific conditions are met.&lt;/p></description></item><item><title>Troubleshoot Prometheus data source issues</title><link>https://grafana.com/docs/grafana/v13.1/datasources/prometheus/troubleshooting/</link><pubDate>Tue, 23 Jun 2026 13:06:40 +0000</pubDate><guid>https://grafana.com/docs/grafana/v13.1/datasources/prometheus/troubleshooting/</guid><content><![CDATA[&lt;h1 id=&#34;troubleshoot-prometheus-data-source-issues&#34;&gt;Troubleshoot Prometheus data source issues&lt;/h1&gt;
&lt;p&gt;This document provides troubleshooting information for common errors you may encounter when using the Prometheus data source in Grafana.&lt;/p&gt;
&lt;h2 id=&#34;connection-errors&#34;&gt;Connection errors&lt;/h2&gt;
&lt;p&gt;The following errors occur when Grafana cannot establish or maintain a connection to Prometheus.&lt;/p&gt;
&lt;h3 id=&#34;failed-to-connect-to-prometheus&#34;&gt;Failed to connect to Prometheus&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error message:&lt;/strong&gt; &amp;ldquo;There was an error returned querying the Prometheus API&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; Grafana cannot establish a network connection to the Prometheus server.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify that the Prometheus server URL is correct in the data source configuration.&lt;/li&gt;
&lt;li&gt;Check that Prometheus is running and accessible from the Grafana server.&lt;/li&gt;
&lt;li&gt;Ensure the URL includes the protocol (&lt;code&gt;http://&lt;/code&gt; or &lt;code&gt;https://&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Verify the port is correct (the Prometheus default port is &lt;code&gt;9090&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Ensure there are no firewall rules blocking the connection.&lt;/li&gt;
&lt;li&gt;If Grafana and Prometheus are running in separate containers, use the container IP address or hostname instead of &lt;code&gt;localhost&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;For Grafana Cloud, ensure you have configured &lt;a href=&#34;/docs/grafana-cloud/connect-externally-hosted/private-data-source-connect/&#34;&gt;Private data source connect&lt;/a&gt; if your Prometheus instance is not publicly accessible.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;request-timed-out&#34;&gt;Request timed out&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error message:&lt;/strong&gt; &amp;ldquo;context deadline exceeded&amp;rdquo; or &amp;ldquo;request timeout&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The connection to Prometheus timed out before receiving a response.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Check the network latency between Grafana and Prometheus.&lt;/li&gt;
&lt;li&gt;Verify that Prometheus is not overloaded or experiencing performance issues.&lt;/li&gt;
&lt;li&gt;Increase the &lt;strong&gt;Query timeout&lt;/strong&gt; setting in the data source configuration under &lt;strong&gt;Interval behavior&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Check the &lt;a href=&#34;/docs/grafana/latest/setup-grafana/configure-grafana/#timeout&#34;&gt;Grafana server timeout configuration&lt;/a&gt; for server-level timeout settings.&lt;/li&gt;
&lt;li&gt;Reduce the time range or complexity of your query.&lt;/li&gt;
&lt;li&gt;Check if any network devices (load balancers, proxies) are timing out the connection.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;failed-to-parse-data-source-url&#34;&gt;Failed to parse data source URL&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error message:&lt;/strong&gt; &amp;ldquo;Failed to parse data source URL&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The URL entered in the data source configuration is not valid.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify the URL format is correct (for example, &lt;code&gt;http://localhost:9090&lt;/code&gt; or &lt;code&gt;https://prometheus.example.com:9090&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Ensure the URL includes the protocol (&lt;code&gt;http://&lt;/code&gt; or &lt;code&gt;https://&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Remove any trailing slashes or invalid characters from the URL.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;data-doesnt-appear-in-metrics-drilldown-or-explore&#34;&gt;Data doesn&amp;rsquo;t appear in Metrics Drilldown or Explore&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; You&amp;rsquo;ve successfully tested the data source connection, but no metric data appears in Explore or Metrics Drilldown.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The wrong data source is selected, or the data source name doesn&amp;rsquo;t match expectations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify you&amp;rsquo;ve selected the correct data source from the data source drop-down menu.&lt;/li&gt;
&lt;li&gt;When using &lt;code&gt;remote_write&lt;/code&gt; to send metrics to Grafana Cloud, the data source name follows the convention &lt;code&gt;grafanacloud-&amp;lt;stackname&amp;gt;-prom&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Check that metrics are being actively scraped by querying &lt;code&gt;up&lt;/code&gt; in the Explore view.&lt;/li&gt;
&lt;li&gt;If using Grafana Cloud, verify the &lt;code&gt;remote_write&lt;/code&gt; endpoint URL and credentials are correct.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;pdc-connectivity-errors&#34;&gt;PDC connectivity errors&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error messages:&lt;/strong&gt; &amp;ldquo;host unreachable&amp;rdquo;, &amp;ldquo;EOF&amp;rdquo;, &amp;ldquo;network unreachable&amp;rdquo;, &amp;ldquo;connection reset by peer&amp;rdquo;, &amp;ldquo;dial tcp: lookup &amp;hellip; no such host&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; Prometheus queries fail intermittently or consistently when using Private data source connect (PDC) to reach a Prometheus instance behind a private network. The data source test may pass occasionally but queries fail under load.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; PDC tunnels traffic through an SSH connection between Grafana Cloud and your PDC agent. Connectivity failures are most commonly caused by DNS resolution issues, network configuration on the customer side, or the PDC agent&amp;rsquo;s default connection limits being too low for the query volume.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Verify DNS resolution from the PDC agent host.&lt;/strong&gt; The PDC agent must be able to resolve the Prometheus hostname from the machine it runs on. Run &lt;code&gt;nslookup&lt;/code&gt; or &lt;code&gt;dig&lt;/code&gt; for the Prometheus URL from the agent host to confirm.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Check network connectivity from the agent.&lt;/strong&gt; Ensure the PDC agent can reach the Prometheus endpoint directly (for example, &lt;code&gt;curl http://prometheus-host:9090/-/healthy&lt;/code&gt; from the agent machine).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Increase parallel SSH connections.&lt;/strong&gt; The PDC agent defaults to 1 parallel SSH connection, which can bottleneck under load from multiple alert evaluations or dashboard queries. Increase this by setting the &lt;code&gt;--ssh-connections&lt;/code&gt; flag (or &lt;code&gt;PDC_SSH_CONNECTIONS&lt;/code&gt; environment variable) to a higher value (for example, 4 or 8):&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;sh&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-sh&#34;&gt;pdc-agent --ssh-connections=4&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Check firewall rules.&lt;/strong&gt; Ensure the PDC agent&amp;rsquo;s outbound SSH connection to Grafana Cloud isn&amp;rsquo;t being interrupted by firewall rules, NAT gateways, or idle connection timeouts.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Verify the PDC agent is running and healthy.&lt;/strong&gt; Check agent logs for connection errors or restarts. The agent must maintain a persistent connection to Grafana Cloud.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Check for idle timeout issues.&lt;/strong&gt; If the connection drops after periods of inactivity, configure TCP keepalives on the host or add a keepalive setting to the PDC agent configuration.&lt;/p&gt;
&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;PDC connectivity issues are almost always caused by networking on the customer side (DNS, firewall rules, routing), not by Grafana Cloud. The data source test passing doesn&amp;rsquo;t guarantee sustained connectivity under load — it only verifies a single query succeeds.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;For general PDC setup and configuration, refer to &lt;a href=&#34;/docs/grafana-cloud/connect-externally-hosted/private-data-source-connect/&#34;&gt;Private data source connect (PDC)&lt;/a&gt; and &lt;a href=&#34;/docs/grafana-cloud/connect-externally-hosted/private-data-source-connect/configure-pdc/&#34;&gt;Configure PDC&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;certificate-verification-failed&#34;&gt;Certificate verification failed&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error message:&lt;/strong&gt; &amp;ldquo;x509: certificate signed by unknown authority&amp;rdquo; or &amp;ldquo;certificate verify failed&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; Grafana cannot verify the TLS certificate presented by Prometheus.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;If using a self-signed certificate, enable &lt;strong&gt;Add self-signed certificate&lt;/strong&gt; in the TLS settings and add your CA certificate.&lt;/li&gt;
&lt;li&gt;Verify the certificate chain is complete and valid.&lt;/li&gt;
&lt;li&gt;Ensure the certificate has not expired.&lt;/li&gt;
&lt;li&gt;As a temporary workaround for testing, enable &lt;strong&gt;Skip TLS verify&lt;/strong&gt; (not recommended for production).&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;tls-handshake-error&#34;&gt;TLS handshake error&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error message:&lt;/strong&gt; &amp;ldquo;TLS: handshake failure&amp;rdquo; or &amp;ldquo;connection reset&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The TLS handshake between Grafana and Prometheus failed.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify that Prometheus is configured to use TLS.&lt;/li&gt;
&lt;li&gt;Check that the TLS version and cipher suites are compatible.&lt;/li&gt;
&lt;li&gt;If using client certificates, ensure they are correctly configured in the &lt;strong&gt;TLS client authentication&lt;/strong&gt; section.&lt;/li&gt;
&lt;li&gt;Verify the server name matches the certificate&amp;rsquo;s Common Name or Subject Alternative Name.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;authentication-errors&#34;&gt;Authentication errors&lt;/h2&gt;
&lt;p&gt;The following errors occur when there are issues with authentication credentials or permissions.&lt;/p&gt;
&lt;h3 id=&#34;unauthorized-401&#34;&gt;Unauthorized (401)&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error message:&lt;/strong&gt; &amp;ldquo;401 Unauthorized&amp;rdquo; or &amp;ldquo;Authorization failed&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The authentication credentials are invalid or missing.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify that the username and password are correct if using basic authentication.&lt;/li&gt;
&lt;li&gt;Check that the authentication method selected matches your Prometheus configuration.&lt;/li&gt;
&lt;li&gt;If using a reverse proxy with authentication, verify the credentials are correct.&lt;/li&gt;
&lt;li&gt;For AWS SigV4 authentication, verify the IAM credentials and permissions. Alternatively, consider using the &lt;a href=&#34;/grafana/plugins/grafana-amazonprometheus-datasource/&#34;&gt;Amazon Managed Service for Prometheus data source&lt;/a&gt; for simplified AWS authentication.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;oauth-token-expiration-errors-gcp-and-azure&#34;&gt;OAuth token expiration errors (GCP and Azure)&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error messages:&lt;/strong&gt; &amp;ldquo;ACCESS_TOKEN_EXPIRED&amp;rdquo;, &amp;ldquo;401 Unauthorized&amp;rdquo; in alerting but not in Explore&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; Queries in Explore and dashboards work correctly, but alert rule evaluations fail intermittently with 401 errors. This is most common with Google Managed Prometheus (GMP) and Azure-managed Prometheus endpoints using OAuth/OIDC authentication.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The Grafana alerting backend and the interactive query path (Explore, dashboards) handle credential refreshes differently. The alerting evaluator can use a cached OAuth token beyond its expiry window due to a token staleness check issue in the Prometheus data source. This causes alerting to fail with expired credentials while interactive queries succeed because they trigger a fresh token exchange.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For Google Managed Prometheus (GMP):&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Use the &lt;strong&gt;GCP datasource-syncer&lt;/strong&gt; pattern: run a sidecar process that refreshes OAuth tokens and updates the Grafana data source credentials on a schedule shorter than the token lifetime (typically every 45 minutes for a 60-minute token). This ensures the stored token is always valid when the alerting backend uses it.&lt;/li&gt;
&lt;li&gt;Alternatively, use the &lt;a href=&#34;/grafana/plugins/stackdriver/&#34;&gt;Google Cloud Monitor data source&lt;/a&gt; with its built-in GCP credential management rather than pointing the core Prometheus data source at a GMP endpoint.&lt;/li&gt;
&lt;li&gt;If running on GKE with Workload Identity, ensure the Kubernetes service account token refresh is functioning and the projected token volume is mounted correctly.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For Azure Managed Prometheus:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify the Azure AD app registration&amp;rsquo;s client secret hasn&amp;rsquo;t expired.&lt;/li&gt;
&lt;li&gt;If using Managed Identity, ensure the Grafana instance&amp;rsquo;s identity has the &lt;strong&gt;Monitoring Data Reader&lt;/strong&gt; role on the Azure Monitor workspace.&lt;/li&gt;
&lt;li&gt;Check that &lt;strong&gt;Forward OAuth identity&lt;/strong&gt; is not enabled alongside Azure AD authentication — both use the same HTTP authorization headers and conflict with each other.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;General steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Check the Grafana server logs for token refresh errors around the time alerts fail.&lt;/li&gt;
&lt;li&gt;Verify the data source test (&lt;strong&gt;Save &amp;amp; test&lt;/strong&gt;) passes — this confirms current credentials are valid but doesn&amp;rsquo;t guarantee the alerting backend has a fresh token.&lt;/li&gt;
&lt;li&gt;If the issue persists, set &lt;strong&gt;Alert state if execution error or timeout&lt;/strong&gt; to &lt;strong&gt;Keep Last State&lt;/strong&gt; to prevent false alarms while investigating. Refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/alerting/#configure-alert-state-for-execution-errors&#34;&gt;Configure alert state for execution errors&lt;/a&gt;.&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;This token caching behavior is a known issue that has received code fixes in recent Grafana releases. If you&amp;rsquo;re experiencing this on an older Grafana version, upgrading may resolve it. Check the 
    &lt;a href=&#34;/docs/grafana/v13.1/whatsnew/&#34;&gt;Grafana changelog&lt;/a&gt; for relevant fixes.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;lbac-not-restricting-data-on-non-mimir-backends&#34;&gt;LBAC not restricting data on non-Mimir backends&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; You&amp;rsquo;ve enabled &lt;code&gt;teamHttpHeadersMimir&lt;/code&gt; and configured Team LBAC rules, but users can still see all metrics regardless of their team assignments.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; Label-Based Access Control (LBAC) for the Prometheus data source only works when the backend is &lt;strong&gt;Grafana Cloud Metrics (Mimir)&lt;/strong&gt; or &lt;strong&gt;Grafana Enterprise Metrics (GEM)&lt;/strong&gt;. It doesn&amp;rsquo;t work with Google Managed Prometheus, self-hosted Prometheus, Thanos, or other Prometheus-compatible endpoints. The LBAC enforcement relies on Mimir-specific HTTP headers (&lt;code&gt;X-Scope-OrgID&lt;/code&gt; and team-scoped label matchers) that other backends ignore.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify your backend is Grafana Cloud Metrics or GEM. If you&amp;rsquo;re using a different Prometheus-compatible backend, LBAC isn&amp;rsquo;t supported.&lt;/li&gt;
&lt;li&gt;For Google Managed Prometheus or other external endpoints, use 
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/#data-source-permissions&#34;&gt;data source permissions&lt;/a&gt; to control which teams can access the data source entirely, rather than per-label access control.&lt;/li&gt;
&lt;li&gt;If you need per-label restrictions on a non-Mimir backend, consider proxying through a Mimir instance or using a separate data source per team with different credentials scoped to the appropriate data.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;azure-ad-or-sigv4-authentication-options-not-available&#34;&gt;Azure AD or SigV4 authentication options not available&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; The Azure AD or SigV4 authentication options don&amp;rsquo;t appear in the authentication drop-down when configuring the Prometheus data source.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; These authentication methods require server-side feature flags that aren&amp;rsquo;t enabled by default, particularly on Grafana Cloud.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Grafana Cloud:&lt;/strong&gt; Contact &lt;a href=&#34;/profile/org#support&#34;&gt;Grafana Support&lt;/a&gt; to request the feature flag be enabled for your stack. This isn&amp;rsquo;t a self-service setting.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Self-managed Grafana:&lt;/strong&gt; Add the required setting to your Grafana configuration file:
&lt;ul&gt;
&lt;li&gt;For Azure AD: set &lt;code&gt;azure_auth_enabled = true&lt;/code&gt; under &lt;code&gt;[auth]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;For SigV4: set &lt;code&gt;sigv4_auth_enabled = true&lt;/code&gt; under &lt;code&gt;[auth]&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;For Amazon Managed Prometheus:&lt;/strong&gt; Consider using the dedicated &lt;a href=&#34;/grafana/plugins/grafana-amazonprometheus-datasource/&#34;&gt;Amazon Managed Service for Prometheus data source&lt;/a&gt; instead, which handles AWS authentication natively without needing the SigV4 flag.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;forbidden-403&#34;&gt;Forbidden (403)&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error message:&lt;/strong&gt; &amp;ldquo;403 Forbidden&amp;rdquo; or &amp;ldquo;Access denied&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The authenticated user does not have permission to access the requested resource.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify the user has read access to the Prometheus API.&lt;/li&gt;
&lt;li&gt;Check Prometheus security settings and access control configuration.&lt;/li&gt;
&lt;li&gt;If using a reverse proxy, verify the proxy is not blocking the request.&lt;/li&gt;
&lt;li&gt;For AWS Managed Prometheus, verify the IAM policy grants the required permissions. Alternatively, consider using the &lt;a href=&#34;/grafana/plugins/grafana-amazonprometheus-datasource/&#34;&gt;Amazon Managed Service for Prometheus data source&lt;/a&gt; for simplified AWS authentication.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;query-errors&#34;&gt;Query errors&lt;/h2&gt;
&lt;p&gt;The following errors occur when there are issues with PromQL syntax or query execution.&lt;/p&gt;
&lt;h3 id=&#34;query-syntax-error&#34;&gt;Query syntax error&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error message:&lt;/strong&gt; &amp;ldquo;parse error: unexpected character&amp;rdquo; or &amp;ldquo;bad_data: 1:X: parse error&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The PromQL query contains invalid syntax.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Alternative cause:&lt;/strong&gt; A proxy between Grafana and Prometheus requires authentication. When proxy authentication fails, the proxy redirects the request to an HTML authentication page. Grafana cannot parse the HTML response, which results in a parse error. This appears to be a query issue but is actually a proxy authentication issue.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Check your query syntax for typos or invalid characters.&lt;/li&gt;
&lt;li&gt;Verify that metric names and label names are valid identifiers.&lt;/li&gt;
&lt;li&gt;Ensure string values in label matchers are enclosed in quotes.&lt;/li&gt;
&lt;li&gt;Use the Prometheus expression browser to test your query directly.&lt;/li&gt;
&lt;li&gt;Refer to the &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/basics/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus querying documentation&lt;/a&gt; for syntax guidance.&lt;/li&gt;
&lt;li&gt;If you have a proxy between Grafana and Prometheus, verify that proxy authentication is correctly configured. Check your proxy logs for authentication failures or redirects.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;query-returns-no-data-for-a-metric&#34;&gt;Query returns no data for a metric&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; The query returns no data and the visualization is empty.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The specified metric does not exist in Prometheus, or there is no data for the selected time range.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify the metric name is spelled correctly.&lt;/li&gt;
&lt;li&gt;Check that the metric is being scraped by Prometheus.&lt;/li&gt;
&lt;li&gt;Use the Prometheus API to browse available metrics at &lt;code&gt;/api/v1/label/__name__/values&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Use the &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/api#querying-target-metadata&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;target metadata API&lt;/a&gt; to verify which metrics a target exposes.&lt;/li&gt;
&lt;li&gt;Verify the time range includes data for the metric.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;query-timeout-limit-exceeded&#34;&gt;Query timeout limit exceeded&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error message:&lt;/strong&gt; &amp;ldquo;query timed out in expression evaluation&amp;rdquo; or &amp;ldquo;query processing would load too many samples&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The query took longer than the configured timeout limit or would return too many samples.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Reduce the time range of your query.&lt;/li&gt;
&lt;li&gt;Add more specific label filters to limit the data scanned.&lt;/li&gt;
&lt;li&gt;Increase the &lt;strong&gt;Query timeout&lt;/strong&gt; setting in the data source configuration.&lt;/li&gt;
&lt;li&gt;Use aggregation functions like &lt;code&gt;sum()&lt;/code&gt;, &lt;code&gt;avg()&lt;/code&gt;, or &lt;code&gt;rate()&lt;/code&gt; to reduce the number of time series.&lt;/li&gt;
&lt;li&gt;Increase the &lt;code&gt;query.timeout&lt;/code&gt; or &lt;code&gt;query.max-samples&lt;/code&gt; settings in Prometheus if you have admin access.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;too-many-time-series&#34;&gt;Too many time series&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error message:&lt;/strong&gt; &amp;ldquo;exceeded maximum resolution of 11,000 points per timeseries&amp;rdquo; or &amp;ldquo;maximum number of series limit exceeded&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The query is returning more time series or data points than the configured limits allow.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Reduce the time range of your query.&lt;/li&gt;
&lt;li&gt;Add label filters to limit the number of time series returned.&lt;/li&gt;
&lt;li&gt;Increase the &lt;strong&gt;Min interval&lt;/strong&gt; or &lt;strong&gt;Resolution&lt;/strong&gt; in the query options to reduce the number of data points.&lt;/li&gt;
&lt;li&gt;Use aggregation functions to combine time series.&lt;/li&gt;
&lt;li&gt;Adjust the &lt;strong&gt;Series limit&lt;/strong&gt; setting in the data source configuration under &lt;strong&gt;Other settings&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;memory-limit-exceeded-for-high-cardinality-queries&#34;&gt;Memory limit exceeded for high-cardinality queries&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error messages:&lt;/strong&gt; &amp;ldquo;max-estimated-memory-consumption-per-query limit exceeded&amp;rdquo;, &amp;ldquo;query requires too much memory&amp;rdquo;, &amp;ldquo;max samples limit reached&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; Queries against high-cardinality metrics (thousands of unique label combinations) over long time ranges (days or weeks) fail with memory or sample limit errors. Short time ranges may work but expanding the range causes the failure.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; Prometheus and Mimir enforce per-query memory and sample limits to protect the system from resource exhaustion. High-cardinality metrics (for example, metrics with a &lt;code&gt;pod&lt;/code&gt;, &lt;code&gt;request_id&lt;/code&gt;, or &lt;code&gt;user_id&lt;/code&gt; label) multiplied by long time ranges produce result sets that exceed these limits.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Reduce the query scope:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Shorten the time range.&lt;/li&gt;
&lt;li&gt;Add label matchers to select fewer series (for example, filter to a specific &lt;code&gt;namespace&lt;/code&gt; or &lt;code&gt;job&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Increase the &lt;strong&gt;Min step&lt;/strong&gt; or use a larger step interval to reduce the number of data points per series.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use recording rules to pre-aggregate:&lt;/strong&gt;
Create &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;recording rules&lt;/a&gt; that pre-compute the aggregation you need. For example, if you commonly query &lt;code&gt;sum(rate(http_requests_total[5m])) by (service)&lt;/code&gt;, create a recording rule for it and query the pre-aggregated metric instead.&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;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;groups:
  - name: aggregations
    rules:
      - record: service:http_requests_total:rate5m
        expr: sum(rate(http_requests_total[5m])) by (service)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use Adaptive Metrics (Grafana Cloud):&lt;/strong&gt;
If you&amp;rsquo;re on Grafana Cloud, &lt;a href=&#34;/docs/grafana-cloud/cost-management-and-billing/reduce-costs/metrics-costs/control-metrics-usage-via-adaptive-metrics/&#34;&gt;Adaptive Metrics&lt;/a&gt; automatically identifies and aggregates high-cardinality metrics that aren&amp;rsquo;t being queried at full resolution, reducing storage and query costs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Restructure dashboards for high-cardinality data:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use template variables to scope queries to a subset of labels rather than querying all series at once.&lt;/li&gt;
&lt;li&gt;Split long-range overviews (weekly/monthly) into separate panels that use pre-aggregated recording rules.&lt;/li&gt;
&lt;li&gt;Use the &lt;strong&gt;Max data points&lt;/strong&gt; setting in the query options to cap the resolution for overview panels.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Increase limits (self-managed only):&lt;/strong&gt;
If you have admin access to Prometheus or Mimir, you can increase limits in the server configuration:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Prometheus: &lt;code&gt;--query.max-samples&lt;/code&gt; flag&lt;/li&gt;
&lt;li&gt;Mimir: &lt;code&gt;-querier.max-samples&lt;/code&gt;, &lt;code&gt;-querier.max-estimated-memory-consumption-per-query&lt;/code&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;Increasing limits allows larger queries to succeed but also increases the risk of resource exhaustion. Prefer reducing query scope or using recording rules over raising limits.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;invalid-function-or-aggregation&#34;&gt;Invalid function or aggregation&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error message:&lt;/strong&gt; &amp;ldquo;unknown function&amp;rdquo; or &amp;ldquo;parse error: unexpected aggregation&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The query uses an invalid or unsupported PromQL function.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify the function name is spelled correctly and is a valid PromQL function.&lt;/li&gt;
&lt;li&gt;Check that you are using the correct syntax for the function.&lt;/li&gt;
&lt;li&gt;Ensure your Prometheus version supports the function you are using.&lt;/li&gt;
&lt;li&gt;Refer to the &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/functions/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;PromQL functions documentation&lt;/a&gt; for available functions.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;rate-or-increase-returning-unexpected-values&#34;&gt;&lt;code&gt;rate()&lt;/code&gt; or &lt;code&gt;increase()&lt;/code&gt; returning unexpected values&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; &lt;code&gt;increase()&lt;/code&gt; returns fractional values on integer counters, &lt;code&gt;rate()&lt;/code&gt; shows an ever-increasing value instead of a steady per-second rate, or counter resets cause large spikes in visualizations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Possible causes and solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Cause&lt;/th&gt;
              &lt;th&gt;Solution&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;increase()&lt;/code&gt; fractional values&lt;/td&gt;
              &lt;td&gt;Expected behavior — Prometheus uses linear interpolation. Use &lt;code&gt;ceil()&lt;/code&gt; or &lt;code&gt;floor()&lt;/code&gt; if you need integers.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;rate()&lt;/code&gt; grows over time&lt;/td&gt;
              &lt;td&gt;Multiple instances write to the same series without unique labels. Ensure each target has unique &lt;code&gt;instance&lt;/code&gt;/&lt;code&gt;pod&lt;/code&gt; labels and aggregate with &lt;code&gt;sum by&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Counter reset spikes after pod restarts&lt;/td&gt;
              &lt;td&gt;Use &lt;code&gt;$__rate_interval&lt;/code&gt; or a longer range vector to smooth spikes. Investigate frequent restarts as the root cause.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Values differ between edit mode and dashboard&lt;/td&gt;
              &lt;td&gt;Panel width affects &lt;code&gt;$__interval&lt;/code&gt; which affects &lt;code&gt;rate()&lt;/code&gt; window calculations. Set a &lt;strong&gt;Min step&lt;/strong&gt; on the query.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;For detailed explanations of these behaviors, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/query-editor/#expected-promql-behaviors&#34;&gt;Expected PromQL behaviors&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;aggregation-by-labels-with-dots&#34;&gt;Aggregation by labels with dots&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; Queries that aggregate by label names containing dots (for example, &lt;code&gt;container.name&lt;/code&gt;) return incorrect or incomplete results.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; Prior to Grafana 13, there was a bug where labels with dots in their names were not handled correctly during aggregation operations like &lt;code&gt;sum by&lt;/code&gt; or &lt;code&gt;avg by&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Upgrade to Grafana 13 or later, which correctly handles labels with dots in aggregation queries.&lt;/li&gt;
&lt;li&gt;Verify your query uses the correct label name with dots (for example, &lt;code&gt;sum by (container.name) (metric_name)&lt;/code&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;configuration-errors&#34;&gt;Configuration errors&lt;/h2&gt;
&lt;p&gt;The following errors occur when the data source is not configured correctly.&lt;/p&gt;
&lt;h3 id=&#34;invalid-prometheus-type&#34;&gt;Invalid Prometheus type&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error message:&lt;/strong&gt; Unexpected behavior when querying metrics or labels&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The &lt;strong&gt;Prometheus type&lt;/strong&gt; setting does not match your actual Prometheus-compatible database.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the data source configuration in Grafana.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Performance&lt;/strong&gt;, select the correct &lt;strong&gt;Prometheus type&lt;/strong&gt; (Prometheus, Cortex, Mimir, or Thanos).&lt;/li&gt;
&lt;li&gt;Different database types support different APIs, so setting this incorrectly may cause unexpected behavior.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;scrape-interval-mismatch&#34;&gt;Scrape interval mismatch&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; Data appears sparse, or &lt;code&gt;rate()&lt;/code&gt; queries return no data or incomplete results.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; The &lt;strong&gt;Scrape interval&lt;/strong&gt; setting in Grafana does not match the actual scrape interval in Prometheus. This especially affects &lt;code&gt;rate()&lt;/code&gt; queries, which require at least two data points within the specified time window. For example, if your actual scrape interval is 5 minutes but Grafana uses the default (15 seconds for OSS, 1 minute for Grafana Cloud), a query like &lt;code&gt;rate(http_requests_total[1m])&lt;/code&gt; returns no data because there are no data points within that 1-minute window.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Check your Prometheus configuration file for the &lt;code&gt;scrape_interval&lt;/code&gt; setting.&lt;/li&gt;
&lt;li&gt;Update the &lt;strong&gt;Scrape interval&lt;/strong&gt; in the Grafana data source configuration under &lt;strong&gt;Interval behavior&lt;/strong&gt; to match.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;$__rate_interval&lt;/code&gt; instead of hard-coded time windows in &lt;code&gt;rate()&lt;/code&gt; queries. This variable automatically adjusts based on your scrape interval.&lt;/li&gt;
&lt;li&gt;For more information, refer to &lt;a href=&#34;/blog/2020/09/28/new-in-grafana-7.2-__rate_interval-for-prometheus-rate-queries-that-just-work/&#34;&gt;$__rate_interval for Prometheus rate queries that just work&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;!-- vale Grafana.Spelling = NO --&gt;
&lt;h3 id=&#34;__rate_interval-returns-no-data-or-incorrect-values&#34;&gt;&lt;code&gt;$__rate_interval&lt;/code&gt; returns no data or incorrect values&lt;/h3&gt;
&lt;!-- vale Grafana.Spelling = YES --&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; Queries using &lt;code&gt;$__rate_interval&lt;/code&gt; return no data, return different values in edit mode versus the dashboard, or produce unexpected gaps.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; &lt;code&gt;$__rate_interval&lt;/code&gt; is calculated as &lt;code&gt;max($__interval &#43; scrape_interval, 4 * scrape_interval)&lt;/code&gt;. If any input to this formula is incorrect, the resulting window is wrong — either too small (no data) or inconsistent across contexts.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Common causes and solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Cause&lt;/th&gt;
              &lt;th&gt;Solution&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Data source scrape interval left at default &lt;code&gt;15s&lt;/code&gt; while actual Prometheus scrape interval is longer (for example, &lt;code&gt;60s&lt;/code&gt;)&lt;/td&gt;
              &lt;td&gt;Set the &lt;strong&gt;Scrape interval&lt;/strong&gt; under &lt;strong&gt;Interval behavior&lt;/strong&gt; in the data source configuration to match your Prometheus &lt;code&gt;scrape_interval&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Query works in edit mode but shows gaps on the dashboard&lt;/td&gt;
              &lt;td&gt;Panel size affects &lt;code&gt;$__interval&lt;/code&gt;. Smaller panels produce larger intervals. Set a &lt;strong&gt;Min step&lt;/strong&gt; on the query to enforce a consistent floor.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;LBAC-enabled data source doesn&amp;rsquo;t inherit scrape interval&lt;/td&gt;
              &lt;td&gt;Set the &lt;strong&gt;Min step&lt;/strong&gt; explicitly on each query panel rather than relying on data source inheritance.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Using &lt;code&gt;$__rate_interval&lt;/code&gt; in recording rules or alerting&lt;/td&gt;
              &lt;td&gt;Use a fixed interval (for example, &lt;code&gt;[5m]&lt;/code&gt;) instead of &lt;code&gt;$__rate_interval&lt;/code&gt; in contexts without a panel/dashboard.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;&lt;strong&gt;To debug the current value:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the query inspector in a panel (click the panel title, then &lt;strong&gt;Inspect&lt;/strong&gt; &amp;gt; &lt;strong&gt;Query&lt;/strong&gt;).&lt;/li&gt;
&lt;li&gt;Look at the expanded query sent to Prometheus — the actual interval value replacing &lt;code&gt;$__rate_interval&lt;/code&gt; is visible in the request.&lt;/li&gt;
&lt;li&gt;Compare this value against your actual scrape interval. If it&amp;rsquo;s smaller than your scrape interval, you need to configure the data source scrape interval or set a Min step.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For detailed documentation on how &lt;code&gt;$__rate_interval&lt;/code&gt; works and how to configure it, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/template-variables/#use-__rate_interval&#34;&gt;Use &lt;code&gt;$__rate_interval&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;performance-issues&#34;&gt;Performance issues&lt;/h2&gt;
&lt;p&gt;The following issues affect query speed and data freshness.&lt;/p&gt;
&lt;h3 id=&#34;slow-query-performance&#34;&gt;Slow query performance&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; Queries take a long time to execute, dashboards are slow to load, or the loading spinner persists.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; Queries scan too much data, the Prometheus server is overloaded, or the network connection is slow.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Reduce the time range of your query.&lt;/li&gt;
&lt;li&gt;Add more specific label filters to limit the data scanned.&lt;/li&gt;
&lt;li&gt;Increase the &lt;strong&gt;Min step&lt;/strong&gt; in the query options to reduce the number of data points.&lt;/li&gt;
&lt;li&gt;Check Prometheus server performance and resource utilization.&lt;/li&gt;
&lt;li&gt;Enable &lt;strong&gt;Disable metrics lookup&lt;/strong&gt; in the data source configuration for large Prometheus instances.&lt;/li&gt;
&lt;li&gt;Enable &lt;strong&gt;Incremental querying (beta)&lt;/strong&gt; to cache query results.&lt;/li&gt;
&lt;li&gt;Use recording rules to pre-aggregate frequently queried data.&lt;/li&gt;
&lt;li&gt;For high-cardinality metrics, refer to &lt;a href=&#34;#memory-limit-exceeded-for-high-cardinality-queries&#34;&gt;Memory limit exceeded for high-cardinality queries&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;data-appears-delayed-or-missing-recent-points&#34;&gt;Data appears delayed or missing recent points&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; The visualization doesn&amp;rsquo;t show the most recent data, even after refreshing.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; Scrape timing, clock drift, or dashboard refresh settings.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Check the dashboard time range and refresh settings.&lt;/li&gt;
&lt;li&gt;Verify the &lt;strong&gt;Scrape interval&lt;/strong&gt; is configured correctly in the data source settings.&lt;/li&gt;
&lt;li&gt;Ensure Prometheus has finished scraping the target (there&amp;rsquo;s a delay between the scrape interval and data availability).&lt;/li&gt;
&lt;li&gt;Check for clock synchronization issues between Grafana and Prometheus (use NTP).&lt;/li&gt;
&lt;li&gt;For &lt;code&gt;rate()&lt;/code&gt; and similar functions, the most recent partial scrape interval won&amp;rsquo;t have enough data points — this is expected.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;exemplars-not-showing&#34;&gt;Exemplars not showing&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; Exemplar data doesn&amp;rsquo;t appear on graphs even though you expect it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; Exemplars require specific configuration in both the data source and the query editor.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify that exemplars are configured in the data source settings under &lt;strong&gt;Exemplars&lt;/strong&gt; (at least one exemplar link must be defined).&lt;/li&gt;
&lt;li&gt;Check that your Prometheus version supports exemplars (2.26&#43;).&lt;/li&gt;
&lt;li&gt;Ensure your instrumented application is actually sending exemplar data with metrics.&lt;/li&gt;
&lt;li&gt;Verify the tracing data source is correctly configured for the exemplar link.&lt;/li&gt;
&lt;li&gt;Enable the &lt;strong&gt;Exemplars&lt;/strong&gt; toggle in the query editor for the specific query.&lt;/li&gt;
&lt;li&gt;Exemplars only appear with &lt;strong&gt;Range&lt;/strong&gt; query type, not &lt;strong&gt;Instant&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;annotation-errors&#34;&gt;Annotation errors&lt;/h2&gt;
&lt;p&gt;The following issues occur when using Prometheus as a data source for annotations.&lt;/p&gt;
&lt;h3 id=&#34;annotations-not-appearing&#34;&gt;Annotations not appearing&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; You&amp;rsquo;ve configured a Prometheus annotation query, but no annotations appear on your dashboard.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Possible causes and solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Cause&lt;/th&gt;
              &lt;th&gt;Solution&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Query returns no data in the current time range&lt;/td&gt;
              &lt;td&gt;Verify the query returns results in Explore for the dashboard&amp;rsquo;s time range.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Query returns continuous data (too many annotations)&lt;/td&gt;
              &lt;td&gt;Every returned data point creates an annotation. If the query returns hundreds of points, annotations may render but are too dense to see. Increase the &lt;strong&gt;Min step&lt;/strong&gt; or refine your query to only return data at event moments.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Wrong data source selected&lt;/td&gt;
              &lt;td&gt;Verify the correct Prometheus data source is selected in the annotation configuration.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Annotation is disabled&lt;/td&gt;
              &lt;td&gt;Check that the annotation toggle is enabled (eye icon) in the dashboard&amp;rsquo;s annotation settings.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Time range mismatch&lt;/td&gt;
              &lt;td&gt;Expand the dashboard time range to include the events you expect to see.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&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;Prometheus annotations create a marker for &lt;strong&gt;every data point&lt;/strong&gt; returned by the query. There&amp;rsquo;s no automatic filtering of zero values. If you only want annotations at specific moments, your PromQL expression must return data only at those times (for example, using &lt;code&gt;&amp;gt; 0&lt;/code&gt;, &lt;code&gt;changes() &amp;gt; 0&lt;/code&gt;, or the &lt;code&gt;ALERTS&lt;/code&gt; metric).&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;For more information on configuring annotations, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/annotations/&#34;&gt;Prometheus annotations&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;alerting-errors&#34;&gt;Alerting errors&lt;/h2&gt;
&lt;p&gt;The following issues occur when using Prometheus with Grafana Alerting.&lt;/p&gt;
&lt;h3 id=&#34;transient-alert-errors-triggering-false-alarms&#34;&gt;Transient alert errors triggering false alarms&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Error messages:&lt;/strong&gt; &lt;code&gt;sse.dependencyError&lt;/code&gt;, &lt;code&gt;sse.dataQueryError&lt;/code&gt;, &amp;ldquo;context deadline exceeded&amp;rdquo;, &amp;ldquo;i/o timeout&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; Alert rules intermittently fire due to execution errors rather than genuine threshold breaches. On-call teams receive false positive notifications. Alert state history shows error states caused by transient backend issues (network blips, HTTP 502/500 responses, timeouts) rather than actual metric conditions being met.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cause:&lt;/strong&gt; By default, when an alert rule encounters an execution error or timeout, Grafana sets the alert state to &lt;strong&gt;Alerting&lt;/strong&gt; — which fires the alert. Transient connectivity issues between Grafana and Prometheus (i/o timeouts, deadline exceeded, brief outages) trigger this behavior even though the underlying metric hasn&amp;rsquo;t crossed its threshold.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open each affected alert rule for editing.&lt;/li&gt;
&lt;li&gt;In the alert conditions section, change &lt;strong&gt;Alert state if execution error or timeout&lt;/strong&gt; from &lt;strong&gt;Alerting&lt;/strong&gt; to &lt;strong&gt;Keep Last State&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Save the rule.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This ensures the alert retains its previous state during transient errors and only fires when a successful evaluation confirms the threshold is breached.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;If errors are frequent&lt;/strong&gt;, also investigate:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Network stability between Grafana and Prometheus.&lt;/li&gt;
&lt;li&gt;Prometheus resource utilization (CPU, memory, disk I/O).&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Query timeout&lt;/strong&gt; setting in the data source configuration — increase it if complex queries regularly exceed the limit.&lt;/li&gt;
&lt;li&gt;Query complexity — simplify queries or use recording rules to pre-compute expensive expressions.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For configuration details, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/alerting/#configure-alert-state-for-execution-errors&#34;&gt;Configure alert state for execution errors&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;alert-rule-fails-to-evaluate&#34;&gt;Alert rule fails to evaluate&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; An alert rule using a Prometheus query shows evaluation errors or remains in a &amp;ldquo;No Data&amp;rdquo; state.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Possible causes and solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Cause&lt;/th&gt;
              &lt;th&gt;Solution&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Template variables in query&lt;/td&gt;
              &lt;td&gt;Alert queries don&amp;rsquo;t support template variables. Replace variables with hard-coded values.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Query timeout&lt;/td&gt;
              &lt;td&gt;Simplify the query or increase the evaluation timeout. Use recording rules for complex expressions.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Data source unreachable&lt;/td&gt;
              &lt;td&gt;Verify the Prometheus data source connection is working (test it in the data source settings).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;No data in range&lt;/td&gt;
              &lt;td&gt;Ensure the metric has recent data. Check that Prometheus is actively scraping the target.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;data-source-managed-rules-not-visible&#34;&gt;Data source-managed rules not visible&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; Prometheus alerting rules don&amp;rsquo;t appear in the Grafana Alerting UI.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify that &lt;strong&gt;Manage alerts via Alerting UI&lt;/strong&gt; is enabled in the data source configuration.&lt;/li&gt;
&lt;li&gt;Check that Prometheus has alerting rules configured in its rule files.&lt;/li&gt;
&lt;li&gt;Ensure Grafana can access the Prometheus rules API endpoint (&lt;code&gt;/api/v1/rules&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;For Prometheus (unlike Mimir), the Alerting UI only supports viewing existing rules, not creating new ones.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For more information on alerting with Prometheus, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/prometheus/alerting/&#34;&gt;Prometheus alerting&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;get-additional-help&#34;&gt;Get additional help&lt;/h2&gt;
&lt;p&gt;If you continue to experience issues after following this troubleshooting guide:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Check the &lt;a href=&#34;https://prometheus.io/docs/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus documentation&lt;/a&gt; for API and PromQL guidance.&lt;/li&gt;
&lt;li&gt;Review the &lt;a href=&#34;https://community.grafana.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana community forums&lt;/a&gt; for similar issues.&lt;/li&gt;
&lt;li&gt;Contact Grafana Support if you are a Cloud Pro, Cloud Contracted, or Enterprise user.&lt;/li&gt;
&lt;li&gt;When reporting issues, include:
&lt;ul&gt;
&lt;li&gt;Grafana version&lt;/li&gt;
&lt;li&gt;Prometheus version and type (Prometheus, Mimir, Cortex, Thanos)&lt;/li&gt;
&lt;li&gt;Error messages (redact sensitive information)&lt;/li&gt;
&lt;li&gt;Steps to reproduce&lt;/li&gt;
&lt;li&gt;Relevant configuration such as data source settings, query timeout, and TLS settings (redact tokens, passwords, and other credentials)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="troubleshoot-prometheus-data-source-issues">Troubleshoot Prometheus data source issues&lt;/h1>
&lt;p>This document provides troubleshooting information for common errors you may encounter when using the Prometheus data source in Grafana.&lt;/p>
&lt;h2 id="connection-errors">Connection errors&lt;/h2>
&lt;p>The following errors occur when Grafana cannot establish or maintain a connection to Prometheus.&lt;/p></description></item></channel></rss>