<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Data sources on Grafana Labs</title><link>https://grafana.com/docs/grafana/v8.4/datasources/</link><description>Recent content in Data sources on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/grafana/v8.4/datasources/index.xml" rel="self" type="application/rss+xml"/><item><title>Add data source</title><link>https://grafana.com/docs/grafana/v8.4/datasources/add-a-data-source/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/add-a-data-source/</guid><content><![CDATA[&lt;h1 id=&#34;add-a-data-source&#34;&gt;Add a data source&lt;/h1&gt;
&lt;p&gt;Before you can create your first dashboard, you need to add your data source.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Only users with the organization Admin role can add data sources.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;To add a data source:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Move your cursor to the cog icon on the side menu which will show the configuration options.&lt;/p&gt;
&lt;figure
       class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
       style=&#34;max-width: 150px;&#34;
       itemprop=&#34;associatedMedia&#34;
       itemscope=&#34;&#34;
       itemtype=&#34;http://schema.org/ImageObject&#34;
     &gt;&lt;a
           class=&#34;lightbox-link&#34;
           href=&#34;/static/img/docs/v75/sidemenu-datasource-7-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 &#34;
             data-src=&#34;/static/img/docs/v75/sidemenu-datasource-7-5.png&#34;data-srcset=&#34;/static/img/docs/v75/sidemenu-datasource-7-5.png?w=320 320w, /static/img/docs/v75/sidemenu-datasource-7-5.png?w=550 550w, /static/img/docs/v75/sidemenu-datasource-7-5.png?w=750 750w, /static/img/docs/v75/sidemenu-datasource-7-5.png?w=900 900w, /static/img/docs/v75/sidemenu-datasource-7-5.png?w=1040 1040w, /static/img/docs/v75/sidemenu-datasource-7-5.png?w=1240 1240w, /static/img/docs/v75/sidemenu-datasource-7-5.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;170&#34;height=&#34;212&#34;/&gt;
           &lt;noscript&gt;
             &lt;img
               src=&#34;/static/img/docs/v75/sidemenu-datasource-7-5.png&#34;
               alt=&#34;&#34;width=&#34;170&#34;height=&#34;212&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
           &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click on &lt;strong&gt;Data sources&lt;/strong&gt;. The data sources page opens showing a list of previously configured data sources for the Grafana instance.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Add data source&lt;/strong&gt; to see a list of all supported data sources.&lt;/p&gt;
&lt;figure
       class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
       style=&#34;max-width: 600px;&#34;
       itemprop=&#34;associatedMedia&#34;
       itemscope=&#34;&#34;
       itemtype=&#34;http://schema.org/ImageObject&#34;
     &gt;&lt;a
           class=&#34;lightbox-link&#34;
           href=&#34;/static/img/docs/v75/add-data-source-7-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 &#34;
             data-src=&#34;/static/img/docs/v75/add-data-source-7-5.png&#34;data-srcset=&#34;/static/img/docs/v75/add-data-source-7-5.png?w=320 320w, /static/img/docs/v75/add-data-source-7-5.png?w=550 550w, /static/img/docs/v75/add-data-source-7-5.png?w=750 750w, /static/img/docs/v75/add-data-source-7-5.png?w=900 900w, /static/img/docs/v75/add-data-source-7-5.png?w=1040 1040w, /static/img/docs/v75/add-data-source-7-5.png?w=1240 1240w, /static/img/docs/v75/add-data-source-7-5.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;957&#34;height=&#34;925&#34;/&gt;
           &lt;noscript&gt;
             &lt;img
               src=&#34;/static/img/docs/v75/add-data-source-7-5.png&#34;
               alt=&#34;&#34;width=&#34;957&#34;height=&#34;925&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
           &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Search for a specific data source by entering the name in the search dialog. Or you can scroll through supported data sources grouped into time series, logging, tracing and other categories.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Move the cursor over the data source you want to add.&lt;/p&gt;
&lt;figure
       class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
       style=&#34;max-width: 700px;&#34;
       itemprop=&#34;associatedMedia&#34;
       itemscope=&#34;&#34;
       itemtype=&#34;http://schema.org/ImageObject&#34;
     &gt;&lt;a
           class=&#34;lightbox-link&#34;
           href=&#34;/static/img/docs/v75/select-data-source-7-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 &#34;
             data-src=&#34;/static/img/docs/v75/select-data-source-7-5.png&#34;data-srcset=&#34;/static/img/docs/v75/select-data-source-7-5.png?w=320 320w, /static/img/docs/v75/select-data-source-7-5.png?w=550 550w, /static/img/docs/v75/select-data-source-7-5.png?w=750 750w, /static/img/docs/v75/select-data-source-7-5.png?w=900 900w, /static/img/docs/v75/select-data-source-7-5.png?w=1040 1040w, /static/img/docs/v75/select-data-source-7-5.png?w=1240 1240w, /static/img/docs/v75/select-data-source-7-5.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;844&#34;height=&#34;134&#34;/&gt;
           &lt;noscript&gt;
             &lt;img
               src=&#34;/static/img/docs/v75/select-data-source-7-5.png&#34;
               alt=&#34;&#34;width=&#34;844&#34;height=&#34;134&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
           &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Select&lt;/strong&gt;. The data source configuration page opens.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Configure the data source following instructions specific to that data source. See &lt;a href=&#34;./&#34;&gt;Data sources&lt;/a&gt; for links to configuration instructions for all supported data sources.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="add-a-data-source">Add a data source&lt;/h1>
&lt;p>Before you can create your first dashboard, you need to add your data source.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Note:&lt;/strong> Only users with the organization Admin role can add data sources.&lt;/p></description></item><item><title>Alertmanager</title><link>https://grafana.com/docs/grafana/v8.4/datasources/alertmanager/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/alertmanager/</guid><content><![CDATA[&lt;h1 id=&#34;alertmanager-data-source&#34;&gt;Alertmanager data source&lt;/h1&gt;
&lt;p&gt;Grafana includes built-in support for Prometheus Alertmanager. It is presently in alpha and not accessible unless &lt;a href=&#34;/docs/grafana/latest/administration/configuration/#enable_alpha-1&#34;&gt;alpha plugins are enabled in Grafana settings&lt;/a&gt;. Once you add it as a data source, you can use the &lt;a href=&#34;/docs/grafana/latest/alerting/&#34;&gt;Grafana alerting UI&lt;/a&gt; to manage silences, contact points as well as notification policies. A drop-down option in these pages allows you to switch between Grafana and any configured Alertmanager data sources.&lt;/p&gt;
&lt;h2 id=&#34;alertmanager-implementations&#34;&gt;Alertmanager implementations&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://prometheus.io/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus&lt;/a&gt; and &lt;a href=&#34;https://cortexmetrics.io/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Cortex&lt;/a&gt; (default) implementations of Alertmanager are supported. You can specify implementation in the data source settings page. In case of Prometheus contact points and notification policies are read-only in the Grafana alerting UI, as it does not support updating configuration via HTTP API.&lt;/p&gt;
&lt;h2 id=&#34;provision-the-alertmanager-data-source&#34;&gt;Provision the Alertmanager data source&lt;/h2&gt;
&lt;p&gt;Configure the Alertmanager data sources by updating Grafana&amp;rsquo;s configuration files. For more information on how it works and the settings available, refer to the &lt;a href=&#34;../../administration/provisioning/#datasources&#34;&gt;provisioning docs page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here is an example for provisioning the Alertmanager data source:&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: Alertmanager
    type: alertmanager
    url: http://localhost:9093
    access: proxy
    jsonData:
      implementation: &amp;#39;prometheus&amp;#39; # alternatively &amp;#39;cortex&amp;#39;
    # optionally
    basicAuth: true
    basicAuthUser: my_user
    basicAuthPassword: test_password&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="alertmanager-data-source">Alertmanager data source&lt;/h1>
&lt;p>Grafana includes built-in support for Prometheus Alertmanager. It is presently in alpha and not accessible unless &lt;a href="/docs/grafana/latest/administration/configuration/#enable_alpha-1">alpha plugins are enabled in Grafana settings&lt;/a>. Once you add it as a data source, you can use the &lt;a href="/docs/grafana/latest/alerting/">Grafana alerting UI&lt;/a> to manage silences, contact points as well as notification policies. A drop-down option in these pages allows you to switch between Grafana and any configured Alertmanager data sources.&lt;/p></description></item><item><title>AWS CloudWatch</title><link>https://grafana.com/docs/grafana/v8.4/datasources/aws-cloudwatch/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/aws-cloudwatch/</guid><content><![CDATA[&lt;h1 id=&#34;aws-cloudwatch-data-source&#34;&gt;AWS CloudWatch data source&lt;/h1&gt;
&lt;p&gt;Grafana ships with built-in support for CloudWatch. This topic describes queries, templates, variables, and other configuration specific to the CloudWatch data source. For instructions on how to add a data source to Grafana, refer to &lt;a href=&#34;../add-a-data-source/&#34;&gt;Add a data source&lt;/a&gt;. Only users with the organization admin role can add data sources.&lt;/p&gt;
&lt;p&gt;Once you have added the Cloudwatch data source, you can build dashboards or use Explore with CloudWatch metrics and CloudWatch Logs.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; For troubleshooting issues when setting up the Cloudwatch data source, check the &lt;code&gt;/var/log/grafana/grafana.log&lt;/code&gt; file.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;configure-the-cloudwatch-data-source&#34;&gt;Configure the CloudWatch data source&lt;/h2&gt;
&lt;p&gt;To access data source settings, hover your mouse over the &lt;strong&gt;Configuration&lt;/strong&gt; (gear) icon, then click &lt;strong&gt;Data Sources&lt;/strong&gt;, and then click the AWS Cloudwatch data source.&lt;/p&gt;
&lt;p&gt;For authentication options and configuration details, see &lt;a href=&#34;aws-authentication/&#34;&gt;AWS authentication&lt;/a&gt; topic.&lt;/p&gt;
&lt;h3 id=&#34;cloudwatch-specific-data-source-configuration&#34;&gt;CloudWatch specific data source configuration&lt;/h3&gt;
&lt;h4 id=&#34;iam-policies&#34;&gt;IAM policies&lt;/h4&gt;
&lt;p&gt;Grafana needs permissions granted via IAM to be able to read CloudWatch metrics and EC2 tags/instances/regions/alarms. You can attach these permissions to the IAM role or IAM user configured in the previous step.&lt;/p&gt;
&lt;h5 id=&#34;metrics-only-example&#34;&gt;Metrics only example:&lt;/h5&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
  &amp;#34;Version&amp;#34;: &amp;#34;2012-10-17&amp;#34;,
  &amp;#34;Statement&amp;#34;: [
    {
      &amp;#34;Sid&amp;#34;: &amp;#34;AllowReadingMetricsFromCloudWatch&amp;#34;,
      &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,
      &amp;#34;Action&amp;#34;: [
        &amp;#34;cloudwatch:DescribeAlarmsForMetric&amp;#34;,
        &amp;#34;cloudwatch:DescribeAlarmHistory&amp;#34;,
        &amp;#34;cloudwatch:DescribeAlarms&amp;#34;,
        &amp;#34;cloudwatch:ListMetrics&amp;#34;,
        &amp;#34;cloudwatch:GetMetricData&amp;#34;,
        &amp;#34;cloudwatch:GetInsightRuleReport&amp;#34;
      ],
      &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;
    },
    {
      &amp;#34;Sid&amp;#34;: &amp;#34;AllowReadingTagsInstancesRegionsFromEC2&amp;#34;,
      &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,
      &amp;#34;Action&amp;#34;: [&amp;#34;ec2:DescribeTags&amp;#34;, &amp;#34;ec2:DescribeInstances&amp;#34;, &amp;#34;ec2:DescribeRegions&amp;#34;],
      &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;
    },
    {
      &amp;#34;Sid&amp;#34;: &amp;#34;AllowReadingResourcesForTags&amp;#34;,
      &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,
      &amp;#34;Action&amp;#34;: &amp;#34;tag:GetResources&amp;#34;,
      &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h5 id=&#34;logs-only-example&#34;&gt;Logs only example:&lt;/h5&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
  &amp;#34;Version&amp;#34;: &amp;#34;2012-10-17&amp;#34;,
  &amp;#34;Statement&amp;#34;: [
    {
      &amp;#34;Sid&amp;#34;: &amp;#34;AllowReadingLogsFromCloudWatch&amp;#34;,
      &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,
      &amp;#34;Action&amp;#34;: [
        &amp;#34;logs:DescribeLogGroups&amp;#34;,
        &amp;#34;logs:GetLogGroupFields&amp;#34;,
        &amp;#34;logs:StartQuery&amp;#34;,
        &amp;#34;logs:StopQuery&amp;#34;,
        &amp;#34;logs:GetQueryResults&amp;#34;,
        &amp;#34;logs:GetLogEvents&amp;#34;
      ],
      &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;
    },
    {
      &amp;#34;Sid&amp;#34;: &amp;#34;AllowReadingTagsInstancesRegionsFromEC2&amp;#34;,
      &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,
      &amp;#34;Action&amp;#34;: [&amp;#34;ec2:DescribeTags&amp;#34;, &amp;#34;ec2:DescribeInstances&amp;#34;, &amp;#34;ec2:DescribeRegions&amp;#34;],
      &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;
    },
    {
      &amp;#34;Sid&amp;#34;: &amp;#34;AllowReadingResourcesForTags&amp;#34;,
      &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,
      &amp;#34;Action&amp;#34;: &amp;#34;tag:GetResources&amp;#34;,
      &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h5 id=&#34;metrics-and-logs-example&#34;&gt;Metrics and Logs example:&lt;/h5&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
  &amp;#34;Version&amp;#34;: &amp;#34;2012-10-17&amp;#34;,
  &amp;#34;Statement&amp;#34;: [
    {
      &amp;#34;Sid&amp;#34;: &amp;#34;AllowReadingMetricsFromCloudWatch&amp;#34;,
      &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,
      &amp;#34;Action&amp;#34;: [
        &amp;#34;cloudwatch:DescribeAlarmsForMetric&amp;#34;,
        &amp;#34;cloudwatch:DescribeAlarmHistory&amp;#34;,
        &amp;#34;cloudwatch:DescribeAlarms&amp;#34;,
        &amp;#34;cloudwatch:ListMetrics&amp;#34;,
        &amp;#34;cloudwatch:GetMetricData&amp;#34;,
        &amp;#34;cloudwatch:GetInsightRuleReport&amp;#34;
      ],
      &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;
    },
    {
      &amp;#34;Sid&amp;#34;: &amp;#34;AllowReadingLogsFromCloudWatch&amp;#34;,
      &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,
      &amp;#34;Action&amp;#34;: [
        &amp;#34;logs:DescribeLogGroups&amp;#34;,
        &amp;#34;logs:GetLogGroupFields&amp;#34;,
        &amp;#34;logs:StartQuery&amp;#34;,
        &amp;#34;logs:StopQuery&amp;#34;,
        &amp;#34;logs:GetQueryResults&amp;#34;,
        &amp;#34;logs:GetLogEvents&amp;#34;
      ],
      &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;
    },
    {
      &amp;#34;Sid&amp;#34;: &amp;#34;AllowReadingTagsInstancesRegionsFromEC2&amp;#34;,
      &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,
      &amp;#34;Action&amp;#34;: [&amp;#34;ec2:DescribeTags&amp;#34;, &amp;#34;ec2:DescribeInstances&amp;#34;, &amp;#34;ec2:DescribeRegions&amp;#34;],
      &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;
    },
    {
      &amp;#34;Sid&amp;#34;: &amp;#34;AllowReadingResourcesForTags&amp;#34;,
      &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,
      &amp;#34;Action&amp;#34;: &amp;#34;tag:GetResources&amp;#34;,
      &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;namespaces-of-custom-metrics&#34;&gt;Namespaces of Custom Metrics&lt;/h4&gt;
&lt;p&gt;Grafana is not able to load custom namespaces through the GetMetricData API. If you still want your custom metrics to show up in the fields in the query editor, you can specify the names of the namespaces containing the custom metrics in the &lt;em&gt;Namespaces of Custom Metrics&lt;/em&gt; field. The field accepts a multiple namespaces, separated by a comma.&lt;/p&gt;
&lt;h4 id=&#34;timeout&#34;&gt;Timeout&lt;/h4&gt;
&lt;p&gt;Timeout specifically, for CloudWatch Logs queries. Log queries don&amp;rsquo;t recognize standard Grafana query timeout as they don&amp;rsquo;t keep a single request open and instead periodically poll for results. Because of limits on concurrently running queries in CloudWatch they can also take a longer time to finish.&lt;/p&gt;
&lt;h4 id=&#34;x-ray-trace-links&#34;&gt;X-Ray trace links&lt;/h4&gt;
&lt;p&gt;Link an X-Ray data source in the &amp;ldquo;X-Ray trace link&amp;rdquo; section of the configuration page to automatically add links in your logs when the log contains &lt;code&gt;@xrayTraceId&lt;/code&gt; field.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/cloudwatch/xray-trace-link-configuration-8-2.png&#34;
  alt=&#34;Trace link configuration&#34; width=&#34;1336&#34;
     height=&#34;256&#34;/&gt;&lt;/p&gt;
&lt;p&gt;The data source select will contain only existing data source instances of type X-Ray so in order to use this feature you need to have existing X-Ray data source already configured, see &lt;a href=&#34;/grafana/plugins/grafana-x-ray-datasource/&#34;&gt;X-Ray docs&lt;/a&gt; for details.&lt;/p&gt;
&lt;p&gt;The X-Ray link will then appear in the log details section which is accessible by clicking on the log row either in Explore or in dashboard &lt;a href=&#34;../../visualizations/logs-panel/&#34;&gt;Logs panel&lt;/a&gt;. To log the &lt;code&gt;@xrayTraceId&lt;/code&gt; in your logs see the &lt;a href=&#34;https://docs.amazonaws.cn/en_us/xray/latest/devguide/xray-services.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;AWS X-Ray documentation&lt;/a&gt;. To provide the field to Grafana your log queries also have to contain the &lt;code&gt;@xrayTraceId&lt;/code&gt; field, for example using query &lt;code&gt;fields @message, @xrayTraceId&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/cloudwatch/xray-link-log-details-8-2.png&#34;
  alt=&#34;Trace link in log details&#34; width=&#34;1562&#34;
     height=&#34;532&#34;/&gt;&lt;/p&gt;
&lt;h2 id=&#34;cloudwatch-query-editor&#34;&gt;CloudWatch query editor&lt;/h2&gt;
&lt;p&gt;The CloudWatch data source can query data from both CloudWatch metrics and CloudWatch Logs APIs, each with its own specialized query editor. You select which API you want to query with using the query mode switch on top of the editor.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/cloudwatch/cloudwatch-query-editor-api-modes-8.3.0.png&#34;
  alt=&#34;CloudWatch API modes&#34; width=&#34;523&#34;
     height=&#34;169&#34;/&gt;&lt;/p&gt;
&lt;h3 id=&#34;metrics-query-editor&#34;&gt;Metrics query editor&lt;/h3&gt;
&lt;p&gt;The metrics query editor allows you to build two types of queries - &lt;strong&gt;Metric Search&lt;/strong&gt; and &lt;strong&gt;Metric Query&lt;/strong&gt;.&lt;/p&gt;
&lt;h4 id=&#34;using-the-metric-search-option&#34;&gt;Using the Metric Search option&lt;/h4&gt;
&lt;p&gt;To create a valid Metric Search query specify the namespace, metric name and at least one statistic.&lt;/p&gt;
&lt;p&gt;If &lt;code&gt;Match Exact&lt;/code&gt; is enabled, you also need to specify all the dimensions of the metric you’re querying, so that the &lt;a href=&#34;https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/search-expression-syntax.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;metric schema&lt;/a&gt; matches exactly. If &lt;code&gt;Match Exact&lt;/code&gt; is disabled, you can specify any number of dimensions by which you’d like to filter. Up to 100 metrics matching your filter criteria will be returned.&lt;/p&gt;
&lt;h5 id=&#34;dynamic-queries-using-dimension-wildcards&#34;&gt;Dynamic queries using dimension wildcards&lt;/h5&gt;
&lt;p&gt;You can monitor a dynamic list of metrics by using the asterisk (*) wildcard for one or more dimension values.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/cloudwatch/cloudwatch-dimension-wildcard-8.3.0.png&#34;
  alt=&#34;CloudWatch dimension wildcard&#34; width=&#34;788&#34;
     height=&#34;375&#34;/&gt;&lt;/p&gt;
&lt;p&gt;In this example, the query returns all metrics in the namespace &lt;code&gt;AWS/EC2&lt;/code&gt; with a metric name of &lt;code&gt;CPUUtilization&lt;/code&gt; and ANY value for the &lt;code&gt;InstanceId&lt;/code&gt; dimension are queried. This can help you monitor metrics for AWS resources, like EC2 instances or containers. When new instances are created as part of an auto scaling event, they will automatically appear in the graph without you having to track the new instance IDs. This capability is currently limited to retrieving up to 100 metrics.&lt;/p&gt;
&lt;p&gt;You can expand the &lt;a href=&#34;/docs/grafana/latest/panels/queries/#query-inspector-button&#34;&gt;Query inspector&lt;/a&gt; button and click &lt;code&gt;Meta Data&lt;/code&gt; to see the search expression that is automatically built to support wildcards. To learn more about search expressions, visit the &lt;a href=&#34;https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/search-expression-syntax.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;CloudWatch documentation&lt;/a&gt;. By default, the search expression is defined in such a way that the queried metrics must match the defined dimension names exactly. This means that in the example only metrics with exactly one dimension with the name ‘InstanceId’ will be returned.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/cloudwatch/cloudwatch-meta-inspector-8.3.0.png&#34;
  alt=&#34;CloudWatch Meta Inspector&#34; width=&#34;928&#34;
     height=&#34;161&#34;/&gt;&lt;/p&gt;
&lt;p&gt;You can disable &lt;code&gt;Match Exact&lt;/code&gt; to include metrics that have other dimensions defined. Disabling &lt;code&gt;Match Exact&lt;/code&gt; also creates a search expression even if you don’t use wildcards. We simply search for any metric that matches at least the namespace, metric name, and all defined dimensions.&lt;/p&gt;
&lt;h5 id=&#34;multi-value-template-variables&#34;&gt;Multi-value template variables&lt;/h5&gt;
&lt;p&gt;When defining dimension values based on multi-valued template variables, a search expression is used to query for the matching metrics. This enables the use of multiple template variables in one query and also allows you to use template variables for queries that have the &lt;code&gt;Match Exact&lt;/code&gt; option disabled.&lt;/p&gt;
&lt;p&gt;Search expressions are currently limited to 1024 characters, so your query may fail if you have a long list of values. We recommend using the asterisk (&lt;code&gt;*&lt;/code&gt;) wildcard instead of the &lt;code&gt;All&lt;/code&gt; option if you want to query all metrics that have any value for a certain dimension name.&lt;/p&gt;
&lt;p&gt;The use of multi-valued template variables is only supported for dimension values. Using multi-valued template variables for &lt;code&gt;Region&lt;/code&gt;, &lt;code&gt;Namespace&lt;/code&gt;, or &lt;code&gt;Metric Name&lt;/code&gt; is not supported.&lt;/p&gt;
&lt;h5 id=&#34;metric-math-expressions&#34;&gt;Metric math expressions&lt;/h5&gt;
&lt;p&gt;You can create new time series metrics by operating on top of CloudWatch metrics using mathematical functions. Arithmetic operators, unary subtraction and other functions are supported and can be applied to CloudWatch metrics. More details on the available functions can be found on &lt;a href=&#34;https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/using-metric-math.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;AWS Metric Math&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As an example, if you want to apply arithmetic operations on a metric, you can do it by giving an id (a unique string) to the raw metric as shown below. You can then use this id and apply arithmetic operations to it in the Expression field of the new metric.&lt;/p&gt;
&lt;p&gt;Please note that in the case you use the expression field to reference another query, like &lt;code&gt;queryA * 2&lt;/code&gt;, it will not be possible to create an alert rule based on that query.&lt;/p&gt;
&lt;h5 id=&#34;deep-linking-from-grafana-panels-to-the-cloudwatch-console&#34;&gt;Deep linking from Grafana panels to the CloudWatch console&lt;/h5&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--right&#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/v65/cloudwatch-deep-linking.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/v65/cloudwatch-deep-linking.png&#34;data-srcset=&#34;/static/img/docs/v65/cloudwatch-deep-linking.png?w=320 320w, /static/img/docs/v65/cloudwatch-deep-linking.png?w=550 550w, /static/img/docs/v65/cloudwatch-deep-linking.png?w=750 750w, /static/img/docs/v65/cloudwatch-deep-linking.png?w=900 900w, /static/img/docs/v65/cloudwatch-deep-linking.png?w=1040 1040w, /static/img/docs/v65/cloudwatch-deep-linking.png?w=1240 1240w, /static/img/docs/v65/cloudwatch-deep-linking.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;CloudWatch deep linking&#34;width=&#34;1000&#34;height=&#34;420&#34;title=&#34;CloudWatch deep linking&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v65/cloudwatch-deep-linking.png&#34;
            alt=&#34;CloudWatch deep linking&#34;width=&#34;1000&#34;height=&#34;420&#34;title=&#34;CloudWatch deep linking&#34;class=&#34;docs-image--right&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;CloudWatch deep linking&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Left clicking a time series in the panel shows a context menu with a link to &lt;code&gt;View in CloudWatch console&lt;/code&gt;. Clicking that link will open a new tab that will take you to the CloudWatch console and display all the metrics for that query. If you&amp;rsquo;re not currently logged in to the CloudWatch console, the link will forward you to the login page. The provided link is valid for any account but will only display the right metrics if you&amp;rsquo;re logged in to the account that corresponds to the selected data source in Grafana.&lt;/p&gt;
&lt;p&gt;This feature is not available for metrics that are based on metric math expressions.&lt;/p&gt;
&lt;h3 id=&#34;using-the-metric-query-option&#34;&gt;Using the Metric Query option&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This query option is available in Grafana 8.3 and higher versions only.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Metrics Query in the CloudWatch plugin is what is referred to as &lt;strong&gt;Metric Insights&lt;/strong&gt; in the AWS console. It&amp;rsquo;s a fast, flexible, SQL-based query engine that enables you to identify trends and patterns across millions of operational metrics in real time. It uses a dialect of SQL. The query syntax is as follows.&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;
SELECT FUNCTION(MetricName)
FROM Namespace | SCHEMA(...)
[ WHERE labelKey OPERATOR labelValue [AND|...]]
[ GROUP BY labelKey [, ...]]
[ ORDER BY FUNCTION() [DESC | ASC] ]
[ LIMIT number]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The following table provides basic explanation of the query keywords. For details about the Metrics Insights syntax, refer to the &lt;a href=&#34;https://docs.aws.amazon.com/console/cloudwatch/metricsinsights-syntax&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;AWS documentation&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;Keyword&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;FUNCTION&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Required. Specifies the aggregate function to use, and also specifies the name of the metric that is to be queried. Valid values are AVG, COUNT, MAX, MIN, and SUM&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;MetricName&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Required. For example, &lt;code&gt;CPUUtilization&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;FROM&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Required. Specifies the source of the metric. You can specify either the metric namespace that contains the metric that is to be queried, or a SCHEMA table function. Some namespace examples are 1&lt;code&gt;AWS/EC2&lt;/code&gt;, &lt;code&gt;AWS/Lambda&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;SCHEMA&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Optional. Allows you to narrow down the query results to only the metrics that is an exact match or to metrics that do noy match.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;WHERE&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Optional. Filters the results to only those metrics that match your specified expression. For example, &lt;code&gt;WHERE InstanceType != &#39;c3.4xlarge&#39;&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;GROUP BY&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Optional. Groups the query results into multiple time series. For example, &lt;code&gt;GROUP BY ServiceName&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ORDER BY&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Optional. Specifies the order of time series that are returned. Options are &lt;code&gt;ASC&lt;/code&gt;, &lt;code&gt;DESC&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;LIMIT&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Optional. Limits the number of time series returned.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;For information about limits for the Metrics Insights, please refer to the &lt;a href=&#34;https://docs.aws.amazon.com/console/cloudwatch/metricsinsights&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;AWS documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Builder mode&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To create a query in Builder mode:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Browse and select a metric namespace, metric name, filter, group, and order options using information from the table above.&lt;/li&gt;
&lt;li&gt;For each of these options, choose from the list of possible options.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Grafana automatically constructs a SQL query based on your selections.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Code mode&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To create a query in the Code mode:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Write your SQL query.&lt;/li&gt;
&lt;li&gt;To run the query, click the &lt;strong&gt;Run query&lt;/strong&gt; above the code editor.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The code editor has a built in autocomplete feature that gives suggestions for keywords, aggregations, namespaces, metrics, labels and label values. The suggestions are shown when hitting space, comma or dollar character. You can also use the keyboard combination CTRL&#43;Space.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/cloudwatch/cloudwatch-code-editor-autocomplete-8.3.0.gif&#34;
  alt=&#34;Code editor autocomplete&#34; width=&#34;1249&#34;
     height=&#34;692&#34;/&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Usage of template variables in the code editor might interfere the autocompletion.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3 id=&#34;common-metric-query-editor-fields&#34;&gt;Common metric query editor fields&lt;/h3&gt;
&lt;p&gt;At the bottom of the metric query editor, you&amp;rsquo;ll find three fields that are common to both &lt;em&gt;Metric Search&lt;/em&gt; and &lt;em&gt;Metric Query&lt;/em&gt;.&lt;/p&gt;
&lt;h4 id=&#34;id&#34;&gt;Id&lt;/h4&gt;
&lt;p&gt;The GetMetricData API requires that all queries have a unique ID. Use this field to specify an ID of choice. The ID can include numbers, letters, and underscore, and must start with a lowercase letter. If no ID is specified, grafana will generate an ID using the following pattern &lt;code&gt;query[refId of the current query row]&lt;/code&gt;, e.g &lt;code&gt;queryA&lt;/code&gt; for the first query row in the panel editor.&lt;/p&gt;
&lt;p&gt;The ID can be used to reference queries in Metric Math expressions.&lt;/p&gt;
&lt;h4 id=&#34;period&#34;&gt;Period&lt;/h4&gt;
&lt;p&gt;A period is the length of time associated with a specific Amazon CloudWatch statistic. Periods are defined in numbers of seconds, and valid values for period are 1, 5, 10, 30, or any multiple of 60.&lt;/p&gt;
&lt;p&gt;If the period field is left blank or set to &lt;code&gt;auto&lt;/code&gt;, then it calculates automatically based on the time range and &lt;a href=&#34;https://aws.amazon.com/about-aws/whats-new/2016/11/cloudwatch-extends-metrics-retention-and-new-user-interface/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;cloudwatch&amp;rsquo;s retention policy&lt;/a&gt;. The formula used is &lt;code&gt;time range in seconds / 2000&lt;/code&gt;, and then it snaps to the next higher value in an array of predefined periods &lt;code&gt;[60, 300, 900, 3600, 21600, 86400]&lt;/code&gt; after removing periods based on retention. By clicking &lt;code&gt;Show Query Preview&lt;/code&gt; in the query editor, you can see what period Grafana used.&lt;/p&gt;
&lt;h4 id=&#34;alias&#34;&gt;Alias&lt;/h4&gt;
&lt;p&gt;The alias field allows you to override the default name of the metric legend.&lt;/p&gt;
&lt;h5 id=&#34;alias-patterns&#34;&gt;Alias patterns&lt;/h5&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;Alias Pattern&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Example Result&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{region}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the region&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;us-east-1&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{period}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the period&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;3000&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metric}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the metric&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;CPUUtilization&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{label}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the label returned by the API (only in Metric Search)&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;i-01343&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{namespace}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the namespace (only in Metric Search)&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;AWS/EC2&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{stat}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the statistic (only in Metric Search)&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;Average&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{[dimension name]}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the dimension name (only in Metric Search)&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;i-01343&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;using-the-logs-query-editor&#34;&gt;Using the Logs query editor&lt;/h2&gt;
&lt;p&gt;To query CloudWatch Logs:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Select the region and up to 20 log groups which you want to query.&lt;/li&gt;
&lt;li&gt;Use the main input area to write your query in &lt;a href=&#34;https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;CloudWatch Logs Query Language&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can also write queries returning time series data by using the &lt;a href=&#34;https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_Insights-Visualizing-Log-Data.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;stats&lt;/code&gt; command&lt;/a&gt;. When making &lt;code&gt;stats&lt;/code&gt; queries in Explore, you have to make sure you are in Metrics Explore mode.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--right&#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/v70/explore-mode-switcher.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/v70/explore-mode-switcher.png&#34;data-srcset=&#34;/static/img/docs/v70/explore-mode-switcher.png?w=320 320w, /static/img/docs/v70/explore-mode-switcher.png?w=550 550w, /static/img/docs/v70/explore-mode-switcher.png?w=750 750w, /static/img/docs/v70/explore-mode-switcher.png?w=900 900w, /static/img/docs/v70/explore-mode-switcher.png?w=1040 1040w, /static/img/docs/v70/explore-mode-switcher.png?w=1240 1240w, /static/img/docs/v70/explore-mode-switcher.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Explore mode switcher&#34;width=&#34;456&#34;height=&#34;48&#34;title=&#34;Explore mode switcher&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v70/explore-mode-switcher.png&#34;
            alt=&#34;Explore mode switcher&#34;width=&#34;456&#34;height=&#34;48&#34;title=&#34;Explore mode switcher&#34;class=&#34;docs-image--right&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Explore mode switcher&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;deep-linking-from-grafana-panels-to-the-cloudwatch-console-1&#34;&gt;Deep linking from Grafana panels to the CloudWatch console&lt;/h3&gt;
&lt;p&gt;&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--right&#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/v70/cloudwatch-logs-deep-linking.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/v70/cloudwatch-logs-deep-linking.png&#34;data-srcset=&#34;/static/img/docs/v70/cloudwatch-logs-deep-linking.png?w=320 320w, /static/img/docs/v70/cloudwatch-logs-deep-linking.png?w=550 550w, /static/img/docs/v70/cloudwatch-logs-deep-linking.png?w=750 750w, /static/img/docs/v70/cloudwatch-logs-deep-linking.png?w=900 900w, /static/img/docs/v70/cloudwatch-logs-deep-linking.png?w=1040 1040w, /static/img/docs/v70/cloudwatch-logs-deep-linking.png?w=1240 1240w, /static/img/docs/v70/cloudwatch-logs-deep-linking.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;CloudWatch Logs deep linking&#34;width=&#34;858&#34;height=&#34;82&#34;title=&#34;CloudWatch Logs deep linking&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v70/cloudwatch-logs-deep-linking.png&#34;
            alt=&#34;CloudWatch Logs deep linking&#34;width=&#34;858&#34;height=&#34;82&#34;title=&#34;CloudWatch Logs deep linking&#34;class=&#34;docs-image--right&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;CloudWatch Logs deep linking&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
If you&amp;rsquo;d like to view your query in the CloudWatch Logs Insights console, simply click the &lt;code&gt;CloudWatch Logs Insights&lt;/code&gt; button next to the query editor.
If you&amp;rsquo;re not currently logged in to the CloudWatch console, the link will forward you to the login page. The provided link is valid for any account but will only display the right metrics if you&amp;rsquo;re logged in to the account that corresponds to the selected data source in Grafana.&lt;/p&gt;
&lt;h2 id=&#34;alerting&#34;&gt;Alerting&lt;/h2&gt;
&lt;p&gt;Since CloudWatch Logs queries can return numeric data, for example through the use of the &lt;code&gt;stats&lt;/code&gt; command, alerts are supported.
For more information on Grafana alerts, refer to &lt;a href=&#34;../../alerting/&#34;&gt;Alerting&lt;/a&gt; documentation.&lt;/p&gt;
&lt;h2 id=&#34;configure-cloudwatch-with-grafanaini&#34;&gt;Configure CloudWatch with grafana.ini&lt;/h2&gt;
&lt;p&gt;The Grafana &lt;a href=&#34;../../administration/configuration/#aws&#34;&gt;configuration&lt;/a&gt; file includes an &lt;code&gt;AWS&lt;/code&gt; section where you can customize the data source.&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;Configuration 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;code&gt;allowed_auth_providers&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Specifies which authentication providers are allowed for the CloudWatch data source. The following providers are enabled by default in OSS Grafana: &lt;code&gt;default&lt;/code&gt; (AWS SDK default), keys (Access and secret key), credentials (Credentials file), ec2_IAM_role (EC2 IAM role).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;assume_role_enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Allows you to disable &lt;code&gt;assume role (ARN)&lt;/code&gt; in the CloudWatch data source. By default, assume role (ARN) is enabled for OSS Grafana.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;list_metrics_page_limit&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;When a custom namespace is specified in the query editor, the &lt;a href=&#34;https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;List Metrics API&lt;/a&gt; is used to populate the &lt;em&gt;Metrics&lt;/em&gt; field and the &lt;em&gt;Dimension&lt;/em&gt; fields. The API is paginated and returns up to 500 results per page. The CloudWatch data source also limits the number of pages to 500. However, you can change this limit using the &lt;code&gt;list_metrics_page_limit&lt;/code&gt; variable in the &lt;a href=&#34;/docs/grafana/latest/administration/configuration/#aws&#34;&gt;grafana configuration file&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;pricing&#34;&gt;Pricing&lt;/h2&gt;
&lt;p&gt;The Amazon CloudWatch data source for Grafana uses the &lt;code&gt;ListMetrics&lt;/code&gt; and &lt;code&gt;GetMetricData&lt;/code&gt; CloudWatch API calls to list and retrieve metrics.
Pricing for CloudWatch Logs is based on the amount of data ingested, archived, and analyzed via CloudWatch Logs Insights queries.
Every time you pick a dimension in the query editor Grafana will issue a ListMetrics request. Whenever you make a change to the queries in the query editor, one new request to GetMetricData will be issued.&lt;/p&gt;
&lt;p&gt;In Grafana version 6.5 or higher, all API requests to GetMetricStatistics have been replaced with calls to GetMetricData to provide better support for CloudWatch metric math and enables the automatic generation of search expressions when using wildcards or disabling the &lt;code&gt;Match Exact&lt;/code&gt; option. While GetMetricStatistics qualified for the CloudWatch API free tier, this is not the case for GetMetricData calls.&lt;/p&gt;
&lt;p&gt;For more information, please refer to the &lt;a href=&#34;https://aws.amazon.com/cloudwatch/pricing/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;CloudWatch pricing page&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;service-quotas&#34;&gt;Service quotas&lt;/h2&gt;
&lt;p&gt;AWS defines quotas, or limits, for resources, actions, and items in your AWS account. Depending on the number of queries in your dashboard and the number of users accessing the dashboard, you may reach the usage limits for various CloudWatch and CloudWatch Logs resources. Note that quotas are defined per account and per region. If you&amp;rsquo;re using multiple regions or have set up more than one CloudWatch data source to query against multiple accounts, you need to request a quota increase for each account and each region in which you hit the limit.&lt;/p&gt;
&lt;p&gt;To request a quota increase, visit the &lt;a href=&#34;https://console.aws.amazon.com/servicequotas/home?r#!/services/monitoring/quotas/L-5E141212&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;AWS Service Quotas console&lt;/a&gt;. For more information, refer to the AWS documentation for &lt;a href=&#34;https://docs.aws.amazon.com/servicequotas/latest/userguide/intro.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Service Quotas&lt;/a&gt; and &lt;a href=&#34;https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_limits.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;CloudWatch limits&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="aws-cloudwatch-data-source">AWS CloudWatch data source&lt;/h1>
&lt;p>Grafana ships with built-in support for CloudWatch. This topic describes queries, templates, variables, and other configuration specific to the CloudWatch data source. For instructions on how to add a data source to Grafana, refer to &lt;a href="../add-a-data-source/">Add a data source&lt;/a>. Only users with the organization admin role can add data sources.&lt;/p></description></item><item><title>Azure Monitor</title><link>https://grafana.com/docs/grafana/v8.4/datasources/azuremonitor/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/azuremonitor/</guid><content><![CDATA[&lt;h1 id=&#34;azure-monitor-data-source&#34;&gt;Azure Monitor data source&lt;/h1&gt;
&lt;p&gt;Grafana includes built-in support for Azure Monitor, the Azure service to maximize the availability and performance of your applications and services in the Azure Cloud. The Azure Monitor data source supports visualizing data from three Azure services:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Azure Monitor Metrics&lt;/strong&gt; to collect numeric data from resources in your Azure account.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Azure Monitor Logs&lt;/strong&gt; to collect log and performance data from your Azure account, and query using the powerful Kusto Language.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Azure Resource Graph&lt;/strong&gt; to quickly query your Azure resources across subscriptions.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This topic explains configuring, querying, and other options specific to the Azure Monitor data source. Refer to &lt;a href=&#34;../add-a-data-source/&#34;&gt;Add a data source&lt;/a&gt; for instructions on how to add a data source to Grafana.&lt;/p&gt;
&lt;h2 id=&#34;azure-monitor-configuration&#34;&gt;Azure Monitor configuration&lt;/h2&gt;
&lt;p&gt;To access Azure Monitor configuration, hover your mouse over the &lt;strong&gt;Configuration&lt;/strong&gt; (gear) icon, click &lt;strong&gt;Data Sources&lt;/strong&gt;, and then select the Azure Monitor data source. If you haven&amp;rsquo;t already, you&amp;rsquo;ll need to &lt;a href=&#34;../add-a-data-source/&#34;&gt;add the Azure Monitor data source&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You must create an app registration and service principal in Azure AD to authenticate the data source. See the &lt;a href=&#34;https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal#get-tenant-and-app-id-values-for-signing-in&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Azure documentation&lt;/a&gt; for configuration details. Alternatively, if you are hosting Grafana in Azure (e.g. App Service, or Azure Virtual Machines) you can configure the Azure Monitor data source to use Managed Identity to securely authenticate without entering credentials into Grafana. Refer to &lt;a href=&#34;#configuring-using-managed-identity&#34;&gt;Configuring using Managed Identity&lt;/a&gt; for more details.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Authentication&lt;/td&gt;
              &lt;td&gt;Enables Managed Identity. Selecting Managed Identity will hide many of the fields below. See &lt;a href=&#34;#configuring-using-managed-identity&#34;&gt;Configuring using Managed Identity&lt;/a&gt; for more details.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Azure Cloud&lt;/td&gt;
              &lt;td&gt;The national cloud for your Azure account. For most users, this is the default &amp;ldquo;Azure&amp;rdquo;. For more information, see &lt;a href=&#34;https://docs.microsoft.com/en-us/azure/active-directory/develop/authentication-national-cloud&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;the Azure documentation.&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Directory (tenant) ID&lt;/td&gt;
              &lt;td&gt;The directory/tenant ID for the Azure AD app registration to use for authentication. See &lt;a href=&#34;https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal#get-tenant-and-app-id-values-for-signing-in&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Get tenant and app ID values for signing in&lt;/a&gt; from the Azure documentation.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Application (client) ID&lt;/td&gt;
              &lt;td&gt;The application/client ID for the Azure AD app registration to use for authentication.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Client secret&lt;/td&gt;
              &lt;td&gt;The application client secret for the Azure AD app registration to use for authentication. See &lt;a href=&#34;https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal#option-2-create-a-new-application-secret&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Create a new application secret&lt;/a&gt; from the Azure documentation.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Default subscription&lt;/td&gt;
              &lt;td&gt;&lt;em&gt;(optional)&lt;/em&gt; Sets a default subscription for template variables to use&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Default workspace&lt;/td&gt;
              &lt;td&gt;&lt;em&gt;(optional)&lt;/em&gt; Sets a default workspace for Log Analytics-based template variable queries to use&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;azure-monitor-query-editor&#34;&gt;Azure Monitor query editor&lt;/h2&gt;
&lt;p&gt;The Azure Monitor data source has three different modes depending on which Azure service you wish to query:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Metrics&lt;/strong&gt; for &lt;a href=&#34;#querying-azure-monitor-metrics&#34;&gt;Azure Monitor Metrics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Logs&lt;/strong&gt; for &lt;a href=&#34;#querying-azure-monitor-logs&#34;&gt;Azure Monitor Logs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#querying-azure-resource-graph&#34;&gt;&lt;strong&gt;Azure Resource Graph&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;querying-azure-monitor-metrics&#34;&gt;Querying Azure Monitor Metrics&lt;/h3&gt;
&lt;p&gt;Azure Monitor Metrics collects numeric data from &lt;a href=&#34;https://docs.microsoft.com/en-us/azure/azure-monitor/monitor-reference&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;supported resources&lt;/a&gt; and allows you to query them to investigate the health and utilization of your resources to maximise availability and performance.&lt;/p&gt;
&lt;p&gt;Metrics are a lightweight format that only stores simple numeric data in a particular structure. Metrics is capable for supporting near real-time scenarios making it useful for fast detection of issues. Azure Monitor Logs can store a variety of different data types each with their own structure.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 800px;&#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/azure-monitor/query-editor-metrics.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/azure-monitor/query-editor-metrics.png&#34;data-srcset=&#34;/static/img/docs/azure-monitor/query-editor-metrics.png?w=320 320w, /static/img/docs/azure-monitor/query-editor-metrics.png?w=550 550w, /static/img/docs/azure-monitor/query-editor-metrics.png?w=750 750w, /static/img/docs/azure-monitor/query-editor-metrics.png?w=900 900w, /static/img/docs/azure-monitor/query-editor-metrics.png?w=1040 1040w, /static/img/docs/azure-monitor/query-editor-metrics.png?w=1240 1240w, /static/img/docs/azure-monitor/query-editor-metrics.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Azure Logs Metrics sample query visualizing CPU percentage over time&#34;width=&#34;1272&#34;height=&#34;916&#34;title=&#34;Azure Logs Metrics sample query visualizing CPU percentage over time&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/azure-monitor/query-editor-metrics.png&#34;
            alt=&#34;Azure Logs Metrics sample query visualizing CPU percentage over time&#34;width=&#34;1272&#34;height=&#34;916&#34;title=&#34;Azure Logs Metrics sample query visualizing CPU percentage over time&#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;Azure Logs Metrics sample query visualizing CPU percentage over time&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h4 id=&#34;your-first-azure-monitor-metrics-query&#34;&gt;Your first Azure Monitor Metrics query&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Select the Metrics service&lt;/li&gt;
&lt;li&gt;Select a resource to pull metrics from using the subscription, resource group, resource type, and resource fields.&lt;/li&gt;
&lt;li&gt;Some resources, such as storage accounts, organise metrics under multiple metric namespaces. Grafana will pick a default namespace, but change this to see which other metrics are available.&lt;/li&gt;
&lt;li&gt;Select a metric from the Metric field.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Optionally, you can apply further aggregations or filter by dimensions for further analysis.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Change the aggregation from the default average to show minimum, maximum or total values.&lt;/li&gt;
&lt;li&gt;Set a specific custom time grain. By default Grafana will automatically select a time grain interval based on your selected time range.&lt;/li&gt;
&lt;li&gt;For metrics that have multiple dimensions, you can split and filter further the returned metrics. For example, the Application Insights dependency calls metric supports returning multiple time series for successful vs unsuccessful calls.&lt;/li&gt;
&lt;/ol&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 800px;&#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/azure-monitor/query-editor-metrics-dimensions.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/azure-monitor/query-editor-metrics-dimensions.png&#34;data-srcset=&#34;/static/img/docs/azure-monitor/query-editor-metrics-dimensions.png?w=320 320w, /static/img/docs/azure-monitor/query-editor-metrics-dimensions.png?w=550 550w, /static/img/docs/azure-monitor/query-editor-metrics-dimensions.png?w=750 750w, /static/img/docs/azure-monitor/query-editor-metrics-dimensions.png?w=900 900w, /static/img/docs/azure-monitor/query-editor-metrics-dimensions.png?w=1040 1040w, /static/img/docs/azure-monitor/query-editor-metrics-dimensions.png?w=1240 1240w, /static/img/docs/azure-monitor/query-editor-metrics-dimensions.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Azure Monitor Metrics screenshot showing Dimensions&#34;width=&#34;920&#34;height=&#34;329&#34;title=&#34;Azure Monitor Metrics screenshot showing Dimensions&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/azure-monitor/query-editor-metrics-dimensions.png&#34;
            alt=&#34;Azure Monitor Metrics screenshot showing Dimensions&#34;width=&#34;920&#34;height=&#34;329&#34;title=&#34;Azure Monitor Metrics screenshot showing Dimensions&#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;Azure Monitor Metrics screenshot showing Dimensions&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;The options available will change depending on what is most relevant to the selected metric.&lt;/p&gt;
&lt;h4 id=&#34;legend-alias-formatting&#34;&gt;Legend alias formatting&lt;/h4&gt;
&lt;p&gt;The legend label for Metrics can be changed using aliases. In the Legend Format field, you can combine aliases defined below any way you want e.g&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Blob Type: {{ blobtype }}&lt;/code&gt; becomes &lt;code&gt;Blob Type: PageBlob&lt;/code&gt;, &lt;code&gt;Blob Type: BlockBlob&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{{ resourcegroup }} - {{ resourcename }}&lt;/code&gt; becomes &lt;code&gt;production - web_server&lt;/code&gt;&lt;/li&gt;
&lt;/ul&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;Alias pattern&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;{{ resourcegroup }}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Replaced with the the resource group&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{ namespace }}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Replaced with the resource type / namespace (e.g. Microsoft.Compute/virtualMachines)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{ resourcename }}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Replaced with the resource name&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{ metric }}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Replaced with the metric name (e.g. Percentage CPU)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;&lt;code&gt;{{ arbitaryDimensionID }}&lt;/code&gt;&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Replaced with the value of the specified dimension. (e.g. {{ blobtype }} becomes BlockBlob)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{ dimensionname }}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;em&gt;(Legacy for backwards compatibility)&lt;/em&gt; Replaced with the name of the first dimension&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{ dimensionvalue }}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;em&gt;(Legacy for backwards compatibility)&lt;/em&gt; Replaced with the value of the first dimension&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h4 id=&#34;supported-azure-monitor-metrics&#34;&gt;Supported Azure Monitor metrics&lt;/h4&gt;
&lt;p&gt;Not all metrics returned by the Azure Monitor Metrics API have values. To make it easier for you when building a query, the Grafana data source has a list of supported metrics and ignores metrics which will never have values. This list is updated regularly as new services and metrics are added to the Azure cloud. For more information about the list of metrics, refer to &lt;a href=&#34;https://github.com/grafana/grafana/blob/main/public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/supported_namespaces.ts&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;current supported namespaces&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;querying-azure-monitor-logs&#34;&gt;Querying Azure Monitor Logs&lt;/h3&gt;
&lt;p&gt;Azure Monitor Logs collects and organises log and performance data from &lt;a href=&#34;https://docs.microsoft.com/en-us/azure/azure-monitor/monitor-reference&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;supported resources&lt;/a&gt; and makes many sources of data available to query together with the sophisticated &lt;a href=&#34;https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Kusto Query Language (KQL)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;While Azure Monitor Metrics only stores simplified numerical data, Logs can store different data types each with their own structure and can perform complexe analysis of data using KQL.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 800px;&#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/azure-monitor/query-editor-logs.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/azure-monitor/query-editor-logs.png&#34;data-srcset=&#34;/static/img/docs/azure-monitor/query-editor-logs.png?w=320 320w, /static/img/docs/azure-monitor/query-editor-logs.png?w=550 550w, /static/img/docs/azure-monitor/query-editor-logs.png?w=750 750w, /static/img/docs/azure-monitor/query-editor-logs.png?w=900 900w, /static/img/docs/azure-monitor/query-editor-logs.png?w=1040 1040w, /static/img/docs/azure-monitor/query-editor-logs.png?w=1240 1240w, /static/img/docs/azure-monitor/query-editor-logs.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Azure Monitor Logs sample query comparing successful requests to failed requests&#34;width=&#34;1272&#34;height=&#34;939&#34;title=&#34;Azure Monitor Logs sample query comparing successful requests to failed requests&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/azure-monitor/query-editor-logs.png&#34;
            alt=&#34;Azure Monitor Logs sample query comparing successful requests to failed requests&#34;width=&#34;1272&#34;height=&#34;939&#34;title=&#34;Azure Monitor Logs sample query comparing successful requests to failed requests&#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;Azure Monitor Logs sample query comparing successful requests to failed requests&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h4 id=&#34;your-first-azure-monitor-logs-query&#34;&gt;Your first Azure Monitor Logs query&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Select the Logs service&lt;/li&gt;
&lt;li&gt;Select a resource to query. Alternatively, you can dynamically query all resources under a single resource group or subscription.&lt;/li&gt;
&lt;li&gt;Enter in your KQL query. See below for examples.&lt;/li&gt;
&lt;/ol&gt;
&lt;h5 id=&#34;kusto-query-language&#34;&gt;Kusto Query Language&lt;/h5&gt;
&lt;p&gt;Azure Monitor Logs queries are written using the Kusto Query Language (KQL), a rich language designed to be easy to read and write, which should be familiar to those know who SQL. The Azure documentation has plenty of resource to help with learning KQL:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://docs.microsoft.com/en-us/azure/azure-monitor/logs/log-query-overview&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Log queries in Azure Monitor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://docs.microsoft.com/en-us/azure/data-explorer/kusto/concepts/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Getting started with Kusto&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/tutorial?pivots=azuremonitor&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Tutorial: Use Kusto queries in Azure Monitor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/sqlcheatsheet&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;SQL to Kusto cheat sheet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is an example query that returns a virtual machine&amp;rsquo;s CPU performance, averaged over 5m time grains&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;kusto&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-kusto&#34;&gt;Perf
# $__timeFilter is a special Grafana macro that filters the results to the time span of the dashboard
| where $__timeFilter(TimeGenerated)
| where CounterName == &amp;#34;% Processor Time&amp;#34;
| summarize avg(CounterValue) by bin(TimeGenerated, 5m), Computer
| order by TimeGenerated asc&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Time series queries are for values that change over time, usually for graph visualisations such as the Time series panel. Each query should return at least a datetime column and a numeric value column. The result must also be sorted in ascending order by the datetime column.&lt;/p&gt;
&lt;p&gt;A query can also have one or more non-numeric/non-datetime columns, and those columns are considered dimensions and become labels in the response. For example, a query that returns the aggregated count grouped by hour, Computer, and the CounterName:&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;kusto&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-kusto&#34;&gt;Perf
| where $__timeFilter(TimeGenerated)
| summarize count() by bin(TimeGenerated, 1h), Computer, CounterName
| order by TimeGenerated asc&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can also select additional number value columns (with, or without multiple dimensions). For example, getting a count and average value by hour, Computer, CounterName, and InstanceName:&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;kusto&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-kusto&#34;&gt;Perf
| where $__timeFilter(TimeGenerated)
| summarize Samples=count(), [&amp;#34;Avg Value&amp;#34;]=avg(CounterValue)
    by bin(TimeGenerated, $__interval), Computer, CounterName, InstanceName
| order by TimeGenerated asc&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Table queries are mainly used in the Table panel and show a list of columns and rows. This example query returns rows with the six specified columns:&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;kusto&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-kusto&#34;&gt;AzureActivity
| where $__timeFilter()
| project TimeGenerated, ResourceGroup, Category, OperationName, ActivityStatus, Caller
| order by TimeGenerated desc&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h5 id=&#34;logs-macros&#34;&gt;Logs macros&lt;/h5&gt;
&lt;p&gt;To make writing queries easier there are several Grafana macros that can be used in the where clause of a query:&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;Macro&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;$__timeFilter()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Used to filter the results to the time range of the dashboard.&lt;br/&gt;Example: &lt;code&gt;TimeGenerated &amp;gt;= datetime(2018-06-05T18:09:58.907Z) and TimeGenerated &amp;lt;= datetime(2018-06-05T20:09:58.907Z)&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeFilter(datetimeColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Like &lt;code&gt;$__timeFilter()&lt;/code&gt;, but specifies a custom field to filter on.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeFrom()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Expands to the start of the dashboard time range.&lt;br/&gt;Example: &lt;code&gt;datetime(2018-06-05T18:09:58.907Z)&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeTo()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Expands to the end of the dashboard time range.&lt;br/&gt;Example: &lt;code&gt;datetime(2018-06-05T20:09:58.907Z)&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__escapeMulti($myVar)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Used with multi-value template variables that contain illegal characters.&lt;br/&gt;If &lt;code&gt;$myVar&lt;/code&gt; has the following two values as a string &lt;code&gt;&#39;\\grafana-vm\Network(eth0)\Total&#39;,&#39;\\hello!&#39;&lt;/code&gt;, then it expands to &lt;code&gt;@&#39;\\grafana-vm\Network(eth0)\Total&#39;, @&#39;\\hello!&#39;&lt;/code&gt;.&lt;br/&gt;&lt;br/&gt;If using single value variables there is no need for this macro, simply escape the variable inline instead - &lt;code&gt;@&#39;\$myVar&#39;&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__contains(colName, $myVar)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Used with multi-value template variables.&lt;br/&gt;If &lt;code&gt;$myVar&lt;/code&gt; has the value &lt;code&gt;&#39;value1&#39;,&#39;value2&#39;&lt;/code&gt;, it expands to: &lt;code&gt;colName in (&#39;value1&#39;,&#39;value2&#39;)&lt;/code&gt;.&lt;br/&gt;&lt;br/&gt;If using the &lt;code&gt;All&lt;/code&gt; option, then check the &lt;code&gt;Include All Option&lt;/code&gt; checkbox and in the &lt;code&gt;Custom all value&lt;/code&gt; field type in the value &lt;code&gt;all&lt;/code&gt;. If &lt;code&gt;$myVar&lt;/code&gt; has value &lt;code&gt;all&lt;/code&gt; then the macro will instead expand to &lt;code&gt;1 == 1&lt;/code&gt;. For template variables with a lot of options, this will increase the query performance by not building a large &amp;ldquo;where..in&amp;rdquo; clause.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Additionally, Grafana has the built-in &lt;code&gt;$__interval&lt;/code&gt; macro&lt;/p&gt;
&lt;h3 id=&#34;querying-azure-resource-graph&#34;&gt;Querying Azure Resource Graph&lt;/h3&gt;
&lt;p&gt;Azure Resource Graph (ARG) is a service in Azure that is designed to extend Azure Resource Management by providing efficient and performant resource exploration, with the ability to query at scale across a given set of subscriptions so that you can effectively govern your environment. By querying ARG, you can query resources with complex filtering, iteratively explore resources based on governance requirements, and assess the impact of applying policies in a vast cloud environment.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 800px;&#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/azure-monitor/query-editor-arg.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/azure-monitor/query-editor-arg.png&#34;data-srcset=&#34;/static/img/docs/azure-monitor/query-editor-arg.png?w=320 320w, /static/img/docs/azure-monitor/query-editor-arg.png?w=550 550w, /static/img/docs/azure-monitor/query-editor-arg.png?w=750 750w, /static/img/docs/azure-monitor/query-editor-arg.png?w=900 900w, /static/img/docs/azure-monitor/query-editor-arg.png?w=1040 1040w, /static/img/docs/azure-monitor/query-editor-arg.png?w=1240 1240w, /static/img/docs/azure-monitor/query-editor-arg.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Azure Resource Graph sample query listing virtual machines on an account&#34;width=&#34;1272&#34;height=&#34;907&#34;title=&#34;Azure Resource Graph sample query listing virtual machines on an account&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/azure-monitor/query-editor-arg.png&#34;
            alt=&#34;Azure Resource Graph sample query listing virtual machines on an account&#34;width=&#34;1272&#34;height=&#34;907&#34;title=&#34;Azure Resource Graph sample query listing virtual machines on an account&#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;Azure Resource Graph sample query listing virtual machines on an account&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;your-first-azure-resource-graph-query&#34;&gt;Your first Azure Resource Graph query&lt;/h3&gt;
&lt;p&gt;ARG queries are written in a variant of the &lt;a href=&#34;https://docs.microsoft.com/en-us/azure/governance/resource-graph/concepts/query-language&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Kusto Query Language&lt;/a&gt;, but not all Kusto language features are available in ARG. An Azure Resource Graph query is formatted as table data.&lt;/p&gt;
&lt;p&gt;If your credentials give you access to multiple subscriptions, then you can choose multiple subscriptions before entering queries.&lt;/p&gt;
&lt;h4 id=&#34;sort-results-by-resource-properties&#34;&gt;Sort results by resource properties&lt;/h4&gt;
&lt;p&gt;Here is an example query that returns all resources in the selected subscriptions, but only the name, type, and location properties:&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;kusto&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-kusto&#34;&gt;Resources
| project name, type, location
| order by name asc&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The query uses &lt;code&gt;order by&lt;/code&gt; to sort the properties by the &lt;code&gt;name&lt;/code&gt; property in ascending (&lt;code&gt;asc&lt;/code&gt;) order. You can change what property to sort by and the order (&lt;code&gt;asc&lt;/code&gt; or &lt;code&gt;desc&lt;/code&gt;). The query uses &lt;code&gt;project&lt;/code&gt; to show only the listed properties in the results. You can add or remove properties.&lt;/p&gt;
&lt;h4 id=&#34;query-resources-with-complex-filtering&#34;&gt;Query resources with complex filtering&lt;/h4&gt;
&lt;p&gt;Filtering for Azure resources with a tag name of &lt;code&gt;environment&lt;/code&gt; that have a value of &lt;code&gt;Internal&lt;/code&gt;. You can change these to any desired tag key and value. The &lt;code&gt;=~&lt;/code&gt; in the &lt;code&gt;type&lt;/code&gt; match tells Resource Graph to be case insensitive. You can project by other properties or add/remove more.&lt;/p&gt;
&lt;p&gt;For example, a query that returns a list of resources with an &lt;code&gt;environment&lt;/code&gt; tag value of &lt;code&gt;Internal&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;kusto&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-kusto&#34;&gt;Resources
| where tags.environment=~&amp;#39;internal&amp;#39;
| project name&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;group-and-aggregate-the-values-by-property&#34;&gt;Group and aggregate the values by property&lt;/h4&gt;
&lt;p&gt;You can also use &lt;code&gt;summarize&lt;/code&gt; and &lt;code&gt;count&lt;/code&gt; to define how to group and aggregate the values by property. For example, returning count of healthy, unhealthy, and not applicable resources per recommendation:&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;kusto&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-kusto&#34;&gt;securityresources
| where type == &amp;#39;microsoft.security/assessments&amp;#39;
| extend resourceId=id,
    recommendationId=name,
    resourceType=type,
    recommendationName=properties.displayName,
    source=properties.resourceDetails.Source,
    recommendationState=properties.status.code,
    description=properties.metadata.description,
    assessmentType=properties.metadata.assessmentType,
    remediationDescription=properties.metadata.remediationDescription,
    policyDefinitionId=properties.metadata.policyDefinitionId,
    implementationEffort=properties.metadata.implementationEffort,
    recommendationSeverity=properties.metadata.severity,
    category=properties.metadata.categories,
    userImpact=properties.metadata.userImpact,
    threats=properties.metadata.threats,
    portalLink=properties.links.azurePortal
| summarize numberOfResources=count(resourceId) by tostring(recommendationName), tostring(recommendationState)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In Azure Resource Graph many nested properties (&lt;code&gt;properties.displayName&lt;/code&gt;) are of a &lt;code&gt;dynamic&lt;/code&gt; type, and should be cast to a string with &lt;code&gt;tostring()&lt;/code&gt; to operate on them.&lt;/p&gt;
&lt;p&gt;The Azure documentation also hosts &lt;a href=&#34;https://docs.microsoft.com/en-gb/azure/governance/resource-graph/samples/starter&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;many sample queries&lt;/a&gt; to help you get started&lt;/p&gt;
&lt;h3 id=&#34;azure-resource-graph-macros&#34;&gt;Azure Resource Graph macros&lt;/h3&gt;
&lt;p&gt;You can use Grafana macros when constructing a query. Use the macros in the where clause of a query:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;$__timeFilter()&lt;/code&gt; - Expands to
&lt;code&gt;timestamp ≥ datetime(2018-06-05T18:09:58.907Z) and&lt;/code&gt;
&lt;code&gt;timestamp ≤ datetime(2018-06-05T20:09:58.907Z)&lt;/code&gt; where the from and to datetimes are from the Grafana time picker.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;$__timeFilter(datetimeColumn)&lt;/code&gt; - Expands to
&lt;code&gt;datetimeColumn ≥ datetime(2018-06-05T18:09:58.907Z) and&lt;/code&gt;
&lt;code&gt;datetimeColumn ≤ datetime(2018-06-05T20:09:58.907Z)&lt;/code&gt; where the from and to datetimes are from the Grafana time picker.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;$__timeFrom()&lt;/code&gt; - Returns the From datetime from the Grafana picker. Example: &lt;code&gt;datetime(2018-06-05T18:09:58.907Z)&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;$__timeTo()&lt;/code&gt; - Returns the To datetime from the Grafana picker. Example: &lt;code&gt;datetime(2018-06-05T20:09:58.907Z)&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;$__escapeMulti($myVar)&lt;/code&gt; - Use with multi-value template variables that contain illegal characters. If &lt;code&gt;$myVar&lt;/code&gt; has the two values as a string &lt;code&gt;&#39;\\grafana-vm\Network(eth0)\Total&#39;,&#39;\\hello!&#39;&lt;/code&gt;, then it expands to: &lt;code&gt;@&#39;\\grafana-vm\Network(eth0)\Total&#39;, @&#39;\\hello!&#39;&lt;/code&gt;. If you are using single value variables, then there is no need for this macro, simply escape the variable inline instead - &lt;code&gt;@&#39;\$myVar&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;$__contains(colName, $myVar)&lt;/code&gt; - Use with multi-value template variables. If &lt;code&gt;$myVar&lt;/code&gt; has the value &lt;code&gt;&#39;value1&#39;,&#39;value2&#39;&lt;/code&gt;, the it expands to: &lt;code&gt;colName in (&#39;value1&#39;,&#39;value2&#39;)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If using the &lt;code&gt;All&lt;/code&gt; option, then check the &lt;code&gt;Include All Option&lt;/code&gt; checkbox and in the &lt;code&gt;Custom all value&lt;/code&gt; field type in the following value: &lt;code&gt;all&lt;/code&gt;. If &lt;code&gt;$myVar&lt;/code&gt; has value &lt;code&gt;all&lt;/code&gt; then the macro will instead expand to &lt;code&gt;1 == 1&lt;/code&gt;. For template variables with a lot of options, this will increase the query performance by not building a large &amp;ldquo;where..in&amp;rdquo; clause.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;going-further-with-azure-monitor&#34;&gt;Going further with Azure Monitor&lt;/h2&gt;
&lt;p&gt;See the following topics to learn more about the Azure Monitor data source:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;template-variables/&#34;&gt;Azure Monitor template variables&lt;/a&gt; for more interactive, dynamic, and reusable dashboards.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;provisioning/&#34;&gt;Provisioning Azure Monitor&lt;/a&gt; for configuring the Azure Monitor data source using YAML files&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;provisioning/&#34;&gt;Deprecating Application Insights&lt;/a&gt; and migrating to Metrics and Logs queries&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;configuring-using-managed-identity&#34;&gt;Configuring using Managed Identity&lt;/h3&gt;
&lt;p&gt;Customers who host Grafana in Azure (e.g. App Service, Azure Virtual Machines) and have managed identity enabled on their VM, will now be able to use the managed identity to configure Azure Monitor in Grafana. This will simplify the data source configuration, requiring the data source to be securely authenticated without having to manually configure credentials via Azure AD App Registrations for each data source. For more details on Azure managed identities, refer to the &lt;a href=&#34;https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Azure documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To enable managed identity for Grafana, set the &lt;code&gt;managed_identity_enabled&lt;/code&gt; flag in the &lt;code&gt;[azure]&lt;/code&gt; section of the &lt;a href=&#34;/docs/grafana/latest/administration/configuration/#azure&#34;&gt;Grafana server config&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&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-ini&#34;&gt;[azure]
managed_identity_enabled = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Then, in the Azure Monitor data source configuration and set Authentication to Managed Identity. The directory ID, application ID and client secret fields will be hidden and the data source will use managed identity for authenticating to Azure Monitor Metrics, Logs, and Azure Resource Graph.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 800px;&#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/azure-monitor/managed-identity.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/azure-monitor/managed-identity.png&#34;data-srcset=&#34;/static/img/docs/azure-monitor/managed-identity.png?w=320 320w, /static/img/docs/azure-monitor/managed-identity.png?w=550 550w, /static/img/docs/azure-monitor/managed-identity.png?w=750 750w, /static/img/docs/azure-monitor/managed-identity.png?w=900 900w, /static/img/docs/azure-monitor/managed-identity.png?w=1040 1040w, /static/img/docs/azure-monitor/managed-identity.png?w=1240 1240w, /static/img/docs/azure-monitor/managed-identity.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Azure Monitor Metrics screenshot showing Dimensions&#34;width=&#34;930&#34;height=&#34;713&#34;title=&#34;Azure Monitor Metrics screenshot showing Dimensions&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/azure-monitor/managed-identity.png&#34;
            alt=&#34;Azure Monitor Metrics screenshot showing Dimensions&#34;width=&#34;930&#34;height=&#34;713&#34;title=&#34;Azure Monitor Metrics screenshot showing Dimensions&#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;Azure Monitor Metrics screenshot showing Dimensions&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
]]></content><description>&lt;h1 id="azure-monitor-data-source">Azure Monitor data source&lt;/h1>
&lt;p>Grafana includes built-in support for Azure Monitor, the Azure service to maximize the availability and performance of your applications and services in the Azure Cloud. The Azure Monitor data source supports visualizing data from three Azure services:&lt;/p></description></item><item><title>Elasticsearch</title><link>https://grafana.com/docs/grafana/v8.4/datasources/elasticsearch/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/elasticsearch/</guid><content><![CDATA[&lt;h1 id=&#34;using-elasticsearch-in-grafana&#34;&gt;Using Elasticsearch in Grafana&lt;/h1&gt;
&lt;p&gt;Grafana ships with advanced support for Elasticsearch. You can do many types of simple or complex Elasticsearch queries to
visualize logs or metrics stored in Elasticsearch. You can also annotate your graphs with log events stored in Elasticsearch.&lt;/p&gt;
&lt;h2 id=&#34;adding-the-data-source&#34;&gt;Adding the data source&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Open the side menu by clicking the Grafana icon in the top header.&lt;/li&gt;
&lt;li&gt;In the side menu under the &lt;code&gt;Dashboards&lt;/code&gt; link you should find a link named &lt;code&gt;Data Sources&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click the &lt;code&gt;&#43; Add data source&lt;/code&gt; button in the top header.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Elasticsearch&lt;/strong&gt; from the &lt;strong&gt;Type&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you&amp;rsquo;re not seeing the &lt;code&gt;Data Sources&lt;/code&gt; link in your side menu it means that your current user does not have the &lt;code&gt;Admin&lt;/code&gt; role for the current organization.&lt;/p&gt;&lt;/blockquote&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The data source name. This is how you refer to the data source in panels and queries.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Default&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Default data source means that it will be pre-selected for new panels.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The HTTP protocol, IP, and port of your Elasticsearch server.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Access&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Server (default) = URL needs to be accessible from the Grafana backend/server, Browser = URL needs to be accessible from the browser. &lt;strong&gt;Note&lt;/strong&gt;: Browser (direct) access is deprecated and will be removed in a future release.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Access mode controls how requests to the data source will be handled. Server should be the preferred way if nothing else stated.&lt;/p&gt;
&lt;h3 id=&#34;server-access-mode-default&#34;&gt;Server access mode (Default)&lt;/h3&gt;
&lt;p&gt;All requests will be made from the browser to Grafana backend/server which in turn will forward the requests to the data source and by that circumvent possible Cross-Origin Resource Sharing (CORS) requirements. The URL needs to be accessible from the grafana backend/server if you select this access mode.&lt;/p&gt;
&lt;h3 id=&#34;browser-direct-access&#34;&gt;Browser (Direct) access&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Browser (Direct) access is deprecated and will be removed in a future release.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;All requests will be made from the browser directly to the data source and may be subject to Cross-Origin Resource Sharing (CORS) requirements. The URL needs to be accessible from the browser if you select this access mode.&lt;/p&gt;
&lt;p&gt;If you select Browser access you must update your Elasticsearch configuration to allow other domains to access
Elasticsearch from the browser. You do this by specifying these two options in your &lt;strong&gt;elasticsearch.yml&lt;/strong&gt; config file.&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;http.cors.enabled: true
http.cors.allow-origin: &amp;#34;*&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;index-settings&#34;&gt;Index settings&lt;/h3&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/elasticsearch/elasticsearch-ds-details-7-4.png&#34;
  alt=&#34;Elasticsearch data source details&#34; width=&#34;663&#34;
     height=&#34;118&#34;/&gt;&lt;/p&gt;
&lt;p&gt;Here you can specify a default for the &lt;code&gt;time field&lt;/code&gt; and specify the name of your Elasticsearch index. You can use
a time pattern for the index name or a wildcard.&lt;/p&gt;
&lt;h3 id=&#34;elasticsearch-version&#34;&gt;Elasticsearch version&lt;/h3&gt;
&lt;p&gt;Select the version of your Elasticsearch data source from the version selection dropdown. Different query compositions and functionalities are available in the query editor for different versions.
Available Elasticsearch versions are &lt;code&gt;2.x&lt;/code&gt;, &lt;code&gt;5.x&lt;/code&gt;, &lt;code&gt;5.6&#43;&lt;/code&gt;, &lt;code&gt;6.0&#43;&lt;/code&gt;, &lt;code&gt;7.0&#43;&lt;/code&gt;, &lt;code&gt;7.7&#43;&lt;/code&gt; and &lt;code&gt;7.10&#43;&lt;/code&gt;. Select the option that best matches your data source version.&lt;/p&gt;
&lt;p&gt;Grafana assumes that you are running the lowest possible version for a specified range. This ensures that new features or breaking changes in a future Elasticsearch release will not affect your configuration.&lt;/p&gt;
&lt;p&gt;For example, suppose you are running Elasticsearch &lt;code&gt;7.6.1&lt;/code&gt; and you selected &lt;code&gt;7.0&#43;&lt;/code&gt;. If a new feature is made available for Elasticsearch &lt;code&gt;7.5.0&lt;/code&gt; or newer releases, then a &lt;code&gt;7.5&#43;&lt;/code&gt; option will be available. However, your configuration will not be affected until you explicitly select the new &lt;code&gt;7.5&#43;&lt;/code&gt; option in your settings.&lt;/p&gt;
&lt;h3 id=&#34;min-time-interval&#34;&gt;Min time interval&lt;/h3&gt;
&lt;p&gt;A lower limit for the auto group by time interval. Recommended to be set to write frequency, for example &lt;code&gt;1m&lt;/code&gt; if your data is written every minute.
This option can also be overridden/configured in a dashboard panel under data source options. It&amp;rsquo;s important to note that this value &lt;strong&gt;needs&lt;/strong&gt; to be formatted as a
number followed by a valid time identifier, e.g. &lt;code&gt;1m&lt;/code&gt; (1 minute) or &lt;code&gt;30s&lt;/code&gt; (30 seconds). The following time identifiers are supported:&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;Identifier&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;y&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;year&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;M&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;month&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;w&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;week&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;d&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;day&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;h&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;hour&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;m&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;minute&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;s&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;second&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ms&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;millisecond&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;x-pack-enabled&#34;&gt;X-Pack enabled&lt;/h3&gt;
&lt;p&gt;Enables &lt;code&gt;X-Pack&lt;/code&gt; specific features and options, providing the query editor with additional aggregations such as &lt;code&gt;Rate&lt;/code&gt; and &lt;code&gt;Top Metrics&lt;/code&gt;.&lt;/p&gt;
&lt;h4 id=&#34;include-frozen-indices&#34;&gt;Include frozen indices&lt;/h4&gt;
&lt;p&gt;When &lt;code&gt;X-Pack enabled&lt;/code&gt; is active and the configured Elasticsearch version is higher than &lt;code&gt;6.6.0&lt;/code&gt;, you can configure Grafana to not ignore &lt;a href=&#34;https://www.elastic.co/guide/en/elasticsearch/reference/7.13/frozen-indices.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;frozen indices&lt;/a&gt; when performing search requests.&lt;/p&gt;
&lt;h3 id=&#34;logs&#34;&gt;Logs&lt;/h3&gt;
&lt;p&gt;There are two parameters, &lt;code&gt;Message field name&lt;/code&gt; and &lt;code&gt;Level field name&lt;/code&gt;, that can optionally be configured from the data source settings page that determine
which fields will be used for log messages and log levels when visualizing logs in &lt;a href=&#34;../../explore/&#34;&gt;Explore&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For example, if you&amp;rsquo;re using a default setup of Filebeat for shipping logs to Elasticsearch the following configuration should work:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Message field name:&lt;/strong&gt; message&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Level field name:&lt;/strong&gt; fields.level&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;data-links&#34;&gt;Data links&lt;/h3&gt;
&lt;p&gt;Data links create a link from a specified field that can be accessed in logs view in Explore.&lt;/p&gt;
&lt;p&gt;Each data link configuration consists of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Field -&lt;/strong&gt; Name of the field used by the data link.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;URL/query -&lt;/strong&gt; If the link is external, then enter the full link URL. If the link is internal link, then this input serves as query for the target data source. In both cases, you can interpolate the value from the field with &lt;code&gt;${__value.raw }&lt;/code&gt; macro.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;URL Label -&lt;/strong&gt; (Optional) Set a custom display label for the link. The link label defaults to the full external URL or name of the linked internal data source and is overridden by this setting.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internal link -&lt;/strong&gt; Select if the link is internal or external. In case of internal link, a data source selector allows you to select the target data source. Only tracing data sources are supported.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;metric-query-editor&#34;&gt;Metric Query editor&lt;/h2&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/elasticsearch/query-editor-7-4.png&#34;
  alt=&#34;Elasticsearch Query Editor&#34; width=&#34;922&#34;
     height=&#34;195&#34;/&gt;&lt;/p&gt;
&lt;p&gt;The Elasticsearch query editor allows you to select multiple metrics and group by multiple terms or filters. Use the plus and minus icons to the right to add/remove
metrics or group by clauses. Some metrics and group by clauses haves options, click the option text to expand the row to view and edit metric or group by options.&lt;/p&gt;
&lt;h2 id=&#34;series-naming-and-alias-patterns&#34;&gt;Series naming and alias patterns&lt;/h2&gt;
&lt;p&gt;You can control the name for time series via the &lt;code&gt;Alias&lt;/code&gt; input field.&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;Pattern&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;{{term fieldname}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;replaced with value of a term group by&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metric}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;replaced with metric name (ex. Average, Min, Max)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{field}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;replaced with the metric field name&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;pipeline-metrics&#34;&gt;Pipeline metrics&lt;/h2&gt;
&lt;p&gt;Some metric aggregations are called Pipeline aggregations, for example, &lt;em&gt;Moving Average&lt;/em&gt; and &lt;em&gt;Derivative&lt;/em&gt;. Elasticsearch pipeline metrics require another metric to be based on. Use the eye icon next to the metric to hide metrics from appearing in the graph. This is useful for metrics you only have in the query for use in a pipeline metric.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/elasticsearch/pipeline-aggregation-editor-7-4.png&#34;
  alt=&#34;Pipeline aggregation editor&#34; width=&#34;844&#34;
     height=&#34;302&#34;/&gt;&lt;/p&gt;
&lt;h2 id=&#34;templating&#34;&gt;Templating&lt;/h2&gt;
&lt;p&gt;Instead of hard-coding things like server, application and sensor name in your metric queries you can use variables in their place.
Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns make it easy to change the data
being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Check out the &lt;a href=&#34;../../variables/&#34;&gt;Templating&lt;/a&gt; documentation for an introduction to the templating feature and the different
types of template variables.&lt;/p&gt;
&lt;h3 id=&#34;query-variable&#34;&gt;Query variable&lt;/h3&gt;
&lt;p&gt;The Elasticsearch data source supports two types of queries you can use in the &lt;em&gt;Query&lt;/em&gt; field of &lt;em&gt;Query&lt;/em&gt; variables. The query is written using a custom JSON string. The field should be mapped as a &lt;a href=&#34;https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html#keyword&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;keyword&lt;/a&gt; in the Elasticsearch index mapping. If it is &lt;a href=&#34;https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;multi-field&lt;/a&gt; with both a &lt;code&gt;text&lt;/code&gt; and &lt;code&gt;keyword&lt;/code&gt; type, then use &lt;code&gt;&amp;quot;field&amp;quot;:&amp;quot;fieldname.keyword&amp;quot;&lt;/code&gt;(sometimes&lt;code&gt;fieldname.raw&lt;/code&gt;) to specify the keyword field in your query.&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&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;{&amp;quot;find&amp;quot;: &amp;quot;fields&amp;quot;, &amp;quot;type&amp;quot;: &amp;quot;keyword&amp;quot;}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of field names with the index type &lt;code&gt;keyword&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{&amp;quot;find&amp;quot;: &amp;quot;terms&amp;quot;, &amp;quot;field&amp;quot;: &amp;quot;hostname.keyword&amp;quot;, &amp;quot;size&amp;quot;: 1000}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of values for a keyword using term aggregation. Query will use current dashboard time range as time range query.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{&amp;quot;find&amp;quot;: &amp;quot;terms&amp;quot;, &amp;quot;field&amp;quot;: &amp;quot;hostname&amp;quot;, &amp;quot;query&amp;quot;: &#39;&amp;lt;lucene query&amp;gt;&#39;}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of values for a keyword field using term aggregation and a specified lucene query filter. Query will use current dashboard time range as time range for query.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;There is a default size limit of 500 on terms queries. Set the size property in your query to set a custom limit.
You can use other variables inside the query. Example query definition for a variable named &lt;code&gt;$host&lt;/code&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;{&amp;#34;find&amp;#34;: &amp;#34;terms&amp;#34;, &amp;#34;field&amp;#34;: &amp;#34;@hostname&amp;#34;, &amp;#34;query&amp;#34;: &amp;#34;@source:$source&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In the above example, we use another variable named &lt;code&gt;$source&lt;/code&gt; inside the query definition. Whenever you change, via the dropdown, the current value of the &lt;code&gt; $source&lt;/code&gt; variable, it will trigger an update of the &lt;code&gt;$host&lt;/code&gt; variable so it now only contains hostnames filtered by in this case the
&lt;code&gt;@source&lt;/code&gt; document property.&lt;/p&gt;
&lt;p&gt;These queries by default return results in term order (which can then be sorted alphabetically or numerically as for any variable).
To produce a list of terms sorted by doc count (a top-N values list), add an &lt;code&gt;orderBy&lt;/code&gt; property of &amp;ldquo;doc_count&amp;rdquo;.
This automatically selects a descending sort; using &amp;ldquo;asc&amp;rdquo; with doc_count (a bottom-N list) can be done by setting &lt;code&gt;order: &amp;quot;asc&amp;quot;&lt;/code&gt; but &lt;a href=&#34;https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-order&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;is discouraged&lt;/a&gt; as it &amp;ldquo;increases the error on document counts&amp;rdquo;.
To keep terms in the doc count order, set the variable&amp;rsquo;s Sort dropdown to &lt;strong&gt;Disabled&lt;/strong&gt;; you might alternatively still want to use e.g. &lt;strong&gt;Alphabetical&lt;/strong&gt; to re-sort them.&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;{&amp;#34;find&amp;#34;: &amp;#34;terms&amp;#34;, &amp;#34;field&amp;#34;: &amp;#34;@hostname&amp;#34;, &amp;#34;orderBy&amp;#34;: &amp;#34;doc_count&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;using-variables-in-queries&#34;&gt;Using variables in queries&lt;/h3&gt;
&lt;p&gt;There are two syntaxes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;$&amp;lt;varname&amp;gt;&lt;/code&gt; Example: @hostname:$hostname&lt;/li&gt;
&lt;li&gt;&lt;code&gt;[[varname]]&lt;/code&gt; Example: @hostname:[[hostname]]&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of a word. When the &lt;em&gt;Multi-value&lt;/em&gt; or &lt;em&gt;Include all value&lt;/em&gt;
options are enabled, Grafana converts the labels from plain text to a lucene compatible condition.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/elasticsearch/elastic-templating-query-7-4.png&#34;
  alt=&#34;Query with template variables&#34; width=&#34;920&#34;
     height=&#34;190&#34;/&gt;&lt;/p&gt;
&lt;p&gt;In the above example, we have a lucene query that filters documents based on the &lt;code&gt;@hostname&lt;/code&gt; property using a variable named &lt;code&gt;$hostname&lt;/code&gt;. It is also using
a variable in the &lt;em&gt;Terms&lt;/em&gt; group by field input box. This allows you to use a variable to quickly change how the data is grouped.&lt;/p&gt;
&lt;p&gt;Example dashboard:
&lt;a href=&#34;https://play.grafana.org/d/CknOEXDMk/elasticsearch-templated?orgId=1d&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Elasticsearch Templated Dashboard&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;../../dashboards/annotations/&#34;&gt;Annotations&lt;/a&gt; allow you to overlay rich event information on top of graphs. You add annotation
queries via the Dashboard menu / Annotations view. Grafana can query any Elasticsearch index
for annotation events.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Query&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;You can leave the search query blank or specify a lucene query.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Time&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The name of the time field, needs to be date field.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Time End&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Optional name of the time end field needs to be date field. If set, then annotations will be marked as a region between time and time-end.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Text&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Event description field.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Tags&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Optional field name to use for event tags (can be an array or a CSV string).&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;querying-logs&#34;&gt;Querying Logs&lt;/h2&gt;
&lt;p&gt;Querying and displaying log data from Elasticsearch is available in &lt;a href=&#34;../../explore/&#34;&gt;Explore&lt;/a&gt;, and in the &lt;a href=&#34;../../visualizations/logs-panel/&#34;&gt;logs panel&lt;/a&gt; in dashboards.
Select the Elasticsearch data source, and then optionally enter a lucene query to display your logs.&lt;/p&gt;
&lt;p&gt;When switching from a Prometheus or Loki data source in Explore, your query is translated to an Elasticsearch log query with a correct Lucene filter.&lt;/p&gt;
&lt;h3 id=&#34;log-queries&#34;&gt;Log Queries&lt;/h3&gt;
&lt;p&gt;Once the result is returned, the log panel shows a list of log rows and a bar chart where the x-axis shows the time and the y-axis shows the frequency/count.&lt;/p&gt;
&lt;p&gt;Note that the fields used for log message and level is based on an &lt;a href=&#34;#logs&#34;&gt;optional data source configuration&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;filter-log-messages&#34;&gt;Filter Log Messages&lt;/h3&gt;
&lt;p&gt;Optionally enter a lucene query into the query field to filter the log messages. For example, using a default Filebeat setup you should be able to use &lt;code&gt;fields.level:error&lt;/code&gt; to only show error log messages.&lt;/p&gt;
&lt;h2 id=&#34;configure-the-data-source-with-provisioning&#34;&gt;Configure the data source with provisioning&lt;/h2&gt;
&lt;p&gt;It&amp;rsquo;s now possible to configure data sources using config files with Grafana&amp;rsquo;s provisioning system. You can read more about how it works and all the settings you can set for data sources on the &lt;a href=&#34;../../administration/provisioning/#datasources&#34;&gt;provisioning docs page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here are some provisioning examples for this data source.&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: Elastic
    type: elasticsearch
    access: proxy
    database: &amp;#39;[metrics-]YYYY.MM.DD&amp;#39;
    url: http://localhost:9200
    jsonData:
      interval: Daily
      timeField: &amp;#39;@timestamp&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;or, for logs:&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: elasticsearch-v7-filebeat
    type: elasticsearch
    access: proxy
    database: &amp;#39;[filebeat-]YYYY.MM.DD&amp;#39;
    url: http://localhost:9200
    jsonData:
      interval: Daily
      timeField: &amp;#39;@timestamp&amp;#39;
      esVersion: &amp;#39;7.0.0&amp;#39;
      logMessageField: message
      logLevelField: fields.level
      dataLinks:
        - datasourceUid: my_jaeger_uid # Target UID needs to be known
          field: traceID
          url: &amp;#39;$${__value.raw}&amp;#39; # Careful about the double &amp;#34;$$&amp;#34; because of env var expansion&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;amazon-elasticsearch-service&#34;&gt;Amazon Elasticsearch Service&lt;/h2&gt;
&lt;p&gt;AWS users using Amazon&amp;rsquo;s Elasticsearch Service can use Grafana&amp;rsquo;s Elasticsearch data source to visualize Elasticsearch data.
If you are using an AWS Identity and Access Management (IAM) policy to control access to your Amazon Elasticsearch Service domain, then you must use AWS Signature Version 4 (AWS SigV4) to sign all requests to that domain.
For more details on AWS SigV4, refer to the &lt;a href=&#34;https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;AWS documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;aws-signature-version-4-authentication&#34;&gt;AWS Signature Version 4 authentication&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Only available in Grafana v7.3&#43;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;In order to sign requests to your Amazon Elasticsearch Service domain, SigV4 can be enabled in the Grafana &lt;a href=&#34;../../administration/configuration/#sigv4_auth_enabled&#34;&gt;configuration&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Once AWS SigV4 is enabled, it can be configured on the Elasticsearch data source configuration page. Refer to &lt;a href=&#34;../aws-cloudwatch/aws-authentication/&#34;&gt;Cloudwatch authentication&lt;/a&gt; for more information about authentication options.&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/v73/elasticsearch-sigv4-config-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;/static/img/docs/v73/elasticsearch-sigv4-config-editor.png&#34;data-srcset=&#34;/static/img/docs/v73/elasticsearch-sigv4-config-editor.png?w=320 320w, /static/img/docs/v73/elasticsearch-sigv4-config-editor.png?w=550 550w, /static/img/docs/v73/elasticsearch-sigv4-config-editor.png?w=750 750w, /static/img/docs/v73/elasticsearch-sigv4-config-editor.png?w=900 900w, /static/img/docs/v73/elasticsearch-sigv4-config-editor.png?w=1040 1040w, /static/img/docs/v73/elasticsearch-sigv4-config-editor.png?w=1240 1240w, /static/img/docs/v73/elasticsearch-sigv4-config-editor.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;SigV4 configuration for AWS Elasticsearch Service&#34;width=&#34;759&#34;height=&#34;886&#34;title=&#34;SigV4 configuration for AWS Elasticsearch Service&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v73/elasticsearch-sigv4-config-editor.png&#34;
            alt=&#34;SigV4 configuration for AWS Elasticsearch Service&#34;width=&#34;759&#34;height=&#34;886&#34;title=&#34;SigV4 configuration for AWS Elasticsearch Service&#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;SigV4 configuration for AWS Elasticsearch Service&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
]]></content><description>&lt;h1 id="using-elasticsearch-in-grafana">Using Elasticsearch in Grafana&lt;/h1>
&lt;p>Grafana ships with advanced support for Elasticsearch. You can do many types of simple or complex Elasticsearch queries to
visualize logs or metrics stored in Elasticsearch. You can also annotate your graphs with log events stored in Elasticsearch.&lt;/p></description></item><item><title>Google Cloud Monitoring</title><link>https://grafana.com/docs/grafana/v8.4/datasources/google-cloud-monitoring/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/google-cloud-monitoring/</guid><content><![CDATA[&lt;h1 id=&#34;using-google-cloud-monitoring-in-grafana&#34;&gt;Using Google Cloud Monitoring in Grafana&lt;/h1&gt;
&lt;p&gt;Grafana ships with built-in support for Google Cloud Monitoring. Add it as a data source to build dashboards for your Google Cloud Monitoring metrics. For instructions on how to add a data source, refer to &lt;a href=&#34;../add-a-data-source/&#34;&gt;Add a data source&lt;/a&gt;. Only users with the organization admin role can add data sources.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; Before Grafana v7.1, Google Cloud Monitoring was referred to as Google Stackdriver.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;configure-the-google-cloud-monitoring-data-source&#34;&gt;Configure the Google Cloud Monitoring data source&lt;/h2&gt;
&lt;p&gt;To access Google Cloud Monitoring settings, hover your mouse over the &lt;strong&gt;Configuration&lt;/strong&gt; (gear) icon, then click &lt;strong&gt;Data Sources&lt;/strong&gt;, and click &lt;strong&gt;Add data source&lt;/strong&gt;, then click the Google Cloud Monitoring data source.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The data source name. This is how you refer to the data source in panels and queries.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Default&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Default data source means that it is pre-selected for new panels.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;For authentication options and configuration details, see the &lt;a href=&#34;google-authentication/&#34;&gt;Google authentication&lt;/a&gt; documentation.&lt;/p&gt;
&lt;h3 id=&#34;google-cloud-monitoring-specific-data-source-configuration&#34;&gt;Google Cloud Monitoring specific data source configuration&lt;/h3&gt;
&lt;p&gt;The following APIs need to be enabled first:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://console.cloud.google.com/apis/library/monitoring.googleapis.com&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Monitoring API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://console.cloud.google.com/apis/library/cloudresourcemanager.googleapis.com&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Cloud Resource Manager API&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Click on the links above and click the &lt;code&gt;Enable&lt;/code&gt; button:&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 450px;&#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/v71/cloudmonitoring_enable_api.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/v71/cloudmonitoring_enable_api.png&#34;data-srcset=&#34;/static/img/docs/v71/cloudmonitoring_enable_api.png?w=320 320w, /static/img/docs/v71/cloudmonitoring_enable_api.png?w=550 550w, /static/img/docs/v71/cloudmonitoring_enable_api.png?w=750 750w, /static/img/docs/v71/cloudmonitoring_enable_api.png?w=900 900w, /static/img/docs/v71/cloudmonitoring_enable_api.png?w=1040 1040w, /static/img/docs/v71/cloudmonitoring_enable_api.png?w=1240 1240w, /static/img/docs/v71/cloudmonitoring_enable_api.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Enable GCP APIs&#34;width=&#34;696&#34;height=&#34;373&#34;title=&#34;Enable GCP APIs&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v71/cloudmonitoring_enable_api.png&#34;
            alt=&#34;Enable GCP APIs&#34;width=&#34;696&#34;height=&#34;373&#34;title=&#34;Enable GCP APIs&#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;Enable GCP APIs&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h4 id=&#34;using-gcp-service-account-key-file&#34;&gt;Using GCP Service Account Key File&lt;/h4&gt;
&lt;p&gt;The GCP Service Account must have the &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role as shown in the image below:&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 600px;&#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/v71/cloudmonitoring_service_account_choose_role.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/v71/cloudmonitoring_service_account_choose_role.png&#34;data-srcset=&#34;/static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=320 320w, /static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=550 550w, /static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=750 750w, /static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=900 900w, /static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=1040 1040w, /static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=1240 1240w, /static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Choose role&#34;width=&#34;1076&#34;height=&#34;743&#34;title=&#34;Choose role&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v71/cloudmonitoring_service_account_choose_role.png&#34;
            alt=&#34;Choose role&#34;width=&#34;1076&#34;height=&#34;743&#34;title=&#34;Choose role&#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;Choose role&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h4 id=&#34;using-gce-default-service-account&#34;&gt;Using GCE Default Service Account&lt;/h4&gt;
&lt;p&gt;If Grafana is running on a Google Compute Engine (GCE) virtual machine, the service account in use must have access to the &lt;code&gt;Cloud Monitoring API&lt;/code&gt; scope.&lt;/p&gt;
&lt;h2 id=&#34;using-the-query-editor&#34;&gt;Using the Query Editor&lt;/h2&gt;
&lt;p&gt;The Google Cloud Monitoring query editor allows you to build two types of queries - &lt;strong&gt;Metric&lt;/strong&gt; and &lt;strong&gt;Service Level Objective (SLO)&lt;/strong&gt;. Both types return time series data.&lt;/p&gt;
&lt;h3 id=&#34;metric-queries&#34;&gt;Metric Queries&lt;/h3&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--right&#34;
    style=&#34;max-width: 400px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png&#34;data-srcset=&#34;/static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=320 320w, /static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=550 550w, /static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=750 750w, /static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=900 900w, /static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=1040 1040w, /static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=1240 1240w, /static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;1016&#34;height=&#34;291&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png&#34;
            alt=&#34;&#34;width=&#34;1016&#34;height=&#34;291&#34;class=&#34;docs-image--right&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;The metric query editor allows you to select metrics, group/aggregate by labels and by time, and use filters to specify which time series you want in the results.&lt;/p&gt;
&lt;p&gt;To create a metric query, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Choose the option &lt;strong&gt;Metrics&lt;/strong&gt; in the &lt;strong&gt;Query Type&lt;/strong&gt; dropdown&lt;/li&gt;
&lt;li&gt;Choose a project from the &lt;strong&gt;Project&lt;/strong&gt; dropdown&lt;/li&gt;
&lt;li&gt;Choose a Google Cloud Platform service from the &lt;strong&gt;Service&lt;/strong&gt; dropdown&lt;/li&gt;
&lt;li&gt;Choose a metric from the &lt;strong&gt;Metric&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Use the plus and minus icons in the filter and group by sections to add/remove filters or group by clauses. This step is optional.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Google Cloud Monitoring supports different kinds of metrics like &lt;code&gt;GAUGE&lt;/code&gt;, &lt;code&gt;DELTA,&lt;/code&gt; and &lt;code&gt;CUMULATIVE&lt;/code&gt;. They support different aggregation options, for example, reducers and aligners. The Grafana query editor displays the list of available aggregation methods for a selected metric and sets a default reducer and aligner when you select the metric.&lt;/p&gt;
&lt;h4 id=&#34;filter&#34;&gt;Filter&lt;/h4&gt;
&lt;p&gt;To add a filter, click the plus icon and choose a field to filter by and enter a filter value e.g. &lt;code&gt;instance_name = grafana-1&lt;/code&gt;. You can remove the filter by clicking on the trash icon.&lt;/p&gt;
&lt;h5 id=&#34;simple-wildcards&#34;&gt;Simple wildcards&lt;/h5&gt;
&lt;p&gt;When the operator is set to &lt;code&gt;=&lt;/code&gt; or &lt;code&gt;!=&lt;/code&gt; it is possible to add wildcards to the filter value field. E.g &lt;code&gt;us-*&lt;/code&gt; will capture all values that starts with &amp;ldquo;us-&amp;rdquo; and &lt;code&gt;*central-a&lt;/code&gt; will capture all values that ends with &amp;ldquo;central-a&amp;rdquo;. &lt;code&gt;*-central-*&lt;/code&gt; captures all values that has the substring of -central-. Simple wildcards are less expensive than regular expressions.&lt;/p&gt;
&lt;h5 id=&#34;regular-expressions&#34;&gt;Regular expressions&lt;/h5&gt;
&lt;p&gt;When the operator is set to &lt;code&gt;=~&lt;/code&gt; or &lt;code&gt;!=~&lt;/code&gt; it is possible to add regular expressions to the filter value field. E.g &lt;code&gt;us-central[1-3]-[af]&lt;/code&gt; would match all values that starts with &amp;ldquo;us-central&amp;rdquo;, is followed by a number in the range of 1 to 3, a dash and then either an &amp;ldquo;a&amp;rdquo; or an &amp;ldquo;f&amp;rdquo;. Leading and trailing slashes are not needed when creating regular expressions.&lt;/p&gt;
&lt;h4 id=&#34;pre-processing&#34;&gt;Pre-processing&lt;/h4&gt;
&lt;p&gt;Preprocessing options are displayed in the UI when the selected metric has a metric kind of &lt;code&gt;delta&lt;/code&gt; or &lt;code&gt;cumulative&lt;/code&gt;. If the selected metric has a metric kind of &lt;code&gt;gauge&lt;/code&gt;, no pre-processing option will be displayed.&lt;/p&gt;
&lt;p&gt;If you select &lt;code&gt;Rate&lt;/code&gt;, data points are aligned and converted to a rate per time series. If you select &lt;code&gt;Delta&lt;/code&gt;, data points are aligned by their delta (difference) per time series.&lt;/p&gt;
&lt;h4 id=&#34;grouping&#34;&gt;Grouping&lt;/h4&gt;
&lt;p&gt;You can reduce the amount of data returned for a metric by combining different time series. To combine multiple time series, specify a grouping and a function.&lt;/p&gt;
&lt;h5 id=&#34;group-by&#34;&gt;Group by&lt;/h5&gt;
&lt;p&gt;Group by resource or metric labels to reduce the number of time series and to aggregate the results by a group. For example, group by &lt;code&gt;instance_name&lt;/code&gt; to view an aggregated metric for a Compute instance.&lt;/p&gt;
&lt;h6 id=&#34;metadata-labels&#34;&gt;Metadata labels&lt;/h6&gt;
&lt;p&gt;Resource metadata labels contain information that can uniquely identify a resource in Google Cloud. Metadata labels are only returned in the time series response if they&amp;rsquo;re part of the &lt;strong&gt;Group By&lt;/strong&gt; segment in the time series request.&lt;/p&gt;
&lt;p&gt;There&amp;rsquo;s no API for retrieving metadata labels. As a result, you cannot populate the group by list with the metadata labels that are available for the selected service and metric. However, the &lt;strong&gt;Group By&lt;/strong&gt; field list comes with a pre-defined set of common system labels.&lt;/p&gt;
&lt;p&gt;User labels cannot be predefined, but you can enter them manually in the &lt;strong&gt;Group By&lt;/strong&gt; field. If a metadata label, user label, or system label is included in the &lt;strong&gt;Group By&lt;/strong&gt; segment, then you can create filters based on it and expand its value on the &lt;strong&gt;Alias&lt;/strong&gt; field.&lt;/p&gt;
&lt;h5 id=&#34;group-by-function&#34;&gt;Group by function&lt;/h5&gt;
&lt;p&gt;Select a grouping function to combine the time series in the group into a single time series.&lt;/p&gt;
&lt;h4 id=&#34;alignment&#34;&gt;Alignment&lt;/h4&gt;
&lt;p&gt;The process of alignment consists of collecting all data points received in a fixed length of time, applying a function to combine those data points, and assigning a timestamp to the result.&lt;/p&gt;
&lt;h5 id=&#34;alignment-function&#34;&gt;Alignment function&lt;/h5&gt;
&lt;p&gt;During alignment, all data points are received in a fixed interval. Within each interval (determined by the alignment period) and for each time series, the data is aggregated into a single point. The value of that point is determined by the type of alignment function used. For more information on alignment functions, refer to &lt;a href=&#34;https://cloud.google.com/monitoring/charts/metrics-selector#alignment&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;alignment metric selector&lt;/a&gt;.&lt;/p&gt;
&lt;h5 id=&#34;alignment-period&#34;&gt;Alignment period&lt;/h5&gt;
&lt;p&gt;The &lt;code&gt;Alignment Period&lt;/code&gt; groups a metric by time if an aggregation is chosen. The default is to use the GCP Google Cloud Monitoring default groupings (which allows you to compare graphs in Grafana with graphs in the Google Cloud Monitoring UI).
The option is called &lt;code&gt;cloud monitoring auto&lt;/code&gt; and the defaults are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;1m for time ranges &amp;lt; 23 hours&lt;/li&gt;
&lt;li&gt;5m for time ranges &amp;gt;= 23 hours and &amp;lt; 6 days&lt;/li&gt;
&lt;li&gt;1h for time ranges &amp;gt;= 6 days&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The other automatic option is &lt;code&gt;grafana auto&lt;/code&gt;. This will automatically set the group by time depending on the time range chosen and the width of the time series panel. For more information about grafana auto, refer to the &lt;a href=&#34;../../variables/variable-types/add-interval-variable/&#34;&gt;interval variable&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can also choose fixed time intervals to group by, like &lt;code&gt;1h&lt;/code&gt; or &lt;code&gt;1d&lt;/code&gt;.&lt;/p&gt;
&lt;h4 id=&#34;alias-patterns&#34;&gt;Alias patterns&lt;/h4&gt;
&lt;p&gt;The Alias By field allows you to control the format of the legend keys. The default is to show the metric name and labels. This can be long and hard to read. Using the following patterns in the alias field, you can format the legend key the way you want it.&lt;/p&gt;
&lt;h4 id=&#34;metric-type-patterns&#34;&gt;Metric type patterns&lt;/h4&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;Alias Pattern&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Example Result&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metric.type}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the full Metric Type&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;compute.googleapis.com/instance/cpu/utilization&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metric.name}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the metric name part&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;instance/cpu/utilization&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metric.service}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the service part&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;compute&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h4 id=&#34;label-patterns&#34;&gt;Label patterns&lt;/h4&gt;
&lt;p&gt;In the Group By dropdown, you can see a list of metric and resource labels for a metric. These can be included in the legend key using alias patterns.&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;Alias Pattern Format&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Alias Pattern Example&lt;/th&gt;
              &lt;th&gt;Example Result&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metric.label.xxx}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the metric label value&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{metric.label.instance_name}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;grafana-1-prod&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{resource.label.xxx}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the resource label value&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{resource.label.zone}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;us-east1-b&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metadata.system_labels.xxx}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the meta data system label value&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{metadata.system_labels.name}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;grafana&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metadata.user_labels.xxx}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the meta data user label value&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{metadata.user_labels.tag}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;production&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Example Alias By: &lt;code&gt;{{metric.type}} - {{metric.label.instance_name}}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Example Result: &lt;code&gt;compute.googleapis.com/instance/cpu/usage_time - server1-prod&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;It is also possible to resolve the name of the Monitored Resource 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;Alias Pattern Format&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Example Result&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{resource.type}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the name of the monitored resource type&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;gce_instance&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Example Alias By: &lt;code&gt;{{resource.type}} - {{metric.type}}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Example Result: &lt;code&gt;gce_instance - compute.googleapis.com/instance/cpu/usage_time&lt;/code&gt;&lt;/p&gt;
&lt;h4 id=&#34;deep-linking-from-grafana-panels-to-the-metrics-explorer-in-google-cloud-console&#34;&gt;Deep linking from Grafana panels to the Metrics Explorer in Google Cloud Console&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Available in Grafana v7.1 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--right&#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/v71/cloudmonitoring_deep_linking.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/v71/cloudmonitoring_deep_linking.png&#34;data-srcset=&#34;/static/img/docs/v71/cloudmonitoring_deep_linking.png?w=320 320w, /static/img/docs/v71/cloudmonitoring_deep_linking.png?w=550 550w, /static/img/docs/v71/cloudmonitoring_deep_linking.png?w=750 750w, /static/img/docs/v71/cloudmonitoring_deep_linking.png?w=900 900w, /static/img/docs/v71/cloudmonitoring_deep_linking.png?w=1040 1040w, /static/img/docs/v71/cloudmonitoring_deep_linking.png?w=1240 1240w, /static/img/docs/v71/cloudmonitoring_deep_linking.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Google Cloud Monitoring deep linking&#34;width=&#34;450&#34;height=&#34;163&#34;title=&#34;Google Cloud Monitoring deep linking&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v71/cloudmonitoring_deep_linking.png&#34;
            alt=&#34;Google Cloud Monitoring deep linking&#34;width=&#34;450&#34;height=&#34;163&#34;title=&#34;Google Cloud Monitoring deep linking&#34;class=&#34;docs-image--right&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Google Cloud Monitoring deep linking&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Click on a time series in the panel to see a context menu with a link to View in Metrics Explorer in Google Cloud Console. Clicking that link opens the Metrics Explorer in the Google Cloud Console and runs the query from the Grafana panel there.
The link navigates the user first to the Google Account Chooser and after successfully selecting an account, the user is redirected to the Metrics Explorer. The provided link is valid for any account, but it only displays the query if your account has access to the GCP project specified in the query.&lt;/p&gt;
&lt;h4 id=&#34;automatic-unit-detection&#34;&gt;Automatic unit detection&lt;/h4&gt;
&lt;p&gt;Grafana issues one query to the Cloud Monitoring API per query editor row, and each API response includes a unit. Grafana will attempt to convert the returned unit into a unit that is understood by the Grafana time series panel. If the conversion was successful, then the unit will be displayed on the Y-axis on the panel. If the query editor rows returned different units, then the unit from the last query editor row is used in the time series panel.&lt;/p&gt;
&lt;h3 id=&#34;slo-service-level-objective-queries&#34;&gt;SLO (Service Level Objective) queries&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Available in Grafana v7.0 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--right&#34;
    style=&#34;max-width: 400px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png&#34;data-srcset=&#34;/static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=320 320w, /static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=550 550w, /static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=750 750w, /static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=900 900w, /static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=1040 1040w, /static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=1240 1240w, /static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;735&#34;height=&#34;259&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png&#34;
            alt=&#34;&#34;width=&#34;735&#34;height=&#34;259&#34;class=&#34;docs-image--right&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;The SLO query builder in the Google Cloud Monitoring data source allows you to display SLO data in time series format. To get an understanding of the basic concepts in service monitoring, please refer to Google Cloud Monitoring&amp;rsquo;s &lt;a href=&#34;https://cloud.google.com/monitoring/service-monitoring&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;official docs&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;how-to-create-an-slo-query&#34;&gt;How to create an SLO query&lt;/h4&gt;
&lt;p&gt;To create an SLO query, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Choose the option &lt;strong&gt;Service Level Objectives (SLO)&lt;/strong&gt; in the &lt;strong&gt;Query Type&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Choose a project from the &lt;strong&gt;Project&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Choose an &lt;a href=&#34;https://cloud.google.com/monitoring/api/ref_v3/rest/v3/services&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;SLO service&lt;/a&gt; from the &lt;strong&gt;Service&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Choose an &lt;a href=&#34;https://cloud.google.com/monitoring/api/ref_v3/rest/v3/services.serviceLevelObjectives&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;SLO&lt;/a&gt; from the &lt;strong&gt;SLO&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Choose a &lt;a href=&#34;https://cloud.google.com/stackdriver/docs/solutions/slo-monitoring/api/timeseries-selectors#ts-selector-list&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;time series selector&lt;/a&gt; from the &lt;strong&gt;Selector&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The friendly names for the time series selectors are shown in Grafana. Here is the mapping from the friendly name to the system name that is used in the Service Monitoring documentation:&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;Selector dropdown value&lt;/th&gt;
              &lt;th&gt;Corresponding time series selector used&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;SLI Value&lt;/td&gt;
              &lt;td&gt;select_slo_health&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;SLO Compliance&lt;/td&gt;
              &lt;td&gt;select_slo_compliance&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;SLO Error Budget Remaining&lt;/td&gt;
              &lt;td&gt;select_slo_budget_fraction&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h4 id=&#34;alias-patterns-for-slo-queries&#34;&gt;Alias patterns for SLO queries&lt;/h4&gt;
&lt;p&gt;The Alias By field allows you to control the format of the legend keys for SLO queries too.&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;Alias Pattern&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Example Result&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{project}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the GCP project name&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;myProject&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{service}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the service name&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;myService&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{slo}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the SLO&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;latency-slo&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{selector}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the selector&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;select_slo_health&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h4 id=&#34;alignment-periodgroup-by-time-for-slo-queries&#34;&gt;Alignment period/group by time for SLO queries&lt;/h4&gt;
&lt;p&gt;SLO queries use the same &lt;a href=&#34;#metric-queries&#34;&gt;alignment period functionality as metric queries&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;mql-monitoring-query-language-queries&#34;&gt;MQL (Monitoring Query Language) queries&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Available in Grafana v7.4 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The MQL query builder in the Google Cloud Monitoring data source allows you to display MQL results in time series format. To get an understanding of the basic concepts in MQL, refer to &lt;a href=&#34;https://cloud.google.com/monitoring/mql&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Introduction to Monitoring Query Language&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;create-an-mql-query&#34;&gt;Create an MQL query&lt;/h4&gt;
&lt;p&gt;To create an MQL query, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In the &lt;strong&gt;Query Type&lt;/strong&gt; list, select &lt;strong&gt;Metrics&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;&amp;lt;&amp;gt; Edit MQL&lt;/strong&gt; right next to the &lt;strong&gt;Query Type&lt;/strong&gt; field. This will toggle the metric query builder mode so that raw MQL queries can be used.&lt;/li&gt;
&lt;li&gt;Choose a project from the &lt;strong&gt;Project&lt;/strong&gt; list.&lt;/li&gt;
&lt;li&gt;Add the &lt;a href=&#34;https://cloud.google.com/monitoring/mql/query-language&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;MQL&lt;/a&gt; query of your choice in the text area.&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;alias-patterns-for-mql-queries&#34;&gt;Alias patterns for MQL queries&lt;/h4&gt;
&lt;p&gt;MQL queries use the same alias patterns as &lt;a href=&#34;#metric-queries&#34;&gt;metric queries&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;{{metric.service}}&lt;/code&gt; is not supported. &lt;code&gt;{{metric.type}}&lt;/code&gt; and &lt;code&gt;{{metric.name}}&lt;/code&gt; show the time series key in the response.&lt;/p&gt;
&lt;h2 id=&#34;templating&#34;&gt;Templating&lt;/h2&gt;
&lt;p&gt;Instead of hard-coding things like server, application and sensor name in your metric queries you can use variables in their place.
Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns make it easy to change the data
being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Check out the &lt;a href=&#34;../../variables/&#34;&gt;Templating&lt;/a&gt; documentation for an introduction to the templating feature and the different
types of template variables.&lt;/p&gt;
&lt;h3 id=&#34;query-variable&#34;&gt;Query Variable&lt;/h3&gt;
&lt;p&gt;Variable of the type &lt;em&gt;Query&lt;/em&gt; allows you to query Google Cloud Monitoring for various types of data. The Google Cloud Monitoring data source plugin provides the following &lt;code&gt;Query Types&lt;/code&gt;.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&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;Metric Types&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of metric type names that are available for the specified service.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Labels Keys&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of keys for &lt;code&gt;metric label&lt;/code&gt; and &lt;code&gt;resource label&lt;/code&gt; in the specified metric.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Labels Values&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of values for the label in the specified metric.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Resource Types&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of resource types for the specified metric.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Aggregations&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of aggregations (cross series reducers) for the specified metric.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Aligners&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of aligners (per series aligners) for the specified metric.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Alignment periods&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of all alignment periods that are available in Google Cloud Monitoring query editor in Grafana&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Selectors&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of selectors that can be used in SLO (Service Level Objectives) queries&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;SLO Services&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of Service Monitoring services that can be used in SLO queries&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Service Level Objectives (SLO)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of SLO&amp;rsquo;s for the specified SLO service&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;using-variables-in-queries&#34;&gt;Using variables in queries&lt;/h3&gt;
&lt;p&gt;Refer to the &lt;a href=&#34;../../variables/syntax/&#34;&gt;variable syntax documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--right&#34;
    style=&#34;max-width: 400px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/static/img/docs/google-cloud-monitoring/annotations-8-0.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/static/img/docs/google-cloud-monitoring/annotations-8-0.png&#34;data-srcset=&#34;/static/img/docs/google-cloud-monitoring/annotations-8-0.png?w=320 320w, /static/img/docs/google-cloud-monitoring/annotations-8-0.png?w=550 550w, /static/img/docs/google-cloud-monitoring/annotations-8-0.png?w=750 750w, /static/img/docs/google-cloud-monitoring/annotations-8-0.png?w=900 900w, /static/img/docs/google-cloud-monitoring/annotations-8-0.png?w=1040 1040w, /static/img/docs/google-cloud-monitoring/annotations-8-0.png?w=1240 1240w, /static/img/docs/google-cloud-monitoring/annotations-8-0.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;735&#34;height=&#34;197&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/google-cloud-monitoring/annotations-8-0.png&#34;
            alt=&#34;&#34;width=&#34;735&#34;height=&#34;197&#34;class=&#34;docs-image--right&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;&lt;a href=&#34;../../dashboards/annotations/&#34;&gt;Annotations&lt;/a&gt; allow you to overlay rich event information on top of graphs. You add annotation
queries via the Dashboard menu / Annotations view. Annotation rendering is expensive so it is important to limit the number of rows returned. There is no support for showing Google Cloud Monitoring annotations and events yet but it works well with &lt;a href=&#34;https://cloud.google.com/monitoring/custom-metrics/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;custom metrics&lt;/a&gt; in Google Cloud Monitoring.&lt;/p&gt;
&lt;p&gt;With the query editor for annotations, you can select a metric and filters. The &lt;code&gt;Title&lt;/code&gt; and &lt;code&gt;Text&lt;/code&gt; fields support templating and can use data returned from the query. For example, the Title field could have the following text:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;{{metric.type}} has value: {{metric.value}}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Example Result: &lt;code&gt;monitoring.googleapis.com/uptime_check/http_status has this value: 502&lt;/code&gt;&lt;/p&gt;
&lt;h3 id=&#34;patterns-for-the-annotation-query-editor&#34;&gt;Patterns for the Annotation Query Editor&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;Alias Pattern Format&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Alias Pattern Example&lt;/th&gt;
              &lt;th&gt;Example Result&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metric.value}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;value of the metric/point&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{metric.value}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;555&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metric.type}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the full Metric Type&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{metric.type}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;compute.googleapis.com/instance/cpu/utilization&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metric.name}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the metric name part&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{metric.name}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;instance/cpu/utilization&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metric.service}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the service part&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{metric.service}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;compute&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metric.label.xxx}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the metric label value&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{metric.label.instance_name}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;grafana-1-prod&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{resource.label.xxx}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;returns the resource label value&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{resource.label.zone}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;us-east1-b&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;configure-the-data-source-with-provisioning&#34;&gt;Configure the data source with provisioning&lt;/h2&gt;
&lt;p&gt;You can provision CloudWatch data source by modifying Grafana&amp;rsquo;s configuration files. To learn more about provisioning and all the settings you can set, see the &lt;a href=&#34;../../administration/provisioning/#data-sources&#34;&gt;provisioning documentation&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is a provisioning example using the JWT (Service Account key file) authentication type.&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: Google Cloud Monitoring
    type: stackdriver
    access: proxy
    jsonData:
      tokenUri: https://oauth2.googleapis.com/token
      clientEmail: stackdriver@myproject.iam.gserviceaccount.com
      authenticationType: jwt
      defaultProject: my-project-name
    secureJsonData:
      privateKey: |
        -----BEGIN PRIVATE KEY-----
        POSEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCb1u1Srw8ICYHS
        ...
        yA&amp;#43;23427282348234=
        -----END PRIVATE KEY-----&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here is a provisioning example using GCE Default Service Account 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;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: Google Cloud Monitoring
    type: stackdriver
    access: proxy
    jsonData:
      authenticationType: gce&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="using-google-cloud-monitoring-in-grafana">Using Google Cloud Monitoring in Grafana&lt;/h1>
&lt;p>Grafana ships with built-in support for Google Cloud Monitoring. Add it as a data source to build dashboards for your Google Cloud Monitoring metrics. For instructions on how to add a data source, refer to &lt;a href="../add-a-data-source/">Add a data source&lt;/a>. Only users with the organization admin role can add data sources.&lt;/p></description></item><item><title>Graphite</title><link>https://grafana.com/docs/grafana/v8.4/datasources/graphite/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/graphite/</guid><content><![CDATA[&lt;h1 id=&#34;using-graphite-in-grafana&#34;&gt;Using Graphite in Grafana&lt;/h1&gt;
&lt;p&gt;Grafana has an advanced Graphite query editor that lets you quickly navigate the metric space, add functions,
change function parameters and much more. The editor can handle all types of graphite queries. It can even handle complex nested
queries through the use of query references.&lt;/p&gt;
&lt;p&gt;Refer to &lt;a href=&#34;../add-a-data-source/&#34;&gt;Add a data source&lt;/a&gt; for instructions on how to add a data source to Grafana. Only organization admins can add data sources. To learn more about the Graphite data source, refer to Graphite&amp;rsquo;s &lt;a href=&#34;https://graphite.readthedocs.io/en/stable/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;product documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;graphite-settings&#34;&gt;Graphite settings&lt;/h2&gt;
&lt;p&gt;To access Graphite settings, hover your mouse over the &lt;strong&gt;Configuration&lt;/strong&gt; (gear) icon, then click &lt;strong&gt;Data Sources&lt;/strong&gt;, and then click the Graphite data source.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The data source name. This is how you refer to the data source in panels and queries.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Default&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Default data source means that it will be pre-selected for new panels.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;URL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The HTTP protocol, IP, and port of your graphite-web or graphite-api install.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Auth&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Refer to &lt;a href=&#34;../../auth/&#34;&gt;Authentication&lt;/a&gt; for more information.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Basic Auth&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enable basic authentication to the data source.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;User&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;User name for basic authentication.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Password&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Password for basic authentication.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Custom HTTP Headers&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Click &lt;strong&gt;Add header&lt;/strong&gt; to add a custom HTTP header.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Header&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enter the custom header name.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Value&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enter the custom header value.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Graphite details&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Version&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Select your version of Graphite.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Type&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Select your type of Graphite.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;graphite-query-editor&#34;&gt;Graphite query editor&lt;/h2&gt;
&lt;p&gt;Grafana includes a Graphite-specific query editor to help you build your queries.&lt;/p&gt;
&lt;p&gt;To see the raw text of the query that is sent to Graphite, click the &lt;strong&gt;Toggle text edit mode&lt;/strong&gt; (pencil) icon.&lt;/p&gt;
&lt;h3 id=&#34;choose-metrics-to-query&#34;&gt;Choose metrics to query&lt;/h3&gt;
&lt;p&gt;Click &lt;strong&gt;Select metric&lt;/strong&gt; to start navigating the metric space. Once you start, you can continue using the mouse or keyboard arrow keys. You can select a wildcard and still continue.&lt;/p&gt;
&lt;div class=&#34;screenshot&#34; style=&#34;max-width:&#34;&gt;
  &lt;a href=&#34;/static/img/docs/graphite/graphite-query-editor.gif&#34; title=&#34;&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==&#34;
         data-src=&#34;/static/img/docs/graphite/graphite-query-editor-still.png&#34; class=&#34;screenshot__still lazyload&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;/static/img/docs/graphite/graphite-query-editor.gif&#34; class=&#34;screenshot__animated-gif&#34;&gt;
    &lt;div class=&#34;screenshot__play&#34;&gt;
      &lt;i class=&#34;fa fa-play&#34;&gt;&lt;/i&gt;
    &lt;/div&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;h3 id=&#34;functions&#34;&gt;Functions&lt;/h3&gt;
&lt;p&gt;Click the plus icon next to &lt;strong&gt;Function&lt;/strong&gt; to add a function. You can search for the function or select it from the menu. Once
a function is selected, it will be added and your focus will be in the text box of the first parameter.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;To edit or change a parameter, click on it and it will turn into a text box.&lt;/li&gt;
&lt;li&gt;To delete a function, click the function name followed by the x icon.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;screenshot&#34; style=&#34;max-width:&#34;&gt;
  &lt;a href=&#34;/static/img/docs/graphite/graphite-functions-demo.gif&#34; title=&#34;&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==&#34;
         data-src=&#34;/static/img/docs/graphite/graphite-functions-still.png&#34; class=&#34;screenshot__still lazyload&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;/static/img/docs/graphite/graphite-functions-demo.gif&#34; class=&#34;screenshot__animated-gif&#34;&gt;
    &lt;div class=&#34;screenshot__play&#34;&gt;
      &lt;i class=&#34;fa fa-play&#34;&gt;&lt;/i&gt;
    &lt;/div&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Some functions like aliasByNode support an optional second argument. To add an argument, hover your mouse over the first argument and then click the &lt;code&gt;&#43;&lt;/code&gt; symbol that appears. To remove the second optional parameter, click on it and leave it blank and the editor will remove it.&lt;/p&gt;
&lt;p&gt;To learn more, refer to &lt;a href=&#34;https://graphite.readthedocs.io/en/latest/functions.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Graphite&amp;rsquo;s documentation on functions&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;sort-labels&#34;&gt;Sort labels&lt;/h3&gt;
&lt;p&gt;If you want consistent ordering, use sortByName. This can be particularly annoying when you have the same labels on multiple graphs, and they are both sorted differently and using different colors. To fix this, use &lt;code&gt;sortByName()&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;nested-queries&#34;&gt;Nested queries&lt;/h3&gt;
&lt;p&gt;You can reference queries by the row “letter” that they’re on (similar to Microsoft Excel). If you add a second query to a graph, you can reference the first query simply by typing in #A. This provides an easy and convenient way to build compounded queries.&lt;/p&gt;
&lt;h3 id=&#34;avoiding-many-queries-by-using-wildcards&#34;&gt;Avoiding many queries by using wildcards&lt;/h3&gt;
&lt;p&gt;Occasionally one would like to see multiple time series plotted on the same graph. For example we might want to see how the CPU is being utilized on a machine. You might
initially create the graph by adding a query for each time series, such as &lt;code&gt;cpu.percent.user.g&lt;/code&gt;,
&lt;code&gt;cpu.percent.system.g&lt;/code&gt;, and so on. This results in &lt;em&gt;n&lt;/em&gt; queries made to the data source, which is inefficient.&lt;/p&gt;
&lt;p&gt;To be more efficient one can use wildcards in your search, returning all the time series in one query. For example, &lt;code&gt;cpu.percent.*.g&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;modify-the-metric-name-in-my-tables-or-charts&#34;&gt;Modify the metric name in my tables or charts&lt;/h3&gt;
&lt;p&gt;Use &lt;code&gt;alias&lt;/code&gt; functions to change metric names on Grafana tables or graphs For example &lt;code&gt;aliasByNode()&lt;/code&gt; or &lt;code&gt;aliasSub()&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;point-consolidation&#34;&gt;Point consolidation&lt;/h2&gt;
&lt;p&gt;All Graphite metrics are consolidated so that Graphite doesn&amp;rsquo;t return more data points than there are pixels in the graph. By default,
this consolidation is done using &lt;code&gt;avg&lt;/code&gt; function. You can control how Graphite consolidates metrics by adding the Graphite consolidateBy function.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This means that legend summary values (max, min, total) cannot all be correct at the same time. They are calculated
client-side by Grafana. And depending on your consolidation function, only one or two can be correct at the same time.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;combine-time-series&#34;&gt;Combine time series&lt;/h2&gt;
&lt;p&gt;To combine time series, click &lt;strong&gt;Combine&lt;/strong&gt; in the &lt;strong&gt;Functions&lt;/strong&gt; list.&lt;/p&gt;
&lt;h2 id=&#34;data-exploration-and-tags&#34;&gt;Data exploration and tags&lt;/h2&gt;
&lt;p&gt;In Graphite, &lt;em&gt;everything&lt;/em&gt; is a tag.&lt;/p&gt;
&lt;p&gt;When exploring data, previously-selected tags are used to filter the remaining result set. To select data, you use the
&lt;code&gt;seriesByTag&lt;/code&gt; function, which takes tag expressions (&lt;code&gt;=&lt;/code&gt;, &lt;code&gt;!=&lt;/code&gt;, &lt;code&gt;=~&lt;/code&gt;, &lt;code&gt;!=~&lt;/code&gt;) to filter timeseries.&lt;/p&gt;
&lt;p&gt;The Grafana query builder does this for you automatically when you select a tag.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; The regular expression search can be quite slow on high-cardinality tags, so try to use other tags to reduce the scope first.
Starting off with a particular name/namespace can help reduce the results.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;template-variables&#34;&gt;Template variables&lt;/h2&gt;
&lt;p&gt;Instead of hard-coding things like server, application, and sensor name in your metric queries, you can use variables in their place.
Variables are shown as drop-down select boxes at the top of the dashboard. These dropdowns make it easy to change the data
being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;For more information, refer to &lt;a href=&#34;../../variables/&#34;&gt;Variables and templates&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Graphite 1.1 introduced tags and Grafana added support for Graphite queries with tags in version 5.0. To create a variable using tag values, use the Grafana functions &lt;code&gt;tags&lt;/code&gt; and &lt;code&gt;tag_values&lt;/code&gt;.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Query&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;tags()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns all tags.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tags(server=~backend\*)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns only tags that occur in series matching the filter expression.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tag_values(server)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Return tag values for the specified tag.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tag_values(server, server=~backend\*)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns filtered tag values that occur for the specified tag in series matching those expressions.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tag_values(server, server=~backend\*, app=~${apps:regex})&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Multiple filter expressions and expressions can contain other variables.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;For more details, see the &lt;a href=&#34;http://graphite.readthedocs.io/en/latest/tags.html#auto-complete-support&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Graphite docs on the autocomplete API for tags&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;query-variable&#34;&gt;Query variable&lt;/h3&gt;
&lt;p&gt;The query you specify in the query field should be a metric find type of query. For example, a query like &lt;code&gt;prod.servers.*&lt;/code&gt; fills the
variable with all possible values that exist in the wildcard position.&lt;/p&gt;
&lt;p&gt;The results contain all possible values occurring only at the last level of the query. To get full metric names matching the query
use expand function (&lt;code&gt;expand(*.servers.*)&lt;/code&gt;).&lt;/p&gt;
&lt;h4 id=&#34;comparison-between-expanded-and-non-expanded-metric-search-results&#34;&gt;Comparison between expanded and non-expanded metric search results&lt;/h4&gt;
&lt;p&gt;The expanded query returns the full names of matching metrics. In combination with regex, it can extract any part of the metric name. By contrast, a non-expanded query only returns the last part of the metric name. It does not allow you to extract other parts of metric names.&lt;/p&gt;
&lt;p&gt;Here are some example metrics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;prod.servers.001.cpu&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;prod.servers.002.cpu&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;test.servers.001.cpu&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The following examples show how expanded and non-expanded queries can be used to fetch specific parts of the metrics name.&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;non-expanded query&lt;/th&gt;
              &lt;th&gt;results&lt;/th&gt;
              &lt;th&gt;expanded query&lt;/th&gt;
              &lt;th&gt;expanded results&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;*&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;prod, test&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;expand(*)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;prod, test&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;*.servers&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;servers&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;expand(*.servers)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;prod.servers, test.servers&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;test.servers&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;servers&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;expand(test.servers)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;test.servers&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;*.servers.*&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;001,002&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;expand(*.servers.*)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;prod.servers.001, prod.servers.002, test.servers.001&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;test.servers.*&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;001&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;expand(test.servers.*)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;test.servers.001&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;*.servers.*.cpu&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;cpu&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;expand(*.servers.*.cpu)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;prod.servers.001.cpu, prod.servers.002.cpu, test.servers.001.cpu&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;As you can see from the results, the non-expanded query is the same as an expanded query with a regex matching the last part of the name.&lt;/p&gt;
&lt;p&gt;You can also create nested variables that use other variables in their definition. For example
&lt;code&gt;apps.$app.servers.*&lt;/code&gt; uses the variable &lt;code&gt;$app&lt;/code&gt; in its query definition.&lt;/p&gt;
&lt;h4 id=&#34;using-__searchfilter-to-filter-query-variable-results&#34;&gt;Using &lt;code&gt;__searchFilter&lt;/code&gt; to filter query variable results&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;Available from Grafana 6.5 and above&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Using &lt;code&gt;__searchFilter&lt;/code&gt; in the query field will filter the query result based on what the user types in the dropdown select box.
When nothing has been entered by the user the default value for &lt;code&gt;__searchFilter&lt;/code&gt; is &lt;code&gt;*&lt;/code&gt; and `` when used as part of a regular expression.&lt;/p&gt;
&lt;p&gt;The example below shows how to use &lt;code&gt;__searchFilter&lt;/code&gt; as part of the query field to enable searching for &lt;code&gt;server&lt;/code&gt; while the user types in the dropdown select box.&lt;/p&gt;
&lt;p&gt;Query&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;apps.$app.servers.$__searchFilter&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;TagValues&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;tag_values(server, server=~${__searchFilter:regex})&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;variable-usage&#34;&gt;Variable usage&lt;/h3&gt;
&lt;p&gt;You can use a variable in a metric node path or as a parameter to a function.
&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/v2/templated_variable_parameter.png&#34;
  alt=&#34;variable&#34; width=&#34;901&#34;
     height=&#34;69&#34;/&gt;&lt;/p&gt;
&lt;p&gt;There are two syntaxes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;$&amp;lt;varname&amp;gt;&lt;/code&gt; Example: apps.frontend.$server.requests.count&lt;/li&gt;
&lt;li&gt;&lt;code&gt;${varname}&lt;/code&gt; Example: apps.frontend.${server}.requests.count&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of a word. Use
the second syntax in expressions like &lt;code&gt;my.server${serverNumber}.count&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Example:
&lt;a href=&#34;https://play.grafana.org/dashboard/db/graphite-templated-nested&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Graphite Templated Dashboard&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&#34;variable-usage-in-tag-queries&#34;&gt;Variable usage in tag queries&lt;/h3&gt;
&lt;p&gt;Multi-value variables in tag queries use the advanced formatting syntax introduced in Grafana 5.0 for variables: &lt;code&gt;{var:regex}&lt;/code&gt;. Non-tag queries will use the default glob formatting for multi-value variables.&lt;/p&gt;
&lt;p&gt;Example of a tag expression with regex formatting and using the Equal Tilde operator, &lt;code&gt;=~&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;text&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-text&#34;&gt;server=~${servers:regex}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For more information, refer to &lt;a href=&#34;../../variables/advanced-variable-format-options/&#34;&gt;Advanced variable format options&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;../../dashboards/annotations/&#34;&gt;Annotations&lt;/a&gt; allow you to overlay rich event information on top of graphs. You add annotation
queries via the Dashboard menu / Annotations view.&lt;/p&gt;
&lt;p&gt;Graphite supports two ways to query annotations. A regular metric query, for this you use the &lt;code&gt;Graphite query&lt;/code&gt; textbox. A Graphite events query, use the &lt;code&gt;Graphite event tags&lt;/code&gt; textbox,
specify a tag or wildcard (leave empty should also work)&lt;/p&gt;
&lt;h2 id=&#34;get-grafana-metrics-into-graphite&#34;&gt;Get Grafana metrics into Graphite&lt;/h2&gt;
&lt;p&gt;Grafana exposes metrics for Graphite on the &lt;code&gt;/metrics&lt;/code&gt; endpoint. For detailed instructions, refer to &lt;a href=&#34;../../administration/view-server/internal-metrics/&#34;&gt;Internal Grafana metrics&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;configure-the-data-source-with-provisioning&#34;&gt;Configure the data source with provisioning&lt;/h2&gt;
&lt;p&gt;It&amp;rsquo;s now possible to configure data sources using config files with Grafana&amp;rsquo;s provisioning system. You can read more about how it works and all the settings you can set for data sources on the &lt;a href=&#34;../../administration/provisioning/#datasources&#34;&gt;provisioning docs page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here are some provisioning examples for this data source.&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: Graphite
    type: graphite
    access: proxy
    url: http://localhost:8080
    jsonData:
      graphiteVersion: &amp;#39;1.1&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;integration-with-loki&#34;&gt;Integration with Loki&lt;/h2&gt;
&lt;p&gt;Graphite queries get converted to Loki queries when the data source selection changes in Explore. Loki label names and values are extracted from the Graphite queries according to mappings information provided in Graphite data source configuration. Queries using tags with &lt;code&gt;seriesByTags()&lt;/code&gt; are also transformed without any additional setup.&lt;/p&gt;
&lt;p&gt;Refer to the Graphite data source settings for more details.&lt;/p&gt;
]]></content><description>&lt;h1 id="using-graphite-in-grafana">Using Graphite in Grafana&lt;/h1>
&lt;p>Grafana has an advanced Graphite query editor that lets you quickly navigate the metric space, add functions,
change function parameters and much more. The editor can handle all types of graphite queries. It can even handle complex nested
queries through the use of query references.&lt;/p></description></item><item><title>InfluxDB data source</title><link>https://grafana.com/docs/grafana/v8.4/datasources/influxdb/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/influxdb/</guid><content><![CDATA[&lt;h1 id=&#34;influxdb-data-source&#34;&gt;InfluxDB data source&lt;/h1&gt;


&lt;div data-shared=&#34;influxdb/intro.md&#34;&gt;
            &lt;p&gt;&lt;a href=&#34;https://www.influxdata.com/products/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;InfluxDB&lt;/a&gt; is an open-source time series database (TSDB) developed by &lt;a href=&#34;https://www.influxdata.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;InfluxData&lt;/a&gt;. It is optimized for fast, high-availability storage and retrieval of time series data in fields such as operations monitoring, application metrics, IoT sensor data, and real-time analytics.&lt;/p&gt;
&lt;/div&gt;

        
&lt;p&gt;This topic explains options, variables, querying, and other options specific to this data source. Refer to &lt;a href=&#34;../add-a-data-source/&#34;&gt;Add a data source&lt;/a&gt; for instructions on how to add a data source to Grafana. Only users with the organization admin role can add data sources.&lt;/p&gt;
&lt;h2 id=&#34;data-source-options&#34;&gt;Data source options&lt;/h2&gt;
&lt;p&gt;To access data source settings, hover your mouse over the &lt;strong&gt;Configuration&lt;/strong&gt; (gear) icon, then click &lt;strong&gt;Data sources&lt;/strong&gt;, and then click the data source.&lt;/p&gt;
&lt;p&gt;InfluxDB data source options differ depending on which &lt;a href=&#34;#query-languages&#34;&gt;query language&lt;/a&gt; you select: InfluxQL or Flux.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Though not required, it&amp;rsquo;s a good practice to append the language choice to the data source name. For example:&lt;/p&gt;&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;InfluxDB-InfluxQL&lt;/li&gt;
&lt;li&gt;InfluxDB-Flux&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;influxql-classic-influxdb-query&#34;&gt;InfluxQL (classic InfluxDB query)&lt;/h3&gt;
&lt;p&gt;These options apply if you are using the InfluxQL query language. If you are using Flux, refer to &lt;a href=&#34;influxdb-flux/&#34;&gt;Flux support in Grafana&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;Name&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;Name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The data source name. This is how you refer to the data source in panels and queries. We recommend something like &lt;code&gt;InfluxDB-InfluxQL&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Default&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Default data source means that it will be pre-selected for new panels.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;URL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The HTTP protocol, IP address and port of your InfluxDB API. InfluxDB API port is by default 8086.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Access&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Server (default) = URL needs to be accessible from the Grafana backend/server, Browser = URL needs to be accessible from the browser. &lt;strong&gt;Note&lt;/strong&gt;: Browser (direct) access is deprecated and will be removed in a future release.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Allowed cookies&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Cookies that will be forwarded to the data source. All other cookies will be deleted.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Database&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The ID of the bucket you want to query from, copied from the &lt;a href=&#34;https://docs.influxdata.com/influxdb/v2.0/organizations/buckets/view-buckets/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Buckets page&lt;/a&gt; of the InfluxDB UI.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;User&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The username you use to sign into InfluxDB.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Password&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The token you use to query the bucket above, copied from the &lt;a href=&#34;https://docs.influxdata.com/influxdb/v2.0/security/tokens/view-tokens/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Tokens page&lt;/a&gt; of the InfluxDB UI.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;HTTP mode&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How to query the database (&lt;code&gt;GET&lt;/code&gt; or &lt;code&gt;POST&lt;/code&gt; HTTP verb). The &lt;code&gt;POST&lt;/code&gt; verb allows heavy queries that would return an error using the &lt;code&gt;GET&lt;/code&gt; verb. Default is &lt;code&gt;GET&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Min time interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;(Optional) Refer to &lt;a href=&#34;#min-time-interval&#34;&gt;Min time interval&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Max series&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;(Optional) Limits the number of series/tables that Grafana processes. Lower this number to prevent abuse, and increase it if you have lots of small time series and not all are shown. Defaults to 1000.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;flux&#34;&gt;Flux&lt;/h3&gt;
&lt;p&gt;For information on data source settings and using Flux in Grafana, refer to &lt;a href=&#34;influxdb-flux/&#34;&gt;Flux support in Grafana&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;min-time-interval&#34;&gt;Min time interval&lt;/h4&gt;
&lt;p&gt;A lower limit for the auto group by time interval. Recommended to be set to write frequency, for example &lt;code&gt;1m&lt;/code&gt; if your data is written every minute.
This option can also be overridden/configured in a dashboard panel under data source options. It&amp;rsquo;s important to note that this value &lt;em&gt;must&lt;/em&gt; be formatted as a number followed by a valid time identifier, e.g. &lt;code&gt;1m&lt;/code&gt; (1 minute) or &lt;code&gt;30s&lt;/code&gt; (30 seconds). The following time identifiers are supported:&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;Identifier&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;y&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;year&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;M&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;month&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;w&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;week&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;d&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;day&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;h&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;hour&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;m&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;minute&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;s&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;second&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ms&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;millisecond&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;query-languages&#34;&gt;Query languages&lt;/h2&gt;
&lt;p&gt;You can query InfluxDB using InfluxQL or Flux:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://docs.influxdata.com/influxdb/v1.8/query_language/explore-data/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;InfluxQL&lt;/a&gt; is a SQL-like language for querying InfluxDB, with statements such as SELECT, FROM, WHERE, and GROUP BY that are familiar to SQL users. InfluxQL is available in InfluxDB 1.0 onwards.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://docs.influxdata.com/influxdb/v2.0/query-data/get-started/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Flux&lt;/a&gt; provides significantly broader functionality than InfluxQL, supporting not only queries, but built-in functions for data shaping, string manipulation, joining to non-InfluxDB data sources and more, but also processing time-series data. It’s more similar to JavaScript with a functional style.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To help you choose the best language for your needs, here’s a comparison of &lt;a href=&#34;https://docs.influxdata.com/influxdb/v1.8/flux/flux-vs-influxql/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Flux vs InfluxQL&lt;/a&gt;, and &lt;a href=&#34;https://www.influxdata.com/blog/why-were-building-flux-a-new-data-scripting-and-query-language/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;why InfluxData created Flux&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;influxql-query-editor&#34;&gt;InfluxQL query editor&lt;/h2&gt;
&lt;p&gt;Enter edit mode by clicking the panel title and clicking &lt;strong&gt;Edit&lt;/strong&gt;. The editor allows you to select metrics and tags.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/influxdb/influxql-query-editor-8-0.png&#34;
  alt=&#34;InfluxQL query editor&#34; width=&#34;633&#34;
     height=&#34;267&#34;/&gt;&lt;/p&gt;
&lt;h3 id=&#34;filter-data-where&#34;&gt;Filter data (WHERE)&lt;/h3&gt;
&lt;p&gt;To add a tag filter, click the plus icon to the right of the &lt;code&gt;WHERE&lt;/code&gt; condition. You can remove tag filters by clicking on the tag key and then selecting &lt;code&gt;--remove tag filter--&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Regex matching&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can type in regex patterns for metric names or tag filter values. Be sure to wrap the regex pattern in forward slashes (&lt;code&gt;/&lt;/code&gt;). Grafana automatically adjusts the filter tag condition to use the InfluxDB regex match condition operator (&lt;code&gt;=~&lt;/code&gt;).&lt;/p&gt;
&lt;h3 id=&#34;field-and-aggregation-functions&#34;&gt;Field and Aggregation functions&lt;/h3&gt;
&lt;p&gt;In the &lt;code&gt;SELECT&lt;/code&gt; row you can specify what fields and functions you want to use. If you have a
group by time you need an aggregation function. Some functions like derivative require an aggregation function. The editor tries to simplify and unify this part of the query. For example:&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload&#34;
  data-src=&#34;/static/img/docs/influxdb/select_editor.png&#34;
  alt=&#34;&#34; width=&#34;657&#34;
     height=&#34;46&#34;/&gt;&lt;/p&gt;
&lt;p&gt;The above generates the following InfluxDB &lt;code&gt;SELECT&lt;/code&gt; clause:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT derivative(mean(&amp;#34;value&amp;#34;), 10s) /10 AS &amp;#34;REQ/s&amp;#34; FROM ....&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;select-multiple-fields&#34;&gt;Select multiple fields&lt;/h4&gt;
&lt;p&gt;Use the plus button and select Field &amp;gt; field to add another SELECT clause. You can also
specify an asterix &lt;code&gt;*&lt;/code&gt; to select all fields.&lt;/p&gt;
&lt;h3 id=&#34;group-by&#34;&gt;Group By&lt;/h3&gt;
&lt;p&gt;To group by a tag, click the plus icon at the end of the GROUP BY row. Pick a tag from the dropdown that appears.
You can remove the &amp;ldquo;Group By&amp;rdquo; by clicking on the &lt;code&gt;tag&lt;/code&gt; and then click on the x icon.&lt;/p&gt;
&lt;h3 id=&#34;text-editor-mode-raw&#34;&gt;Text Editor Mode (RAW)&lt;/h3&gt;
&lt;p&gt;You can switch to raw query mode by clicking hamburger icon and then &lt;code&gt;Switch editor mode&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you use Raw Query be sure your query at minimum have &lt;code&gt;WHERE $timeFilter&lt;/code&gt;.
Also, always have a group by time and an aggregation function, otherwise InfluxDB can easily return hundreds of thousands of data points that will hang the browser.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3 id=&#34;alias-patterns&#34;&gt;Alias patterns&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;$m = replaced with measurement name&lt;/li&gt;
&lt;li&gt;$measurement = replaced with measurement name&lt;/li&gt;
&lt;li&gt;$1 - $9 = replaced with part of measurement name (if you separate your measurement name with dots)&lt;/li&gt;
&lt;li&gt;$col = replaced with column name&lt;/li&gt;
&lt;li&gt;$tag_exampletag = replaced with the value of the &lt;code&gt;exampletag&lt;/code&gt; tag. The syntax is &lt;code&gt;$tag*yourTagName&lt;/code&gt;(must start with&lt;code&gt;$tag*&lt;/code&gt;). To use your tag as an alias in the ALIAS BY field then the tag must be used to group by in the query.&lt;/li&gt;
&lt;li&gt;You can also use [[tag_hostname]] pattern replacement syntax. For example, in the ALIAS BY field using this text &lt;code&gt;Host: [[tag_hostname]]&lt;/code&gt; would substitute in the &lt;code&gt;hostname&lt;/code&gt; tag value for each legend value and an example legend value would be: &lt;code&gt;Host: server1&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;querying-logs&#34;&gt;Querying logs&lt;/h2&gt;
&lt;p&gt;Querying and displaying log data from InfluxDB is available in &lt;a href=&#34;../../explore/&#34;&gt;Explore&lt;/a&gt;, and in the &lt;a href=&#34;../../visualizations/logs-panel/&#34;&gt;logs panel&lt;/a&gt; in dashboards.
Select the InfluxDB data source, and then enter a query to display your logs.&lt;/p&gt;
&lt;h3 id=&#34;log-queries&#34;&gt;Log queries&lt;/h3&gt;
&lt;p&gt;The Logs Explorer (the &lt;code&gt;Measurements/Fields&lt;/code&gt; button) next to the query field shows a list of measurements and fields. Choose the desired measurement that contains your log data and then choose which field Explore should use to display the log message.&lt;/p&gt;
&lt;p&gt;Once the result is returned, the log panel shows a list of log rows and a bar chart where the x-axis shows the time and the y-axis shows the frequency/count.&lt;/p&gt;
&lt;h3 id=&#34;filter-search&#34;&gt;Filter search&lt;/h3&gt;
&lt;p&gt;To add a filter, click the plus icon to the right of the &lt;code&gt;Measurements/Fields&lt;/code&gt; button or a condition. You can remove tag filters by clicking on the first select and choosing &lt;code&gt;--remove filter--&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;../../dashboards/annotations/&#34;&gt;Annotations&lt;/a&gt; allows you to overlay rich event information on top of graphs. Add annotation queries using the Annotations view in the Dashboard menu.&lt;/p&gt;
&lt;p&gt;An example query:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT title, description from events WHERE $timeFilter ORDER BY time ASC&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For InfluxDB, you need to enter a query like the one in the example above. The &lt;code&gt;where $timeFilter&lt;/code&gt; component is required. If you only select one column, then you do not need to enter anything in the column mapping fields. The &lt;strong&gt;Tags&lt;/strong&gt; field can be a comma-separated string.&lt;/p&gt;
]]></content><description>&lt;h1 id="influxdb-data-source">InfluxDB data source&lt;/h1>
&lt;div data-shared="influxdb/intro.md">
&lt;p>&lt;a href="https://www.influxdata.com/products/" target="_blank" rel="noopener noreferrer">InfluxDB&lt;/a> is an open-source time series database (TSDB) developed by &lt;a href="https://www.influxdata.com/" target="_blank" rel="noopener noreferrer">InfluxData&lt;/a>. It is optimized for fast, high-availability storage and retrieval of time series data in fields such as operations monitoring, application metrics, IoT sensor data, and real-time analytics.&lt;/p></description></item><item><title>Jaeger</title><link>https://grafana.com/docs/grafana/v8.4/datasources/jaeger/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/jaeger/</guid><content><![CDATA[&lt;h1 id=&#34;jaeger-data-source&#34;&gt;Jaeger data source&lt;/h1&gt;
&lt;p&gt;Grafana ships with built-in support for Jaeger, which provides open source, end-to-end distributed tracing.
Just add it as a data source and you are ready to query your traces in &lt;a href=&#34;../../explore/&#34;&gt;Explore&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;add-data-source&#34;&gt;Add data source&lt;/h2&gt;
&lt;p&gt;To access Jaeger settings, click the &lt;strong&gt;Configuration&lt;/strong&gt; (gear) icon, then click &lt;strong&gt;Data Sources&lt;/strong&gt; &amp;gt; &lt;strong&gt;Jaeger&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;Name&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;Name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The data source name in panels, queries, and Explore.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Default&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The pre-selected data source for a new panel.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;URL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The URL of the Jaeger instance. For example, &lt;code&gt;http://localhost:16686&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Basic Auth&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enable basic authentication for the Jaeger data source.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;User&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Specify a user name for basic authentication.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Password&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Specify a password for basic authentication.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;trace-to-logs&#34;&gt;Trace to logs&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This feature is available in Grafana 7.4&#43;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This is a configuration for the &lt;a href=&#34;../../explore/trace-integration/&#34;&gt;trace to logs feature&lt;/a&gt;. Select target data source (at this moment limited to Loki data sources) and select which tags will be used in the logs query.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Data source -&lt;/strong&gt; Target data source.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tags -&lt;/strong&gt; The tags that will be used in the Loki query. Default is &lt;code&gt;&#39;cluster&#39;, &#39;hostname&#39;, &#39;namespace&#39;, &#39;pod&#39;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Map tag names -&lt;/strong&gt; When enabled, allows configuring how Jaeger tag names map to Loki label names. For example, map &lt;code&gt;service.name&lt;/code&gt; to &lt;code&gt;service&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Span start time shift -&lt;/strong&gt; Shift in the start time for the Loki query based on the span start time. In order to extend to the past, you need to use a negative value. Use time interval units like 5s, 1m, 3h. The default is 0.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Span end time shift -&lt;/strong&gt; Shift in the end time for the Loki query based on the span end time. Time units can be used here, for example, 5s, 1m, 3h. The default is 0.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Filter by Trace ID -&lt;/strong&gt; Toggle to append the trace ID to the Loki query.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Filter by Span ID -&lt;/strong&gt; Toggle to append the span ID to the Loki query.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/explore/trace-to-logs-settings-8-2.png&#34;
  alt=&#34;Trace to logs settings&#34;/&gt;&lt;/p&gt;
&lt;h3 id=&#34;node-graph&#34;&gt;Node Graph&lt;/h3&gt;
&lt;p&gt;This is a configuration for the beta Node Graph visualization. The Node Graph is shown after the trace view is loaded and is disabled by default.&lt;/p&gt;
&lt;p&gt;&amp;ndash; &lt;strong&gt;Enable Node Graph -&lt;/strong&gt; Enables the Node Graph visualization.&lt;/p&gt;
&lt;h2 id=&#34;query-traces&#34;&gt;Query traces&lt;/h2&gt;
&lt;p&gt;You can query and display traces from Jaeger via &lt;a href=&#34;../../explore/&#34;&gt;Explore&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: 1857px;&#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/explore/jaeger-search-form.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/explore/jaeger-search-form.png&#34;data-srcset=&#34;/static/img/docs/explore/jaeger-search-form.png?w=320 320w, /static/img/docs/explore/jaeger-search-form.png?w=550 550w, /static/img/docs/explore/jaeger-search-form.png?w=750 750w, /static/img/docs/explore/jaeger-search-form.png?w=900 900w, /static/img/docs/explore/jaeger-search-form.png?w=1040 1040w, /static/img/docs/explore/jaeger-search-form.png?w=1240 1240w, /static/img/docs/explore/jaeger-search-form.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the Jaeger query editor&#34;width=&#34;1857&#34;height=&#34;733&#34;title=&#34;Screenshot of the Jaeger query editor&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/explore/jaeger-search-form.png&#34;
            alt=&#34;Screenshot of the Jaeger query editor&#34;width=&#34;1857&#34;height=&#34;733&#34;title=&#34;Screenshot of the Jaeger query editor&#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;Screenshot of the Jaeger query editor&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;You can query by trace ID or use the search form to find traces. To query by trace ID, select the TraceID from the Query type selector and insert the ID into the text input.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 1855px;&#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/explore/jaeger-trace-id.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/explore/jaeger-trace-id.png&#34;data-srcset=&#34;/static/img/docs/explore/jaeger-trace-id.png?w=320 320w, /static/img/docs/explore/jaeger-trace-id.png?w=550 550w, /static/img/docs/explore/jaeger-trace-id.png?w=750 750w, /static/img/docs/explore/jaeger-trace-id.png?w=900 900w, /static/img/docs/explore/jaeger-trace-id.png?w=1040 1040w, /static/img/docs/explore/jaeger-trace-id.png?w=1240 1240w, /static/img/docs/explore/jaeger-trace-id.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the Jaeger query editor with trace ID selected&#34;width=&#34;1855&#34;height=&#34;778&#34;title=&#34;Screenshot of the Jaeger query editor with trace ID selected&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/explore/jaeger-trace-id.png&#34;
            alt=&#34;Screenshot of the Jaeger query editor with trace ID selected&#34;width=&#34;1855&#34;height=&#34;778&#34;title=&#34;Screenshot of the Jaeger query editor with trace ID selected&#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;Screenshot of the Jaeger query editor with trace ID selected&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;To perform a search, set the query type selector to Search, then use the following fields to find traces:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Service - Returns a list of services.&lt;/li&gt;
&lt;li&gt;Operation - Field gets populated once you select a service. It then lists the operations related to the selected service. Select &lt;code&gt;All&lt;/code&gt; option to query all operations.&lt;/li&gt;
&lt;li&gt;Tags - Use values in the &lt;a href=&#34;https://brandur.org/logfmt&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;logfmt&lt;/a&gt; format. For example &lt;code&gt;error=true db.statement=&amp;quot;select * from User&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Min Duration - Filter all traces with a duration higher than the set value. Possible values are &lt;code&gt;1.2s, 100ms, 500us&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Max Duration - Filter all traces with a duration lower than the set value. Possible values are &lt;code&gt;1.2s, 100ms, 500us&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Limit - Limits the number of traces returned.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;upload-json-trace-file&#34;&gt;Upload JSON trace file&lt;/h2&gt;
&lt;p&gt;You can upload a JSON file that contains a single trace to visualize it. If the file has multiple traces then the first trace is used for visualization.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 1849px;&#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/explore/jaeger-upload-json.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/explore/jaeger-upload-json.png&#34;data-srcset=&#34;/static/img/docs/explore/jaeger-upload-json.png?w=320 320w, /static/img/docs/explore/jaeger-upload-json.png?w=550 550w, /static/img/docs/explore/jaeger-upload-json.png?w=750 750w, /static/img/docs/explore/jaeger-upload-json.png?w=900 900w, /static/img/docs/explore/jaeger-upload-json.png?w=1040 1040w, /static/img/docs/explore/jaeger-upload-json.png?w=1240 1240w, /static/img/docs/explore/jaeger-upload-json.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the Jaeger data source in explore with upload selected&#34;width=&#34;1849&#34;height=&#34;548&#34;title=&#34;Screenshot of the Jaeger data source in explore with upload selected&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/explore/jaeger-upload-json.png&#34;
            alt=&#34;Screenshot of the Jaeger data source in explore with upload selected&#34;width=&#34;1849&#34;height=&#34;548&#34;title=&#34;Screenshot of the Jaeger data source in explore with upload selected&#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;Screenshot of the Jaeger data source in explore with upload selected&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Here is an example JSON:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
  &amp;#34;data&amp;#34;: [
    {
      &amp;#34;traceID&amp;#34;: &amp;#34;2ee9739529395e31&amp;#34;,
      &amp;#34;spans&amp;#34;: [
        {
          &amp;#34;traceID&amp;#34;: &amp;#34;2ee9739529395e31&amp;#34;,
          &amp;#34;spanID&amp;#34;: &amp;#34;2ee9739529395e31&amp;#34;,
          &amp;#34;flags&amp;#34;: 1,
          &amp;#34;operationName&amp;#34;: &amp;#34;CAS&amp;#34;,
          &amp;#34;references&amp;#34;: [],
          &amp;#34;startTime&amp;#34;: 1616095319593196,
          &amp;#34;duration&amp;#34;: 1004,
          &amp;#34;tags&amp;#34;: [
            {
              &amp;#34;key&amp;#34;: &amp;#34;sampler.type&amp;#34;,
              &amp;#34;type&amp;#34;: &amp;#34;string&amp;#34;,
              &amp;#34;value&amp;#34;: &amp;#34;const&amp;#34;
            }
          ],
          &amp;#34;logs&amp;#34;: [],
          &amp;#34;processID&amp;#34;: &amp;#34;p1&amp;#34;,
          &amp;#34;warnings&amp;#34;: null
        }
      ],
      &amp;#34;processes&amp;#34;: {
        &amp;#34;p1&amp;#34;: {
          &amp;#34;serviceName&amp;#34;: &amp;#34;loki-all&amp;#34;,
          &amp;#34;tags&amp;#34;: [
            {
              &amp;#34;key&amp;#34;: &amp;#34;jaeger.version&amp;#34;,
              &amp;#34;type&amp;#34;: &amp;#34;string&amp;#34;,
              &amp;#34;value&amp;#34;: &amp;#34;Go-2.25.0&amp;#34;
            }
          ]
        }
      },
      &amp;#34;warnings&amp;#34;: null
    }
  ],
  &amp;#34;total&amp;#34;: 0,
  &amp;#34;limit&amp;#34;: 0,
  &amp;#34;offset&amp;#34;: 0,
  &amp;#34;errors&amp;#34;: null
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;linking-trace-id-from-logs&#34;&gt;Linking Trace ID from logs&lt;/h2&gt;
&lt;p&gt;You can link to Jaeger trace from logs in Loki by configuring a derived field with internal link. See the &lt;a href=&#34;../loki/#derived-fields&#34;&gt;Derived fields&lt;/a&gt; section in the &lt;a href=&#34;../loki/&#34;&gt;Loki data source&lt;/a&gt; documentation for details.&lt;/p&gt;
&lt;h2 id=&#34;configure-the-data-source-with-provisioning&#34;&gt;Configure the data source with provisioning&lt;/h2&gt;
&lt;p&gt;You can set up the data source via configuration files with Grafana&amp;rsquo;s provisioning system. Refer to &lt;a href=&#34;../../administration/provisioning/#datasources&#34;&gt;provisioning docs page&lt;/a&gt; for more information on configuring various settings.&lt;/p&gt;
&lt;p&gt;Here is an example with basic auth and trace-to-logs field.&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: Jaeger
    type: jaeger
    uid: jaeger-spectra
    access: proxy
    url: http://localhost:16686/
    basicAuth: true
    basicAuthUser: my_user
    editable: true
    isDefault: false
    jsonData:
      tracesToLogs:
        # Field with internal link pointing to a Loki data source in Grafana.
        # datasourceUid value must match the `datasourceUid` value of the Loki data source.
        datasourceUid: &amp;#39;loki&amp;#39;
        tags: [&amp;#39;job&amp;#39;, &amp;#39;instance&amp;#39;, &amp;#39;pod&amp;#39;, &amp;#39;namespace&amp;#39;]
        mappedTags: [{ key: &amp;#39;service.name&amp;#39;, value: &amp;#39;service&amp;#39; }]
        mapTagNamesEnabled: false
        spanStartTimeShift: &amp;#39;1h&amp;#39;
        spanEndTimeShift: &amp;#39;1h&amp;#39;
        filterByTraceID: false
        filterBySpanID: false
        lokiSearch: true
    secureJsonData:
      basicAuthPassword: my_password&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="jaeger-data-source">Jaeger data source&lt;/h1>
&lt;p>Grafana ships with built-in support for Jaeger, which provides open source, end-to-end distributed tracing.
Just add it as a data source and you are ready to query your traces in &lt;a href="../../explore/">Explore&lt;/a>.&lt;/p></description></item><item><title>Loki</title><link>https://grafana.com/docs/grafana/v8.4/datasources/loki/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/loki/</guid><content><![CDATA[&lt;h1 id=&#34;using-loki-in-grafana&#34;&gt;Using Loki in Grafana&lt;/h1&gt;
&lt;p&gt;Grafana ships with built-in support for Loki, an open source log aggregation system by Grafana Labs. This topic explains options, variables, querying, and other options specific to this data source.&lt;/p&gt;
&lt;p&gt;Add it as a data source and you are ready to build dashboards or query your log data in &lt;a href=&#34;../../explore/&#34;&gt;Explore&lt;/a&gt;. Refer to &lt;a href=&#34;../add-a-data-source/&#34;&gt;Add a data source&lt;/a&gt; for instructions on how to add a data source to Grafana. Only users with the organization admin role can add data sources.&lt;/p&gt;
&lt;h2 id=&#34;hosted-loki&#34;&gt;Hosted Loki&lt;/h2&gt;
&lt;p&gt;You can run Loki on your own hardware or use &lt;a href=&#34;/products/cloud/features/#cloud-logs&#34;&gt;Grafana Cloud&lt;/a&gt;. The free forever plan includes Grafana, 50 GB of Loki logs, 10K Prometheus series, and more. &lt;a href=&#34;/auth/sign-up/create-user?pg=docs-grafana-loki&amp;amp;plcmt=in-text&#34;&gt;Create a free account to get started&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;loki-settings&#34;&gt;Loki settings&lt;/h2&gt;
&lt;p&gt;To access Loki settings, click the &lt;strong&gt;Configuration&lt;/strong&gt; (gear) icon, then click &lt;strong&gt;Data Sources&lt;/strong&gt;, and then click the Loki data source.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The data source name. This is how you refer to the data source in panels, queries, and Explore.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Default&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Default data source that is pre-selected for new panels.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;URL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;URL of the Loki instance, e.g., &lt;code&gt;http://localhost:3100&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Allowed cookies&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Grafana Proxy deletes forwarded cookies by default. Specify cookies by name that should be forwarded to the data source.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Maximum lines&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Upper limit for the number of log lines returned by Loki (default is 1000). Lower this limit if your browser is sluggish when displaying logs in Explore.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; To troubleshoot configuration and other issues, check the log file located at /var/log/grafana/grafana.log on Unix systems or in &amp;lt;grafana_install_dir&amp;gt;/data/log on other platforms and manual installations.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3 id=&#34;derived-fields&#34;&gt;Derived fields&lt;/h3&gt;
&lt;p&gt;The Derived Fields configuration allows you to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add fields parsed from the log message.&lt;/li&gt;
&lt;li&gt;Add a link that uses the value of the field.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, you can use this functionality to link to your tracing backend directly from your logs, or link to a user profile page if a userId is present in the log line. These links appear in the &lt;a href=&#34;../../explore/logs-integration/#labels-and-detected-fields&#34;&gt;log details&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Each derived field consists of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Name -&lt;/strong&gt; Shown in the log details as a label.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Regex -&lt;/strong&gt; A Regex pattern that runs on the log message and captures part of it as the value of the new field. Can only contain a single capture group.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;URL/query -&lt;/strong&gt; If the link is external, then enter the full link URL. If the link is internal link, then this input serves as query for the target data source. In both cases, you can interpolate the value from the field with &lt;code&gt;${__value.raw}&lt;/code&gt; macro.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;URL Label -&lt;/strong&gt; (Optional) Set a custom display label for the link. The link label defaults to the full external URL or name of the linked internal data source and is overridden by this setting.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internal link -&lt;/strong&gt; Select if the link is internal or external. In case of internal link, a data source selector allows you to select the target data source. Only tracing data sources are supported.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can use a debug section to see what your fields extract and how the URL is interpolated. Click &lt;strong&gt;Show example log message&lt;/strong&gt; to show the text area where you can enter a log message.
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 800px;&#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/v75/loki_derived_fields_settings.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/v75/loki_derived_fields_settings.png&#34;data-srcset=&#34;/static/img/docs/v75/loki_derived_fields_settings.png?w=320 320w, /static/img/docs/v75/loki_derived_fields_settings.png?w=550 550w, /static/img/docs/v75/loki_derived_fields_settings.png?w=750 750w, /static/img/docs/v75/loki_derived_fields_settings.png?w=900 900w, /static/img/docs/v75/loki_derived_fields_settings.png?w=1040 1040w, /static/img/docs/v75/loki_derived_fields_settings.png?w=1240 1240w, /static/img/docs/v75/loki_derived_fields_settings.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the derived fields debugging&#34;width=&#34;2060&#34;height=&#34;866&#34;title=&#34;Screenshot of the derived fields debugging&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v75/loki_derived_fields_settings.png&#34;
            alt=&#34;Screenshot of the derived fields debugging&#34;width=&#34;2060&#34;height=&#34;866&#34;title=&#34;Screenshot of the derived fields debugging&#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;Screenshot of the derived fields debugging&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The new field with the link shown in log details:
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 800px;&#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/explore/detected-fields-link-7-4.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/explore/detected-fields-link-7-4.png&#34;data-srcset=&#34;/static/img/docs/explore/detected-fields-link-7-4.png?w=320 320w, /static/img/docs/explore/detected-fields-link-7-4.png?w=550 550w, /static/img/docs/explore/detected-fields-link-7-4.png?w=750 750w, /static/img/docs/explore/detected-fields-link-7-4.png?w=900 900w, /static/img/docs/explore/detected-fields-link-7-4.png?w=1040 1040w, /static/img/docs/explore/detected-fields-link-7-4.png?w=1240 1240w, /static/img/docs/explore/detected-fields-link-7-4.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Detected fields link in Explore&#34;width=&#34;2024&#34;height=&#34;776&#34;title=&#34;Detected fields link in Explore&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/explore/detected-fields-link-7-4.png&#34;
            alt=&#34;Detected fields link in Explore&#34;width=&#34;2024&#34;height=&#34;776&#34;title=&#34;Detected fields link in Explore&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Detected fields link in Explore&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&#34;loki-query-editor&#34;&gt;Loki query editor&lt;/h2&gt;
&lt;p&gt;You can use the Loki query editor to create log and metric queries.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Query expression&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Loki query expression, refer to the &lt;a href=&#34;/docs/loki/latest/logql/&#34;&gt;LogQL documentation&lt;/a&gt; for more information.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Query type&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Choose the type of query to run. The instant type queries against a single point in time. We are using &amp;ldquo;To&amp;rdquo; time from the time range. The range type queries over the selected range of time.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Line limit&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Upper limit for number of log lines returned by query. The default is the Maximum lines limit set in Loki settings.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Legend&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Available only in Dashboard. Controls the name of the time series, using name or pattern. For example &lt;code&gt;{{hostname}}&lt;/code&gt; is replaced with the label value for the label &lt;code&gt;hostname&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;log-browser&#34;&gt;Log browser&lt;/h3&gt;
&lt;p&gt;With Loki log browser you can easily navigate through your list of labels and values and construct the query of your choice. Log browser has multi-step selection:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Choose the labels you would like to consider for your search.&lt;/li&gt;
&lt;li&gt;Pick the values for selected labels. Log browser supports facetting and therefore it shows you only possible label combinations.&lt;/li&gt;
&lt;li&gt;Choose the type of query - logs query or rate metrics query. Additionally, you can also validate selector.&lt;/li&gt;
&lt;/ol&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 800px;&#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/v75/loki_log_browser.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/v75/loki_log_browser.png&#34;data-srcset=&#34;/static/img/docs/v75/loki_log_browser.png?w=320 320w, /static/img/docs/v75/loki_log_browser.png?w=550 550w, /static/img/docs/v75/loki_log_browser.png?w=750 750w, /static/img/docs/v75/loki_log_browser.png?w=900 900w, /static/img/docs/v75/loki_log_browser.png?w=1040 1040w, /static/img/docs/v75/loki_log_browser.png?w=1240 1240w, /static/img/docs/v75/loki_log_browser.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the log browser for Loki&#34;width=&#34;1824&#34;height=&#34;1534&#34;title=&#34;Screenshot of the log browser for Loki&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v75/loki_log_browser.png&#34;
            alt=&#34;Screenshot of the log browser for Loki&#34;width=&#34;1824&#34;height=&#34;1534&#34;title=&#34;Screenshot of the log browser for Loki&#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;Screenshot of the log browser for Loki&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h2 id=&#34;querying-with-loki&#34;&gt;Querying with Loki&lt;/h2&gt;
&lt;p&gt;There are two types of LogQL queries:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Log queries - Return the contents of log lines.&lt;/li&gt;
&lt;li&gt;Metric queries - Extend log queries and calculate sample values based on the content of logs from a log query.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;log-queries&#34;&gt;Log queries&lt;/h3&gt;
&lt;p&gt;Querying and displaying log data from Loki is available via &lt;a href=&#34;../../explore/&#34;&gt;Explore&lt;/a&gt;, and with the &lt;a href=&#34;../../visualizations/logs-panel/&#34;&gt;logs panel&lt;/a&gt; in dashboards. Select the Loki data source, and then enter a &lt;a href=&#34;/docs/loki/latest/logql/#log-queries&#34;&gt;LogQL&lt;/a&gt; query to display your logs.&lt;/p&gt;
&lt;p&gt;A log query consists of two parts: log stream selector, and a log pipeline. For performance reasons begin by choosing a log stream by selecting a log label.&lt;/p&gt;
&lt;h3 id=&#34;log-context&#34;&gt;Log context&lt;/h3&gt;
&lt;p&gt;When using a search expression as detailed above, you can retrieve the context surrounding your filtered results.
By clicking the &lt;code&gt;Show Context&lt;/code&gt; link on the filtered rows, you&amp;rsquo;ll be able to investigate the log messages that came before and after the
log message you&amp;rsquo;re interested in.&lt;/p&gt;
&lt;h3 id=&#34;live-tailing&#34;&gt;Live tailing&lt;/h3&gt;
&lt;p&gt;Loki supports Live tailing which displays logs in real-time. This feature is supported in &lt;a href=&#34;../../explore/#loki-specific-features&#34;&gt;Explore&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that Live Tailing relies on two Websocket connections: one between the browser and the Grafana server, and another between the Grafana server and the Loki server. If you run any reverse proxies, please configure them accordingly. The following example for Apache2 can be used for proxying between the browser and the Grafana server:&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;ProxyPassMatch &amp;#34;^/(api/datasources/proxy/\d&amp;#43;/loki/api/v1/tail)&amp;#34; &amp;#34;ws://127.0.0.1:3000/$1&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The following example shows basic NGINX proxy configuration. It assumes that the Grafana server is available at &lt;code&gt;http://localhost:3000/&lt;/code&gt;, Loki server is running locally without proxy, and your external site uses HTTPS. If you also host Loki behind NGINX proxy, then you might want to repeat the following configuration for Loki as well.&lt;/p&gt;
&lt;p&gt;In the &lt;code&gt;http&lt;/code&gt; section of NGINX configuration, add the following map definition:&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;  map $http_upgrade $connection_upgrade {
    default upgrade;
    &amp;#39;&amp;#39; close;
  }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In your &lt;code&gt;server&lt;/code&gt; section, add the following configuration:&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;  location ~ /(api/datasources/proxy/\d&amp;#43;/loki/api/v1/tail) {
      proxy_pass          http://localhost:3000$request_uri;
      proxy_set_header    Host              $host;
      proxy_set_header    X-Real-IP         $remote_addr;
      proxy_set_header    X-Forwarded-for   $proxy_add_x_forwarded_for;
      proxy_set_header    X-Forwarded-Proto &amp;#34;https&amp;#34;;
      proxy_set_header    Connection        $connection_upgrade;
      proxy_set_header    Upgrade           $http_upgrade;
  }

  location / {
      proxy_pass          http://localhost:3000/;
      proxy_set_header    Host              $host;
      proxy_set_header    X-Real-IP         $remote_addr;
      proxy_set_header    X-Forwarded-for   $proxy_add_x_forwarded_for;
      proxy_set_header    X-Forwarded-Proto &amp;#34;https&amp;#34;;
  }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This feature is only available in Grafana v6.3&#43;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;metric-queries&#34;&gt;Metric queries&lt;/h2&gt;
&lt;p&gt;LogQL supports wrapping a log query with functions that allow for creating metrics out of the logs. See &lt;a href=&#34;/docs/loki/latest/logql/#metric-queries&#34;&gt;LogQL&lt;/a&gt; documentation on how to create and use metrics queries.&lt;/p&gt;
&lt;h2 id=&#34;templating&#34;&gt;Templating&lt;/h2&gt;
&lt;p&gt;Instead of hard-coding things like server, application and sensor name in your metric queries, you can use variables in their place. Variables are shown as drop-down select boxes at the top of the dashboard. These drop-down boxes make it easy to change the data being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Check out the &lt;a href=&#34;../../variables/&#34;&gt;Templating&lt;/a&gt; documentation for an introduction to the templating feature and the different types of template variables.&lt;/p&gt;
&lt;h2 id=&#34;query-variable&#34;&gt;Query variable&lt;/h2&gt;
&lt;p&gt;Variable of the type &lt;em&gt;Query&lt;/em&gt; allows you to query Loki for a list labels or label values. The Loki data source plugin
provides the following functions you can use in the &lt;code&gt;Query&lt;/code&gt; input field.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;label_names()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of label names.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;label_values(label)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of label values for the &lt;code&gt;label&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;label_values(log stream selector, label)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of label values for the &lt;code&gt;label&lt;/code&gt; in the specified &lt;code&gt;log stream selector&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;ad-hoc-filters-variable&#34;&gt;Ad hoc filters variable&lt;/h3&gt;
&lt;p&gt;Loki supports the special ad hoc filters variable type. It allows you to specify any number of label/value filters on the fly. These filters are automatically applied to all your Loki queries.&lt;/p&gt;
&lt;h3 id=&#34;using-interval-and-range-variables&#34;&gt;Using interval and range variables&lt;/h3&gt;
&lt;p&gt;You can use some global built-in variables in query variables; &lt;code&gt;$__interval&lt;/code&gt;, &lt;code&gt;$__interval_ms&lt;/code&gt;, &lt;code&gt;$__range&lt;/code&gt;, &lt;code&gt;$__range_s&lt;/code&gt; and &lt;code&gt;$__range_ms&lt;/code&gt;. For more information, refer to &lt;a href=&#34;../../variables/variable-types/global-variables/&#34;&gt;Global built-in variables&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;p&gt;You can use any non-metric Loki query as a source for &lt;a href=&#34;../../dashboards/annotations/&#34;&gt;annotations&lt;/a&gt;. Log content will be used as annotation text and your log stream labels as tags, so there is no need for additional mapping.&lt;/p&gt;
&lt;h2 id=&#34;configure-the-data-source-with-provisioning&#34;&gt;Configure the data source with provisioning&lt;/h2&gt;
&lt;p&gt;You can set up the data source via config files with Grafana&amp;rsquo;s provisioning system.
You can read more about how it works and all the settings you can set for data sources on the &lt;a href=&#34;../../administration/provisioning/#datasources&#34;&gt;provisioning docs page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is an example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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: Loki
    type: loki
    access: proxy
    url: http://localhost:3100
    jsonData:
      maxLines: 1000&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here&amp;rsquo;s another with basic auth and derived field. Keep in mind that &lt;code&gt;$&lt;/code&gt; character needs to be escaped in YAML values as it is used to interpolate environment variables:&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: Loki
    type: loki
    access: proxy
    url: http://localhost:3100
    basicAuth: true
    basicAuthUser: my_user
    basicAuthPassword: test_password
    jsonData:
      maxLines: 1000
      derivedFields:
        # Field with internal link pointing to data source in Grafana.
        # Right now, Grafana supports only Jaeger and Zipkin data sources as link targets.
        # datasourceUid value can be anything, but it should be unique across all defined data source uids.
        - datasourceUid: my_jaeger_uid
          matcherRegex: &amp;#34;traceID=(\\w&amp;#43;)&amp;#34;
          name: TraceID
          # url will be interpreted as query for the datasource
          url: &amp;#39;$${__value.raw}&amp;#39;

        # Field with external link.
        - matcherRegex: &amp;#34;traceID=(\\w&amp;#43;)&amp;#34;
          name: TraceID
          url: &amp;#39;http://localhost:16686/trace/$${__value.raw}&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here&amp;rsquo;s an example of a Jaeger data source corresponding to the above example. Note that the Jaeger &lt;code&gt;uid&lt;/code&gt; value does match the Loki &lt;code&gt;datasourceUid&lt;/code&gt; value.&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;datasources:
    - name: Jaeger
      type: jaeger
      url: http://jaeger-tracing-query:16686/
      access: proxy
      # UID should match the datasourceUid in dervidedFields.
      uid: my_jaeger_uid&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="using-loki-in-grafana">Using Loki in Grafana&lt;/h1>
&lt;p>Grafana ships with built-in support for Loki, an open source log aggregation system by Grafana Labs. This topic explains options, variables, querying, and other options specific to this data source.&lt;/p></description></item><item><title>Microsoft SQL Server</title><link>https://grafana.com/docs/grafana/v8.4/datasources/mssql/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/mssql/</guid><content><![CDATA[&lt;h1 id=&#34;using-microsoft-sql-server-in-grafana&#34;&gt;Using Microsoft SQL Server in Grafana&lt;/h1&gt;
&lt;p&gt;Grafana ships with a built-in Microsoft SQL Server (MS SQL) data source plugin that allows you to query and visualize data from any Microsoft SQL Server 2005 or newer, including Microsoft Azure SQL Database. This topic explains options, variables, querying, and other options specific to the MS SQL data source. Refer to &lt;a href=&#34;../add-a-data-source/&#34;&gt;Add a data source&lt;/a&gt; for instructions on how to add a data source to Grafana. Only users with the organization admin role can add data sources.&lt;/p&gt;
&lt;h2 id=&#34;data-source-options&#34;&gt;Data source options&lt;/h2&gt;
&lt;p&gt;To access data source settings, hover your mouse over the &lt;strong&gt;Configuration&lt;/strong&gt; (gear) icon, then click &lt;strong&gt;Data Sources&lt;/strong&gt;, and then click the data source.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The data source name. This is how you refer to the data source in panels and queries.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Default&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Default data source means that it will be pre-selected for new panels.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Host&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The IP address/hostname and optional port of your MS SQL instance. If you omit the port, then the driver default is used (0). You can specify multiple connection properties such as ApplicationIntent using &amp;lsquo;;&amp;rsquo; character to separate each property.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Database&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Name of your MS SQL database.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Authentication&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Authentication mode. Either using SQL Server Authentication or Windows Authentication (single sign on for Windows users).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;User&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Database user&amp;rsquo;s login/username&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Password&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Database user&amp;rsquo;s password&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Encrypt&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;This option determines whether or to which extent a secure SSL TCP/IP connection will be negotiated with the server, default &lt;code&gt;false&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Max open&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The maximum number of open connections to the database, default &lt;code&gt;unlimited&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Max idle&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The maximum number of connections in the idle connection pool, default &lt;code&gt;2&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Max lifetime&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The maximum amount of time in seconds a connection may be reused, default &lt;code&gt;14400&lt;/code&gt;/4 hours.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;min-time-interval&#34;&gt;Min time interval&lt;/h3&gt;
&lt;p&gt;A lower limit for the &lt;a href=&#34;../../variables/variable-types/global-variables/#__interval&#34;&gt;$__interval&lt;/a&gt; and &lt;a href=&#34;../../variables/variable-types/global-variables/#__interval_ms&#34;&gt;$__interval_ms&lt;/a&gt; variables.
Recommended to be set to write frequency, for example &lt;code&gt;1m&lt;/code&gt; if your data is written every minute.
This option can also be overridden/configured in a dashboard panel under data source options. It&amp;rsquo;s important to note that this value &lt;strong&gt;needs&lt;/strong&gt; to be formatted as a
number followed by a valid time identifier, e.g. &lt;code&gt;1m&lt;/code&gt; (1 minute) or &lt;code&gt;30s&lt;/code&gt; (30 seconds). The following time identifiers are supported:&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;Identifier&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;y&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;year&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;M&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;month&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;w&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;week&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;d&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;day&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;h&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;hour&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;m&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;minute&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;s&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;second&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ms&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;millisecond&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;database-user-permissions&#34;&gt;Database user permissions&lt;/h3&gt;
&lt;p&gt;The database user you specify when you add the data source should only be granted SELECT permissions on
the specified database and tables you want to query. Grafana does not validate that the query is safe. The query
could include any SQL statement. For example, statements like &lt;code&gt;DELETE FROM user;&lt;/code&gt; and &lt;code&gt;DROP TABLE user;&lt;/code&gt; would be
executed. To protect against this we &lt;em&gt;highly&lt;/em&gt; recommend you create a specific MS SQL user with restricted permissions.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt; CREATE USER grafanareader WITH PASSWORD &amp;#39;password&amp;#39;
 GRANT SELECT ON dbo.YourTable3 TO grafanareader&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Make sure the user does not get any unwanted privileges from the public role.&lt;/p&gt;
&lt;h3 id=&#34;known-issues&#34;&gt;Known Issues&lt;/h3&gt;
&lt;p&gt;If you&amp;rsquo;re using an older version of Microsoft SQL Server like 2008 and 2008R2 you may need to disable encryption to be able to connect.
If possible, we recommend you to use the latest service pack available for optimal compatibility.&lt;/p&gt;
&lt;h2 id=&#34;query-editor&#34;&gt;Query Editor&lt;/h2&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 1060px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/static/img/docs/v51/mssql_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 &#34;
          data-src=&#34;/static/img/docs/v51/mssql_query_editor.png&#34;data-srcset=&#34;/static/img/docs/v51/mssql_query_editor.png?w=320 320w, /static/img/docs/v51/mssql_query_editor.png?w=550 550w, /static/img/docs/v51/mssql_query_editor.png?w=750 750w, /static/img/docs/v51/mssql_query_editor.png?w=900 900w, /static/img/docs/v51/mssql_query_editor.png?w=1040 1040w, /static/img/docs/v51/mssql_query_editor.png?w=1240 1240w, /static/img/docs/v51/mssql_query_editor.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;1060&#34;height=&#34;484&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v51/mssql_query_editor.png&#34;
            alt=&#34;&#34;width=&#34;1060&#34;height=&#34;484&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;You will find the MSSQL query editor in the metrics tab in Graph, Singlestat or Table panel&amp;rsquo;s edit mode. You enter edit mode by clicking the
panel title, then edit. The editor allows you to define a SQL query to select data to be visualized.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Select &lt;em&gt;Format as&lt;/em&gt; &lt;code&gt;Time series&lt;/code&gt; (for use in Graph or Singlestat panel&amp;rsquo;s among others) or &lt;code&gt;Table&lt;/code&gt; (for use in Table panel among others).&lt;/li&gt;
&lt;li&gt;This is the actual editor where you write your SQL queries.&lt;/li&gt;
&lt;li&gt;Show help section for MSSQL below the query editor.&lt;/li&gt;
&lt;li&gt;Show actual executed SQL query. Will be available first after a successful query has been executed.&lt;/li&gt;
&lt;li&gt;Add an additional query where an additional query editor will be displayed.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;clearfix&#34;&gt;&lt;/div&gt;
&lt;h2 id=&#34;macros&#34;&gt;Macros&lt;/h2&gt;
&lt;p&gt;To simplify syntax and to allow for dynamic parts, like date range filters, the query can contain macros.&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;Macro example&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__time(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by an expression to rename the column to &lt;em&gt;time&lt;/em&gt;. For example, &lt;em&gt;dateColumn as time&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeEpoch(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by an expression to convert a DATETIME column type to Unix timestamp and rename it to &lt;em&gt;time&lt;/em&gt;. &lt;br/&gt;For example, &lt;em&gt;DATEDIFF(second, &amp;lsquo;1970-01-01&amp;rsquo;, dateColumn) AS time&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeFilter(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by a time range filter using the specified column name. &lt;br/&gt;For example, &lt;em&gt;dateColumn BETWEEN &amp;lsquo;2017-04-21T05:01:17Z&amp;rsquo; AND &amp;lsquo;2017-04-21T05:06:17Z&amp;rsquo;&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeFrom()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the start of the currently active time selection. For example, &lt;em&gt;&amp;lsquo;2017-04-21T05:01:17Z&amp;rsquo;&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeTo()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the end of the currently active time selection. For example, &lt;em&gt;&amp;lsquo;2017-04-21T05:06:17Z&amp;rsquo;&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroup(dateColumn,&#39;5m&#39;[, fillvalue])&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by an expression usable in GROUP BY clause. Providing a &lt;em&gt;fillValue&lt;/em&gt; of &lt;em&gt;NULL&lt;/em&gt; or &lt;em&gt;floating value&lt;/em&gt; will automatically fill empty series in timerange with that value. &lt;br/&gt;For example, &lt;em&gt;CAST(ROUND(DATEDIFF(second, &amp;lsquo;1970-01-01&amp;rsquo;, time_column)/300.0, 0) as bigint)*300&lt;/em&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroup(dateColumn,&#39;5m&#39;, 0)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as above but with a fill parameter so missing points in that series will be added by grafana and 0 will be used as value.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroup(dateColumn,&#39;5m&#39;, NULL)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as above but NULL will be used as value for missing points.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroup(dateColumn,&#39;5m&#39;, previous)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as above but the previous value in that series will be used as fill value if no value has been seen yet NULL will be used (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroupAlias(dateColumn,&#39;5m&#39;)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced identical to $__timeGroup but with an added column alias (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochFilter(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by a time range filter using the specified column name with times represented as Unix timestamp. For example, &lt;em&gt;dateColumn &amp;gt; 1494410783 AND dateColumn &amp;lt; 1494497183&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochFrom()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the start of the currently active time selection as Unix timestamp. For example, &lt;em&gt;1494410783&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochTo()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the end of the currently active time selection as Unix timestamp. For example, &lt;em&gt;1494497183&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochNanoFilter(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by a time range filter using the specified column name with times represented as nanosecond timestamp. For example, &lt;em&gt;dateColumn &amp;gt; 1494410783152415214 AND dateColumn &amp;lt; 1494497183142514872&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochNanoFrom()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the start of the currently active time selection as nanosecond timestamp. For example, &lt;em&gt;1494410783152415214&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochNanoTo()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the end of the currently active time selection as nanosecond timestamp. For example, &lt;em&gt;1494497183142514872&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochGroup(dateColumn,&#39;5m&#39;, [fillmode])&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as $__timeGroup but for times stored as Unix timestamp (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochGroupAlias(dateColumn,&#39;5m&#39;, [fillmode])&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as above but also adds a column alias (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;We plan to add many more macros. If you have suggestions for what macros you would like to see, please &lt;a href=&#34;https://github.com/grafana/grafana&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;open an issue&lt;/a&gt; in our GitHub repo.&lt;/p&gt;
&lt;p&gt;The query editor has a link named &lt;code&gt;Generated SQL&lt;/code&gt; that shows up after a query has been executed, while in panel edit mode. Click on it and it will expand and show the raw interpolated SQL string that was executed.&lt;/p&gt;
&lt;h2 id=&#34;table-queries&#34;&gt;Table queries&lt;/h2&gt;
&lt;p&gt;If the &lt;code&gt;Format as&lt;/code&gt; query option is set to &lt;code&gt;Table&lt;/code&gt; then you can basically do any type of SQL query. The table panel will automatically show the results of whatever columns and rows your query returns.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example database table:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;CREATE TABLE [event] (
  time_sec bigint,
  description nvarchar(100),
  tags nvarchar(100),
)&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;CREATE TABLE [mssql_types] (
  c_bit bit, c_tinyint tinyint, c_smallint smallint, c_int int, c_bigint bigint, c_money money, c_smallmoney smallmoney, c_numeric numeric(10,5),
  c_real real, c_decimal decimal(10,2), c_float float,
  c_char char(10), c_varchar varchar(10), c_text text,
  c_nchar nchar(12), c_nvarchar nvarchar(12), c_ntext ntext,
  c_datetime datetime,  c_datetime2 datetime2, c_smalldatetime smalldatetime, c_date date, c_time time, c_datetimeoffset datetimeoffset
)

INSERT INTO [mssql_types]
SELECT
  1, 5, 20020, 980300, 1420070400, &amp;#39;$20000.15&amp;#39;, &amp;#39;£2.15&amp;#39;, 12345.12,
  1.11, 2.22, 3.33,
  &amp;#39;char10&amp;#39;, &amp;#39;varchar10&amp;#39;, &amp;#39;text&amp;#39;,
  N&amp;#39;☺nchar12☺&amp;#39;, N&amp;#39;☺nvarchar12☺&amp;#39;, N&amp;#39;☺text☺&amp;#39;,
  GETDATE(), CAST(GETDATE() AS DATETIME2), CAST(GETDATE() AS SMALLDATETIME), CAST(GETDATE() AS DATE), CAST(GETDATE() AS TIME), SWITCHOFFSET(CAST(GETDATE() AS DATETIMEOFFSET), &amp;#39;-07:00&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Query editor with example query:&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&#34;
        href=&#34;/static/img/docs/v51/mssql_table_query.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/static/img/docs/v51/mssql_table_query.png&#34;data-srcset=&#34;/static/img/docs/v51/mssql_table_query.png?w=320 320w, /static/img/docs/v51/mssql_table_query.png?w=550 550w, /static/img/docs/v51/mssql_table_query.png?w=750 750w, /static/img/docs/v51/mssql_table_query.png?w=900 900w, /static/img/docs/v51/mssql_table_query.png?w=1040 1040w, /static/img/docs/v51/mssql_table_query.png?w=1240 1240w, /static/img/docs/v51/mssql_table_query.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;559&#34;height=&#34;336&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v51/mssql_table_query.png&#34;
            alt=&#34;&#34;width=&#34;559&#34;height=&#34;336&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;The query:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT * FROM [mssql_types]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can control the name of the Table panel columns by using regular &lt;code&gt;AS&lt;/code&gt; SQL column selection syntax. Example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  c_bit as [column1], c_tinyint as [column2]
FROM
  [mssql_types]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The resulting table panel:&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 1489px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/static/img/docs/v51/mssql_table_result.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/static/img/docs/v51/mssql_table_result.png&#34;data-srcset=&#34;/static/img/docs/v51/mssql_table_result.png?w=320 320w, /static/img/docs/v51/mssql_table_result.png?w=550 550w, /static/img/docs/v51/mssql_table_result.png?w=750 750w, /static/img/docs/v51/mssql_table_result.png?w=900 900w, /static/img/docs/v51/mssql_table_result.png?w=1040 1040w, /static/img/docs/v51/mssql_table_result.png?w=1240 1240w, /static/img/docs/v51/mssql_table_result.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;2013&#34;height=&#34;167&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v51/mssql_table_result.png&#34;
            alt=&#34;&#34;width=&#34;2013&#34;height=&#34;167&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h2 id=&#34;time-series-queries&#34;&gt;Time series queries&lt;/h2&gt;
&lt;p&gt;If you set Format as to &lt;em&gt;Time series&lt;/em&gt;, then the query must have a column named time that returns either a SQL datetime or any numeric datatype representing Unix epoch in seconds. In addition, result sets of time series queries must be sorted by time for panels to properly visualize the result.&lt;/p&gt;
&lt;p&gt;A time series query result is returned in a &lt;a href=&#34;/developers/plugin-tools/introduction/data-frames#wide-format&#34;&gt;wide data frame format&lt;/a&gt;. Any column except time or of type string transforms into value fields in the data frame query result. Any string column transforms into field labels in the data frame query result.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;For backward compatibility, there&amp;rsquo;s an exception to the above rule for queries that return three columns including a string column named metric. Instead of transforming the metric column into field labels, it becomes the field name, and then the series name is formatted as the value of the metric column. See the example with the metric column below.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;You can optionally customize the default series name formatting using instructions in &lt;a href=&#34;../../panels/reference-standard-field-definitions/#display-name&#34;&gt;Reference: Standard field definitions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example with &lt;code&gt;metric&lt;/code&gt; column:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  $__timeGroup(time_date_time, &amp;#39;5m&amp;#39;) as time,
  min(&amp;#34;value_double&amp;#34;),
  &amp;#39;min&amp;#39; as metric
FROM test_data
WHERE $__timeFilter(time_date_time)
GROUP BY $__timeGroup(time_date_time, &amp;#39;5m&amp;#39;)
ORDER BY 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Data frame result:&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;text&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-text&#34;&gt;&amp;#43;---------------------&amp;#43;-----------------&amp;#43;
| Name: time          | Name: min       |
| Labels:             | Labels:         |
| Type: []time.Time   | Type: []float64 |
&amp;#43;---------------------&amp;#43;-----------------&amp;#43;
| 2020-01-02 03:05:00 | 3               |
| 2020-01-02 03:10:00 | 6               |
&amp;#43;---------------------&amp;#43;-----------------&amp;#43;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example using the fill parameter in the $__timeGroup macro to convert null values to be zero instead:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  $__timeGroup(createdAt, &amp;#39;5m&amp;#39;, 0) as time,
  sum(value) as value,
  hostname
FROM test_data
WHERE
  $__timeFilter(createdAt)
GROUP BY
  $__timeGroup(createdAt, &amp;#39;5m&amp;#39;, 0),
  hostname
ORDER BY 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Given the data frame result in the following example and using the graph panel, you will get two series named &lt;em&gt;value 10.0.1.1&lt;/em&gt; and &lt;em&gt;value 10.0.1.2&lt;/em&gt;. To render the series with a name of &lt;em&gt;10.0.1.1&lt;/em&gt; and &lt;em&gt;10.0.1.2&lt;/em&gt; , use a &lt;a href=&#34;../../panels/reference-standard-field-definitions/#display-name&#34;&gt;Reference: Standard field definitions&lt;/a&gt; display name value of &lt;code&gt;${__field.labels.hostname}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Data frame result:&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;text&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-text&#34;&gt;&amp;#43;---------------------&amp;#43;---------------------------&amp;#43;---------------------------&amp;#43;
| Name: time          | Name: value               | Name: value               |
| Labels:             | Labels: hostname=10.0.1.1 | Labels: hostname=10.0.1.2 |
| Type: []time.Time   | Type: []float64           | Type: []float64           |
&amp;#43;---------------------&amp;#43;---------------------------&amp;#43;---------------------------&amp;#43;
| 2020-01-02 03:05:00 | 3                         | 4                         |
| 2020-01-02 03:10:00 | 6                         | 7                         |
&amp;#43;---------------------&amp;#43;---------------------------&amp;#43;---------------------------&amp;#43;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example with multiple columns:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  $__timeGroup(time_date_time, &amp;#39;5m&amp;#39;),
  min(value_double) as min_value,
  max(value_double) as max_value
FROM test_data
WHERE $__timeFilter(time_date_time)
GROUP BY $__timeGroup(time_date_time, &amp;#39;5m&amp;#39;)
ORDER BY 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Data frame result:&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;text&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-text&#34;&gt;&amp;#43;---------------------&amp;#43;-----------------&amp;#43;-----------------&amp;#43;
| Name: time          | Name: min_value | Name: max_value |
| Labels:             | Labels:         | Labels:         |
| Type: []time.Time   | Type: []float64 | Type: []float64 |
&amp;#43;---------------------&amp;#43;-----------------&amp;#43;-----------------&amp;#43;
| 2020-01-02 03:04:00 | 3               | 4               |
| 2020-01-02 03:05:00 | 6               | 7               |
&amp;#43;---------------------&amp;#43;-----------------&amp;#43;-----------------&amp;#43;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;templating&#34;&gt;Templating&lt;/h2&gt;
&lt;p&gt;Instead of hard-coding things like server, application and sensor name in your metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns make it easy to change the data being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Check out the &lt;a href=&#34;../../variables/&#34;&gt;Templating&lt;/a&gt; documentation for an introduction to the templating feature and the different types of template variables.&lt;/p&gt;
&lt;h3 id=&#34;query-variable&#34;&gt;Query variable&lt;/h3&gt;
&lt;p&gt;If you add a template variable of the type &lt;code&gt;Query&lt;/code&gt;, you can write a MS SQL query that can
return things like measurement names, key names or key values that are shown as a dropdown select box.&lt;/p&gt;
&lt;p&gt;For example, you can have a variable that contains all values for the &lt;code&gt;hostname&lt;/code&gt; column in a table if you specify a query like this in the templating variable &lt;strong&gt;Query&lt;/strong&gt; setting.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT hostname FROM host&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;A query can return multiple columns and Grafana will automatically create a list from them. For example, the query below will return a list with values from &lt;code&gt;hostname&lt;/code&gt; and &lt;code&gt;hostname2&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT [host].[hostname], [other_host].[hostname2] FROM host JOIN other_host ON [host].[city] = [other_host].[city]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Another option is a query that can create a key/value variable. The query should return two columns that are named &lt;code&gt;__text&lt;/code&gt; and &lt;code&gt;__value&lt;/code&gt;. The &lt;code&gt;__text&lt;/code&gt; column value should be unique (if it is not unique then the first value is used). The options in the dropdown will have a text and value that allow you to have a friendly name as text and an id as the value. An example query with &lt;code&gt;hostname&lt;/code&gt; as the text and &lt;code&gt;id&lt;/code&gt; as the value:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT hostname __text, id __value FROM host&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can also create nested variables. For example, if you had another variable named &lt;code&gt;region&lt;/code&gt;. Then you could have
the hosts variable only show hosts from the current selected region with a query like this (if &lt;code&gt;region&lt;/code&gt; is a multi-value variable, then use the &lt;code&gt;IN&lt;/code&gt; comparison operator rather than &lt;code&gt;=&lt;/code&gt; to match against multiple values):&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT hostname FROM host WHERE region IN ($region)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;using-variables-in-queries&#34;&gt;Using Variables in Queries&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;From Grafana 4.3.0 to 4.6.0, template variables are always quoted automatically so if it is a string value do not wrap them in quotes in where clauses.&lt;/p&gt;
&lt;p&gt;From Grafana 5.0.0, template variable values are only quoted when the template variable is a &lt;code&gt;multi-value&lt;/code&gt;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;If the variable is a multi-value variable then use the &lt;code&gt;IN&lt;/code&gt; comparison operator rather than &lt;code&gt;=&lt;/code&gt; to match against multiple values.&lt;/p&gt;
&lt;p&gt;There are two syntaxes:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;$&amp;lt;varname&amp;gt;&lt;/code&gt; Example with a template variable named &lt;code&gt;hostname&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  atimestamp time,
  aint value
FROM table
WHERE $__timeFilter(atimestamp) and hostname in($hostname)
ORDER BY atimestamp&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;code&gt;[[varname]]&lt;/code&gt; Example with a template variable named &lt;code&gt;hostname&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  atimestamp as time,
  aint as value
FROM table
WHERE $__timeFilter(atimestamp) and hostname in([[hostname]])
ORDER BY atimestamp&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;disabling-quoting-for-multi-value-variables&#34;&gt;Disabling Quoting for Multi-value Variables&lt;/h4&gt;
&lt;p&gt;Grafana automatically creates a quoted, comma-separated string for multi-value variables. For example: if &lt;code&gt;server01&lt;/code&gt; and &lt;code&gt;server02&lt;/code&gt; are selected then it will be formatted as: &lt;code&gt;&#39;server01&#39;, &#39;server02&#39;&lt;/code&gt;. Do disable quoting, use the csv formatting option for variables:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;${servers:csv}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Read more about variable formatting options in the &lt;a href=&#34;../../variables/variable-types/#advanced-formatting-options&#34;&gt;Variables&lt;/a&gt; documentation.&lt;/p&gt;
&lt;h2 id=&#34;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;../../dashboards/annotations/&#34;&gt;Annotations&lt;/a&gt; allow you to overlay rich event information on top of graphs. You add annotation queries via the Dashboard menu / Annotations view.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Columns:&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;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;time&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The name of the date/time field. Could be a column with a native SQL date/time data type or epoch value.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;timeend&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Optional name of the end date/time field. Could be a column with a native SQL date/time data type or epoch value. (Grafana v6.6&#43;)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;text&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Event description field.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tags&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Optional field name to use for event tags as a comma separated string.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;&lt;strong&gt;Example database tables:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;CREATE TABLE [events] (
  time_sec bigint,
  description nvarchar(100),
  tags nvarchar(100),
)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;We also use the database table defined in &lt;a href=&#34;#time-series-queries&#34;&gt;Time series queries&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example query using time column with epoch values:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  time_sec as time,
  description as [text],
  tags
FROM
  [events]
WHERE
  $__unixEpochFilter(time_sec)
ORDER BY 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example region query using time and timeend columns with epoch values:&lt;/strong&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Only available in Grafana v6.6&#43;.&lt;/p&gt;&lt;/blockquote&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  time_sec as time,
  time_end_sec as timeend,
  description as [text],
  tags
FROM
  [events]
WHERE
  $__unixEpochFilter(time_sec)
ORDER BY 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example query using time column of native SQL date/time data type:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  time,
  measurement as text,
  convert(varchar, valueOne) &amp;#43; &amp;#39;,&amp;#39; &amp;#43; convert(varchar, valueTwo) as tags
FROM
  metric_values
WHERE
  $__timeFilter(time_column)
ORDER BY 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;stored-procedure-support&#34;&gt;Stored procedure support&lt;/h2&gt;
&lt;p&gt;Stored procedures have been verified to work. However, please note that we haven&amp;rsquo;t done anything special to support this, so there might be edge cases where it won&amp;rsquo;t work as you would expect.
Stored procedures should be supported in table, time series and annotation queries as long as you use the same naming of columns and return data in the same format as describe above under respective section.&lt;/p&gt;
&lt;p&gt;Please note that any macro function will not work inside a stored procedure.&lt;/p&gt;
&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;p&gt;&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow docs-image--right&#34;
    style=&#34;max-width: 1054px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/static/img/docs/v51/mssql_metrics_graph.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/static/img/docs/v51/mssql_metrics_graph.png&#34;data-srcset=&#34;/static/img/docs/v51/mssql_metrics_graph.png?w=320 320w, /static/img/docs/v51/mssql_metrics_graph.png?w=550 550w, /static/img/docs/v51/mssql_metrics_graph.png?w=750 750w, /static/img/docs/v51/mssql_metrics_graph.png?w=900 900w, /static/img/docs/v51/mssql_metrics_graph.png?w=1040 1040w, /static/img/docs/v51/mssql_metrics_graph.png?w=1240 1240w, /static/img/docs/v51/mssql_metrics_graph.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;1054&#34;height=&#34;552&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v51/mssql_metrics_graph.png&#34;
            alt=&#34;&#34;width=&#34;1054&#34;height=&#34;552&#34;class=&#34;docs-image--no-shadow docs-image--right&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
For the following examples, the database table is defined in &lt;a href=&#34;#time-series-queries&#34;&gt;Time series queries&lt;/a&gt;. Let&amp;rsquo;s say that we want to visualize four series in a graph panel, such as all combinations of columns &lt;code&gt;valueOne&lt;/code&gt;, &lt;code&gt;valueTwo&lt;/code&gt; and &lt;code&gt;measurement&lt;/code&gt;. Graph panel to the right visualizes what we want to achieve. To solve this, we need to use two queries:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;First query:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  $__timeGroup(time, &amp;#39;5m&amp;#39;) as time,
  measurement &amp;#43; &amp;#39; - value one&amp;#39; as metric,
  avg(valueOne) as valueOne
FROM
  metric_values
WHERE
  $__timeFilter(time)
GROUP BY
  $__timeGroup(time, &amp;#39;5m&amp;#39;),
  measurement
ORDER BY 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Second query:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  $__timeGroup(time, &amp;#39;5m&amp;#39;) as time,
  measurement &amp;#43; &amp;#39; - value two&amp;#39; as metric,
  avg(valueTwo) as valueTwo
FROM
  metric_values
GROUP BY
  $__timeGroup(time, &amp;#39;5m&amp;#39;),
  measurement
ORDER BY 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;stored-procedure-using-time-in-epoch-format&#34;&gt;Stored procedure using time in epoch format&lt;/h4&gt;
&lt;p&gt;We can define a stored procedure that will return all data we need to render 4 series in a graph panel like above.
In this case the stored procedure accepts two parameters &lt;code&gt;@from&lt;/code&gt; and &lt;code&gt;@to&lt;/code&gt; of &lt;code&gt;int&lt;/code&gt; data types which should be a timerange (from-to) in epoch format
which will be used to filter the data to return from the stored procedure.&lt;/p&gt;
&lt;p&gt;We&amp;rsquo;re mimicking the &lt;code&gt;$__timeGroup(time, &#39;5m&#39;)&lt;/code&gt; in the select and group by expressions, and that&amp;rsquo;s why there are a lot of lengthy expressions needed -
these could be extracted to MS SQL functions, if wanted.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;CREATE PROCEDURE sp_test_epoch(
  @from int,
  @to 	int
)	AS
BEGIN
  SELECT
    cast(cast(DATEDIFF(second, {d &amp;#39;1970-01-01&amp;#39;}, DATEADD(second, DATEDIFF(second,GETDATE(),GETUTCDATE()), time))/600 as int)*600 as int) as time,
    measurement &amp;#43; &amp;#39; - value one&amp;#39; as metric,
    avg(valueOne) as value
  FROM
    metric_values
  WHERE
    time &amp;gt;= DATEADD(s, @from, &amp;#39;1970-01-01&amp;#39;) AND time &amp;lt;= DATEADD(s, @to, &amp;#39;1970-01-01&amp;#39;)
  GROUP BY
    cast(cast(DATEDIFF(second, {d &amp;#39;1970-01-01&amp;#39;}, DATEADD(second, DATEDIFF(second,GETDATE(),GETUTCDATE()), time))/600 as int)*600 as int),
    measurement
  UNION ALL
  SELECT
    cast(cast(DATEDIFF(second, {d &amp;#39;1970-01-01&amp;#39;}, DATEADD(second, DATEDIFF(second,GETDATE(),GETUTCDATE()), time))/600 as int)*600 as int) as time,
    measurement &amp;#43; &amp;#39; - value two&amp;#39; as metric,
    avg(valueTwo) as value
  FROM
    metric_values
  WHERE
    time &amp;gt;= DATEADD(s, @from, &amp;#39;1970-01-01&amp;#39;) AND time &amp;lt;= DATEADD(s, @to, &amp;#39;1970-01-01&amp;#39;)
  GROUP BY
    cast(cast(DATEDIFF(second, {d &amp;#39;1970-01-01&amp;#39;}, DATEADD(second, DATEDIFF(second,GETDATE(),GETUTCDATE()), time))/600 as int)*600 as int),
    measurement
  ORDER BY 1
END&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Then we can use the following query for our graph panel.&lt;/p&gt;

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

EXEC dbo.sp_test_epoch @from, @to&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;stored-procedure-using-time-in-datetime-format&#34;&gt;Stored procedure using time in datetime format&lt;/h4&gt;
&lt;p&gt;We can define a stored procedure that will return all data we need to render 4 series in a graph panel like above.
In this case the stored procedure accepts two parameters &lt;code&gt;@from&lt;/code&gt; and &lt;code&gt;@to&lt;/code&gt; of &lt;code&gt;datetime&lt;/code&gt; data types which should be a timerange (from-to)
which will be used to filter the data to return from the stored procedure.&lt;/p&gt;
&lt;p&gt;We&amp;rsquo;re mimicking the &lt;code&gt;$__timeGroup(time, &#39;5m&#39;)&lt;/code&gt; in the select and group by expressions and that&amp;rsquo;s why there&amp;rsquo;s a lot of lengthy expressions needed -
these could be extracted to MS SQL functions, if wanted.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;CREATE PROCEDURE sp_test_datetime(
  @from datetime,
  @to 	datetime
)	AS
BEGIN
  SELECT
    cast(cast(DATEDIFF(second, {d &amp;#39;1970-01-01&amp;#39;}, time)/600 as int)*600 as int) as time,
    measurement &amp;#43; &amp;#39; - value one&amp;#39; as metric,
    avg(valueOne) as value
  FROM
    metric_values
  WHERE
    time &amp;gt;= @from AND time &amp;lt;= @to
  GROUP BY
    cast(cast(DATEDIFF(second, {d &amp;#39;1970-01-01&amp;#39;}, time)/600 as int)*600 as int),
    measurement
  UNION ALL
  SELECT
    cast(cast(DATEDIFF(second, {d &amp;#39;1970-01-01&amp;#39;}, time)/600 as int)*600 as int) as time,
    measurement &amp;#43; &amp;#39; - value two&amp;#39; as metric,
    avg(valueTwo) as value
  FROM
    metric_values
  WHERE
    time &amp;gt;= @from AND time &amp;lt;= @to
  GROUP BY
    cast(cast(DATEDIFF(second, {d &amp;#39;1970-01-01&amp;#39;}, time)/600 as int)*600 as int),
    measurement
  ORDER BY 1
END&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Then we can use the following query for our graph panel.&lt;/p&gt;

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

EXEC dbo.sp_test_datetime @from, @to&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;alerting&#34;&gt;Alerting&lt;/h2&gt;
&lt;p&gt;Time series queries should work in alerting conditions. Table formatted queries are not yet supported in alert rule
conditions.&lt;/p&gt;
&lt;h2 id=&#34;configure-the-data-source-with-provisioning&#34;&gt;Configure the data source with provisioning&lt;/h2&gt;
&lt;p&gt;It&amp;rsquo;s now possible to configure data sources using config files with Grafana&amp;rsquo;s provisioning system. You can read more about how it works and all the settings you can set for data sources on the &lt;a href=&#34;../../administration/provisioning/#datasources&#34;&gt;provisioning docs page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here are some provisioning examples for this data source.&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: MSSQL
    type: mssql
    url: localhost:1433
    database: grafana
    user: grafana
    jsonData:
      maxOpenConns: 0 # Grafana v5.4&amp;#43;
      maxIdleConns: 2 # Grafana v5.4&amp;#43;
      connMaxLifetime: 14400 # Grafana v5.4&amp;#43;
    secureJsonData:
      password: &amp;#39;Password!&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="using-microsoft-sql-server-in-grafana">Using Microsoft SQL Server in Grafana&lt;/h1>
&lt;p>Grafana ships with a built-in Microsoft SQL Server (MS SQL) data source plugin that allows you to query and visualize data from any Microsoft SQL Server 2005 or newer, including Microsoft Azure SQL Database. This topic explains options, variables, querying, and other options specific to the MS SQL data source. Refer to &lt;a href="../add-a-data-source/">Add a data source&lt;/a> for instructions on how to add a data source to Grafana. Only users with the organization admin role can add data sources.&lt;/p></description></item><item><title>MySQL</title><link>https://grafana.com/docs/grafana/v8.4/datasources/mysql/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/mysql/</guid><content><![CDATA[&lt;h1 id=&#34;using-mysql-in-grafana&#34;&gt;Using MySQL in Grafana&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;Starting from Grafana v5.1 you can name the time column &lt;em&gt;time&lt;/em&gt; in addition to earlier supported &lt;em&gt;time_sec&lt;/em&gt;. Usage of &lt;em&gt;time_sec&lt;/em&gt; will eventually be deprecated.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Grafana ships with a built-in MySQL data source plugin that allows you to query and visualize data from a MySQL compatible database.&lt;/p&gt;
&lt;h2 id=&#34;adding-the-data-source&#34;&gt;Adding the data source&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Open the side menu by clicking the Grafana icon in the top header.&lt;/li&gt;
&lt;li&gt;In the side menu under the &lt;code&gt;Dashboards&lt;/code&gt; link you should find a link named &lt;code&gt;Data Sources&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click the &lt;code&gt;&#43; Add data source&lt;/code&gt; button in the top header.&lt;/li&gt;
&lt;li&gt;Select &lt;em&gt;MySQL&lt;/em&gt; from the &lt;em&gt;Type&lt;/em&gt; dropdown.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;data-source-options&#34;&gt;Data source 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;Name&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;Name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The data source name. This is how you refer to the data source in panels and queries.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Default&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Default data source means that it will be pre-selected for new panels.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Host&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The IP address/hostname and optional port of your MySQL instance.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Database&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Name of your MySQL database.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;User&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Database user&amp;rsquo;s login/username&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Password&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Database user&amp;rsquo;s password&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Session Timezone&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Specify the time zone used in the database session, such as &lt;code&gt;Europe/Berlin&lt;/code&gt; or &lt;code&gt;&#43;02:00&lt;/code&gt;. This is necessary, if the timezone of the database (or the host of the database) is set to something other than UTC. Set the value used in the session with &lt;code&gt;SET time_zone=&#39;...&#39;&lt;/code&gt;. If you leave this field empty, then the time zone is not updated. For more information, refer to the &lt;a href=&#34;https://dev.mysql.com/doc/refman/8.0/en/time-zone-support.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;MySQL documentation&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Max open&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The maximum number of open connections to the database, default &lt;code&gt;unlimited&lt;/code&gt; (Grafana v5.4&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Max idle&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The maximum number of connections in the idle connection pool, default &lt;code&gt;2&lt;/code&gt; (Grafana v5.4&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Max lifetime&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The maximum amount of time in seconds a connection may be reused, default &lt;code&gt;14400&lt;/code&gt;/4 hours. This should always be lower than configured &lt;a href=&#34;https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_wait_timeout&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;wait_timeout&lt;/a&gt; in MySQL (Grafana v5.4&#43;).&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;min-time-interval&#34;&gt;Min time interval&lt;/h3&gt;
&lt;p&gt;A lower limit for the &lt;a href=&#34;../../variables/variable-types/global-variables/#__interval&#34;&gt;$__interval&lt;/a&gt; and &lt;a href=&#34;../../variables/variable-types/global-variables/#__interval_ms&#34;&gt;$__interval_ms&lt;/a&gt; variables.
Recommended to be set to write frequency, for example &lt;code&gt;1m&lt;/code&gt; if your data is written every minute.
This option can also be overridden/configured in a dashboard panel under data source options. It&amp;rsquo;s important to note that this value &lt;strong&gt;needs&lt;/strong&gt; to be formatted as a
number followed by a valid time identifier, e.g. &lt;code&gt;1m&lt;/code&gt; (1 minute) or &lt;code&gt;30s&lt;/code&gt; (30 seconds). The following time identifiers are supported:&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;Identifier&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;y&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;year&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;M&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;month&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;w&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;week&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;d&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;day&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;h&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;hour&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;m&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;minute&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;s&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;second&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ms&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;millisecond&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;database-user-permissions-important&#34;&gt;Database User Permissions (Important!)&lt;/h3&gt;
&lt;p&gt;The database user you specify when you add the data source should only be granted SELECT permissions on
the specified database and tables you want to query. Grafana does not validate that the query is safe. The query
could include any SQL statement. For example, statements like &lt;code&gt;USE otherdb;&lt;/code&gt; and &lt;code&gt;DROP TABLE user;&lt;/code&gt; would be
executed. To protect against this we &lt;strong&gt;Highly&lt;/strong&gt; recommend you create a specific mysql user with restricted permissions.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt; CREATE USER &amp;#39;grafanaReader&amp;#39; IDENTIFIED BY &amp;#39;password&amp;#39;;
 GRANT SELECT ON mydatabase.mytable TO &amp;#39;grafanaReader&amp;#39;;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can use wildcards (&lt;code&gt;*&lt;/code&gt;) in place of database or table if you want to grant access to more databases and tables.&lt;/p&gt;
&lt;h2 id=&#34;query-editor&#34;&gt;Query Editor&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Only available in Grafana v5.4&#43;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;div class=&#34;screenshot&#34; style=&#34;max-width:&#34;&gt;
  &lt;a href=&#34;/static/img/docs/v54/mysql_query.gif&#34; title=&#34;&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==&#34;
         data-src=&#34;/static/img/docs/v54/mysql_query_still.png&#34; class=&#34;screenshot__still lazyload&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;/static/img/docs/v54/mysql_query.gif&#34; class=&#34;screenshot__animated-gif&#34;&gt;
    &lt;div class=&#34;screenshot__play&#34;&gt;
      &lt;i class=&#34;fa fa-play&#34;&gt;&lt;/i&gt;
    &lt;/div&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;You find the MySQL query editor in the metrics tab in a panel&amp;rsquo;s edit mode. You enter edit mode by clicking the
panel title, then edit.&lt;/p&gt;
&lt;p&gt;The query editor has a link named &lt;code&gt;Generated SQL&lt;/code&gt; that shows up after a query has been executed, while in panel edit mode. Click on it and it will expand and show the raw interpolated SQL string that was executed.&lt;/p&gt;
&lt;h3 id=&#34;select-table-time-column-and-metric-column-from&#34;&gt;Select table, time column and metric column (FROM)&lt;/h3&gt;
&lt;p&gt;When you enter edit mode for the first time or add a new query Grafana will try to prefill the query builder with the first table that has a timestamp column and a numeric column.&lt;/p&gt;
&lt;p&gt;In the FROM field, Grafana will suggest tables that are in the configured database. To select a table or view in another database that your database user has access to you can manually enter a fully qualified name (database.table) like &lt;code&gt;otherDb.metrics&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The Time column field refers to the name of the column holding your time values. Selecting a value for the Metric column field is optional. If a value is selected, the Metric column field will be used as the series name.&lt;/p&gt;
&lt;p&gt;The metric column suggestions will only contain columns with a text datatype (text, tinytext, mediumtext, longtext, varchar, char).
If you want to use a column with a different datatype as metric column you may enter the column name with a cast: &lt;code&gt;CAST(numericColumn as CHAR)&lt;/code&gt;.
You may also enter arbitrary SQL expressions in the metric column field that evaluate to a text datatype like
&lt;code&gt;CONCAT(column1, &amp;quot; &amp;quot;, CAST(numericColumn as CHAR))&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;columns-and-aggregation-functions-select&#34;&gt;Columns and Aggregation functions (SELECT)&lt;/h3&gt;
&lt;p&gt;In the &lt;code&gt;SELECT&lt;/code&gt; row you can specify what columns and functions you want to use.
In the column field you may write arbitrary expressions instead of a column name like &lt;code&gt;column1 * column2 / column3&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you use aggregate functions you need to group your resultset. The editor will automatically add a &lt;code&gt;GROUP BY time&lt;/code&gt; if you add an aggregate function.&lt;/p&gt;
&lt;p&gt;You may add further value columns by clicking the plus button and selecting &lt;code&gt;Column&lt;/code&gt; from the menu. Multiple value columns will be plotted as separate series in the graph panel.&lt;/p&gt;
&lt;h3 id=&#34;filter-data-where&#34;&gt;Filter data (WHERE)&lt;/h3&gt;
&lt;p&gt;To add a filter click the plus icon to the right of the &lt;code&gt;WHERE&lt;/code&gt; condition. You can remove filters by clicking on
the filter and selecting &lt;code&gt;Remove&lt;/code&gt;. A filter for the current selected timerange is automatically added to new queries.&lt;/p&gt;
&lt;h3 id=&#34;group-by&#34;&gt;Group By&lt;/h3&gt;
&lt;p&gt;To group by time or any other columns click the plus icon at the end of the GROUP BY row. The suggestion dropdown will only show text columns of your currently selected table but you may manually enter any column.
You can remove the group by clicking on the item and then selecting &lt;code&gt;Remove&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you add any grouping, all selected columns need to have an aggregate function applied. The query builder will automatically add aggregate functions to all columns without aggregate functions when you add groupings.&lt;/p&gt;
&lt;h4 id=&#34;gap-filling&#34;&gt;Gap Filling&lt;/h4&gt;
&lt;p&gt;Grafana can fill in missing values when you group by time. The time function accepts two arguments. The first argument is the time window that you would like to group by, and the second argument is the value you want Grafana to fill missing items with.&lt;/p&gt;
&lt;h3 id=&#34;text-editor-mode-raw&#34;&gt;Text Editor Mode (RAW)&lt;/h3&gt;
&lt;p&gt;You can switch to the raw query editor mode by clicking the hamburger icon and selecting &lt;code&gt;Switch editor mode&lt;/code&gt; or by clicking &lt;code&gt;Edit SQL&lt;/code&gt; below the query.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you use the raw query editor, be sure your query at minimum has &lt;code&gt;ORDER BY time&lt;/code&gt; and a filter on the returned time range.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;macros&#34;&gt;Macros&lt;/h2&gt;
&lt;p&gt;To simplify syntax and to allow for dynamic parts, like date range filters, the query can contain macros.&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;Macro example&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__time(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by an expression to convert to a UNIX timestamp and rename the column to &lt;code&gt;time_sec&lt;/code&gt;. For example, &lt;em&gt;UNIX_TIMESTAMP(dateColumn) as time_sec&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeEpoch(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by an expression to convert to a UNIX timestamp and rename the column to &lt;code&gt;time_sec&lt;/code&gt;. For example, &lt;em&gt;UNIX_TIMESTAMP(dateColumn) as time_sec&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeFilter(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by a time range filter using the specified column name. For example, &lt;em&gt;dateColumn BETWEEN FROM_UNIXTIME(1494410783) AND FROM_UNIXTIME(1494410983)&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeFrom()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the start of the currently active time selection. For example, &lt;em&gt;FROM_UNIXTIME(1494410783)&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeTo()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the end of the currently active time selection. For example, &lt;em&gt;FROM_UNIXTIME(1494410983)&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroup(dateColumn,&#39;5m&#39;)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by an expression usable in GROUP BY clause. For example, *cast(cast(UNIX_TIMESTAMP(dateColumn)/(300) as signed)*300 as signed),*&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroup(dateColumn,&#39;5m&#39;, 0)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as above but with a fill parameter so missing points in that series will be added by grafana and 0 will be used as value.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroup(dateColumn,&#39;5m&#39;, NULL)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as above but NULL will be used as value for missing points.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroup(dateColumn,&#39;5m&#39;, previous)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as above but the previous value in that series will be used as fill value if no value has been seen yet NULL will be used (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroupAlias(dateColumn,&#39;5m&#39;)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced identical to $__timeGroup but with an added column alias (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochFilter(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by a time range filter using the specified column name with times represented as Unix timestamp. For example, &lt;em&gt;dateColumn &amp;gt; 1494410783 AND dateColumn &amp;lt; 1494497183&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochFrom()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the start of the currently active time selection as Unix timestamp. For example, &lt;em&gt;1494410783&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochTo()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the end of the currently active time selection as Unix timestamp. For example, &lt;em&gt;1494497183&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochNanoFilter(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by a time range filter using the specified column name with times represented as nanosecond timestamp. For example, &lt;em&gt;dateColumn &amp;gt; 1494410783152415214 AND dateColumn &amp;lt; 1494497183142514872&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochNanoFrom()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the start of the currently active time selection as nanosecond timestamp. For example, &lt;em&gt;1494410783152415214&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochNanoTo()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the end of the currently active time selection as nanosecond timestamp. For example, &lt;em&gt;1494497183142514872&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochGroup(dateColumn,&#39;5m&#39;, [fillmode])&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as $__timeGroup but for times stored as Unix timestamp (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochGroupAlias(dateColumn,&#39;5m&#39;, [fillmode])&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as above but also adds a column alias (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;We plan to add many more macros. If you have suggestions for what macros you would like to see, please &lt;a href=&#34;https://github.com/grafana/grafana&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;open an issue&lt;/a&gt; in our GitHub repo.&lt;/p&gt;
&lt;p&gt;The query editor has a link named &lt;code&gt;Generated SQL&lt;/code&gt; that shows up after a query has been executed, while in panel edit mode. Click on it and it will expand and show the raw interpolated SQL string that was executed.&lt;/p&gt;
&lt;h2 id=&#34;table-queries&#34;&gt;Table queries&lt;/h2&gt;
&lt;p&gt;If the &lt;code&gt;Format as&lt;/code&gt; query option is set to &lt;code&gt;Table&lt;/code&gt; then you can basically do any type of SQL query. The table panel will automatically show the results of whatever columns and rows your query returns.&lt;/p&gt;
&lt;p&gt;Query editor with example query:&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 1770px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/static/img/docs/v45/mysql_table_query.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/static/img/docs/v45/mysql_table_query.png&#34;data-srcset=&#34;/static/img/docs/v45/mysql_table_query.png?w=320 320w, /static/img/docs/v45/mysql_table_query.png?w=550 550w, /static/img/docs/v45/mysql_table_query.png?w=750 750w, /static/img/docs/v45/mysql_table_query.png?w=900 900w, /static/img/docs/v45/mysql_table_query.png?w=1040 1040w, /static/img/docs/v45/mysql_table_query.png?w=1240 1240w, /static/img/docs/v45/mysql_table_query.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;1770&#34;height=&#34;470&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v45/mysql_table_query.png&#34;
            alt=&#34;&#34;width=&#34;1770&#34;height=&#34;470&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;The query:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  title as &amp;#39;Title&amp;#39;,
  user.login as &amp;#39;Created By&amp;#39; ,
  dashboard.created as &amp;#39;Created On&amp;#39;
 FROM dashboard
INNER JOIN user on user.id = dashboard.created_by
WHERE $__timeFilter(dashboard.created)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can control the name of the Table panel columns by using regular &lt;code&gt;as &lt;/code&gt; SQL column selection syntax.&lt;/p&gt;
&lt;p&gt;The resulting table panel:&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload&#34;
  data-src=&#34;/static/img/docs/v43/mysql_table.png&#34;
  alt=&#34;&#34; width=&#34;562&#34;
     height=&#34;250&#34;/&gt;&lt;/p&gt;
&lt;h2 id=&#34;time-series-queries&#34;&gt;Time series queries&lt;/h2&gt;
&lt;p&gt;If you set Format as to &lt;em&gt;Time series&lt;/em&gt;, then the query must have a column named time that returns either a SQL datetime or any numeric datatype representing Unix epoch in seconds. In addition, result sets of time series queries must be sorted by time for panels to properly visualize the result.&lt;/p&gt;
&lt;p&gt;A time series query result is returned in a &lt;a href=&#34;/developers/plugin-tools/introduction/data-frames#wide-format&#34;&gt;wide data frame format&lt;/a&gt;. Any column except time or of type string transforms into value fields in the data frame query result. Any string column transforms into field labels in the data frame query result.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;For backward compatibility, there&amp;rsquo;s an exception to the above rule for queries that return three columns including a string column named metric. Instead of transforming the metric column into field labels, it becomes the field name, and then the series name is formatted as the value of the metric column. See the example with the metric column below.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;You can optionally customize the default series name formatting using instructions in &lt;a href=&#34;../../panels/reference-standard-field-definitions/#display-name&#34;&gt;Reference: Standard field definitions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example with &lt;code&gt;metric&lt;/code&gt; column:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  $__timeGroup(time_date_time,&amp;#39;5m&amp;#39;),
  min(value_double),
  &amp;#39;min&amp;#39; as metric
FROM test_data
WHERE $__timeFilter(time_date_time)
GROUP BY time
ORDER BY time&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Data frame result:&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;text&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-text&#34;&gt;&amp;#43;---------------------&amp;#43;-----------------&amp;#43;
| Name: time          | Name: min       |
| Labels:             | Labels:         |
| Type: []time.Time   | Type: []float64 |
&amp;#43;---------------------&amp;#43;-----------------&amp;#43;
| 2020-01-02 03:05:00 | 3               |
| 2020-01-02 03:10:00 | 6               |
&amp;#43;---------------------&amp;#43;-----------------&amp;#43;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example using the fill parameter in the $__timeGroup macro to convert null values to be zero instead:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  $__timeGroup(createdAt,&amp;#39;5m&amp;#39;,0),
  sum(value_double) as value,
  hostname
FROM test_data
WHERE
  $__timeFilter(createdAt)
GROUP BY time, hostname
ORDER BY time&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Given the data frame result in the following example and using the graph panel, you will get two series named &lt;em&gt;value 10.0.1.1&lt;/em&gt; and &lt;em&gt;value 10.0.1.2&lt;/em&gt;. To render the series with a name of &lt;em&gt;10.0.1.1&lt;/em&gt; and &lt;em&gt;10.0.1.2&lt;/em&gt; , use a &lt;a href=&#34;../../panels/reference-standard-field-definitions/#display-name&#34;&gt;Reference: Standard field definitions&lt;/a&gt; display value of &lt;code&gt;${__field.labels.hostname}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Data frame result:&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;text&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-text&#34;&gt;&amp;#43;---------------------&amp;#43;---------------------------&amp;#43;---------------------------&amp;#43;
| Name: time          | Name: value               | Name: value               |
| Labels:             | Labels: hostname=10.0.1.1 | Labels: hostname=10.0.1.2 |
| Type: []time.Time   | Type: []float64           | Type: []float64           |
&amp;#43;---------------------&amp;#43;---------------------------&amp;#43;---------------------------&amp;#43;
| 2020-01-02 03:05:00 | 3                         | 4                         |
| 2020-01-02 03:10:00 | 6                         | 7                         |
&amp;#43;---------------------&amp;#43;---------------------------&amp;#43;---------------------------&amp;#43;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example with multiple columns:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  $__timeGroup(time_date_time,&amp;#39;5m&amp;#39;),
  min(value_double) as min_value,
  max(value_double) as max_value
FROM test_data
WHERE $__timeFilter(time_date_time)
GROUP BY time
ORDER BY time&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Data frame result:&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;text&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-text&#34;&gt;&amp;#43;---------------------&amp;#43;-----------------&amp;#43;-----------------&amp;#43;
| Name: time          | Name: min_value | Name: max_value |
| Labels:             | Labels:         | Labels:         |
| Type: []time.Time   | Type: []float64 | Type: []float64 |
&amp;#43;---------------------&amp;#43;-----------------&amp;#43;-----------------&amp;#43;
| 2020-01-02 03:04:00 | 3               | 4               |
| 2020-01-02 03:05:00 | 6               | 7               |
&amp;#43;---------------------&amp;#43;-----------------&amp;#43;-----------------&amp;#43;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Currently, there is no support for a dynamic group by time based on time range and panel width.
This is something we plan to add.&lt;/p&gt;
&lt;h2 id=&#34;templating&#34;&gt;Templating&lt;/h2&gt;
&lt;p&gt;This feature is currently available in the nightly builds and will be included in the 5.0.0 release.&lt;/p&gt;
&lt;p&gt;Instead of hard-coding things like server, application and sensor name in your metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns make it easy to change the data being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Check out the &lt;a href=&#34;../../variables/&#34;&gt;Templating&lt;/a&gt; documentation for an introduction to the templating feature and the different types of template variables.&lt;/p&gt;
&lt;h3 id=&#34;query-variable&#34;&gt;Query Variable&lt;/h3&gt;
&lt;p&gt;If you add a template variable of the type &lt;code&gt;Query&lt;/code&gt;, you can write a MySQL query that can
return things like measurement names, key names or key values that are shown as a dropdown select box.&lt;/p&gt;
&lt;p&gt;For example, you can have a variable that contains all values for the &lt;code&gt;hostname&lt;/code&gt; column in a table if you specify a query like this in the templating variable &lt;em&gt;Query&lt;/em&gt; setting.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT hostname FROM my_host&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;A query can return multiple columns and Grafana will automatically create a list from them. For example, the query below will return a list with values from &lt;code&gt;hostname&lt;/code&gt; and &lt;code&gt;hostname2&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT my_host.hostname, my_other_host.hostname2 FROM my_host JOIN my_other_host ON my_host.city = my_other_host.city&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To use time range dependent macros like &lt;code&gt;$__timeFilter(column)&lt;/code&gt; in your query the refresh mode of the template variable needs to be set to &lt;em&gt;On Time Range Change&lt;/em&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT event_name FROM event_log WHERE $__timeFilter(time_column)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Another option is a query that can create a key/value variable. The query should return two columns that are named &lt;code&gt;__text&lt;/code&gt; and &lt;code&gt;__value&lt;/code&gt;. The &lt;code&gt;__text&lt;/code&gt; column value should be unique (if it is not unique then the first value is used). The options in the dropdown will have a text and value that allows you to have a friendly name as text and an id as the value. An example query with &lt;code&gt;hostname&lt;/code&gt; as the text and &lt;code&gt;id&lt;/code&gt; as the value:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT hostname AS __text, id AS __value FROM my_host&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can also create nested variables. For example if you had another variable named &lt;code&gt;region&lt;/code&gt;. Then you could have
the hosts variable only show hosts from the current selected region with a query like this (if &lt;code&gt;region&lt;/code&gt; is a multi-value variable then use the &lt;code&gt;IN&lt;/code&gt; comparison operator rather than &lt;code&gt;=&lt;/code&gt; to match against multiple values):&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT hostname FROM my_host  WHERE region IN($region)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;using-__searchfilter-to-filter-results-in-query-variable&#34;&gt;Using &lt;code&gt;__searchFilter&lt;/code&gt; to filter results in Query Variable&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;Available from Grafana 6.5 and above&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Using &lt;code&gt;__searchFilter&lt;/code&gt; in the query field will filter the query result based on what the user types in the dropdown select box.
When nothing has been entered by the user the default value for &lt;code&gt;__searchFilter&lt;/code&gt; is &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Important that you surround the &lt;code&gt;__searchFilter&lt;/code&gt; expression with quotes as Grafana does not do this for you.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The example below shows how to use &lt;code&gt;__searchFilter&lt;/code&gt; as part of the query field to enable searching for &lt;code&gt;hostname&lt;/code&gt; while the user types in the dropdown select box.&lt;/p&gt;
&lt;p&gt;Query&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT hostname FROM my_host  WHERE hostname LIKE &amp;#39;$__searchFilter&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;using-variables-in-queries&#34;&gt;Using Variables in Queries&lt;/h3&gt;
&lt;p&gt;From Grafana 4.3.0 to 4.6.0, template variables are always quoted automatically so if it is a string value do not wrap them in quotes in where clauses.&lt;/p&gt;
&lt;p&gt;From Grafana 4.7.0, template variable values are only quoted when the template variable is a &lt;code&gt;multi-value&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If the variable is a multi-value variable then use the &lt;code&gt;IN&lt;/code&gt; comparison operator rather than &lt;code&gt;=&lt;/code&gt; to match against multiple values.&lt;/p&gt;
&lt;p&gt;There are two syntaxes:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;$&amp;lt;varname&amp;gt;&lt;/code&gt; Example with a template variable named &lt;code&gt;hostname&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  UNIX_TIMESTAMP(atimestamp) as time,
  aint as value,
  avarchar as metric
FROM my_table
WHERE $__timeFilter(atimestamp) and hostname in($hostname)
ORDER BY atimestamp ASC&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;code&gt;[[varname]]&lt;/code&gt; Example with a template variable named &lt;code&gt;hostname&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  UNIX_TIMESTAMP(atimestamp) as time,
  aint as value,
  avarchar as metric
FROM my_table
WHERE $__timeFilter(atimestamp) and hostname in([[hostname]])
ORDER BY atimestamp ASC&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;disabling-quoting-for-multi-value-variables&#34;&gt;Disabling Quoting for Multi-value Variables&lt;/h4&gt;
&lt;p&gt;Grafana automatically creates a quoted, comma-separated string for multi-value variables. For example: if &lt;code&gt;server01&lt;/code&gt; and &lt;code&gt;server02&lt;/code&gt; are selected then it will be formatted as: &lt;code&gt;&#39;server01&#39;, &#39;server02&#39;&lt;/code&gt;. Do disable quoting, use the csv formatting option for variables:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;${servers:csv}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Read more about variable formatting options in the &lt;a href=&#34;../../variables/#advanced-formatting-options&#34;&gt;Variables&lt;/a&gt; documentation.&lt;/p&gt;
&lt;h2 id=&#34;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;../../dashboards/annotations/&#34;&gt;Annotations&lt;/a&gt; allow you to overlay rich event information on top of graphs. You add annotation queries via the Dashboard menu / Annotations view.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example query using time column with epoch values:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  epoch_time as time,
  metric1 as text,
  CONCAT(tag1, &amp;#39;,&amp;#39;, tag2) as tags
FROM
  public.test_data
WHERE
  $__unixEpochFilter(epoch_time)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example region query using time and timeend columns with epoch values:&lt;/strong&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Only available in Grafana v6.6&#43;.&lt;/p&gt;&lt;/blockquote&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  epoch_time as time,
  epoch_timeend as timeend,
  metric1 as text,
  CONCAT(tag1, &amp;#39;,&amp;#39;, tag2) as tags
FROM
  public.test_data
WHERE
  $__unixEpochFilter(epoch_time)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example query using time column of native SQL date/time data type:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  native_date_time as time,
  metric1 as text,
  CONCAT(tag1, &amp;#39;,&amp;#39;, tag2) as tags
FROM
  public.test_data
WHERE
  $__timeFilter(native_date_time)&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;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;time&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The name of the date/time field. Could be a column with a native SQL date/time data type or epoch value.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;timeend&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Optional name of the end date/time field. Could be a column with a native SQL date/time data type or epoch value. (Grafana v6.6&#43;)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;text&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Event description field.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tags&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Optional field name to use for event tags as a comma separated string.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;alerting&#34;&gt;Alerting&lt;/h2&gt;
&lt;p&gt;Time series queries should work in alerting conditions. Table formatted queries are not yet supported in alert rule conditions.&lt;/p&gt;
&lt;h2 id=&#34;configure-the-data-source-with-provisioning&#34;&gt;Configure the data source with provisioning&lt;/h2&gt;
&lt;p&gt;It&amp;rsquo;s now possible to configure data sources using config files with Grafana&amp;rsquo;s provisioning system. You can read more about how it works and all the settings you can set for data sources on the &lt;a href=&#34;../../administration/provisioning/#datasources&#34;&gt;provisioning docs page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here are some provisioning examples for this data source.&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: MySQL
    type: mysql
    url: localhost:3306
    database: grafana
    user: grafana
    jsonData:
      maxOpenConns: 0 # Grafana v5.4&amp;#43;
      maxIdleConns: 2 # Grafana v5.4&amp;#43;
      connMaxLifetime: 14400 # Grafana v5.4&amp;#43;
    secureJsonData:
      password: ${GRAFANA_MYSQL_PASSWORD}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="using-mysql-in-grafana">Using MySQL in Grafana&lt;/h1>
&lt;blockquote>
&lt;p>Starting from Grafana v5.1 you can name the time column &lt;em>time&lt;/em> in addition to earlier supported &lt;em>time_sec&lt;/em>. Usage of &lt;em>time_sec&lt;/em> will eventually be deprecated.&lt;/p></description></item><item><title>OpenTSDB</title><link>https://grafana.com/docs/grafana/v8.4/datasources/opentsdb/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/opentsdb/</guid><content><![CDATA[&lt;h1 id=&#34;using-opentsdb-in-grafana&#34;&gt;Using OpenTSDB in Grafana&lt;/h1&gt;
&lt;p&gt;Grafana ships with advanced support for OpenTSDB. This topic explains options, variables, querying, and other options specific to the OpenTSDB data source. Refer to &lt;a href=&#34;../add-a-data-source/&#34;&gt;Add a data source&lt;/a&gt; for instructions on how to add a data source to Grafana. Only users with the organization admin role can add data sources.&lt;/p&gt;
&lt;h2 id=&#34;opentsdb-settings&#34;&gt;OpenTSDB settings&lt;/h2&gt;
&lt;p&gt;To access OpenTSDB settings, hover your mouse over the &lt;strong&gt;Configuration&lt;/strong&gt; (gear) icon, then click &lt;strong&gt;Data Sources&lt;/strong&gt;, and then click the OpenTSDB data source.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The data source name. This is how you refer to the data source in panels and queries.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Default&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Default data source means that it will be pre-selected for new panels.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;URL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The HTTP protocol, IP, and port of your OpenTSDB server (default port is usually 4242)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Allowed cookies&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;List the names of cookies to forward to the data source.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Version&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Version = opentsdb version, either &amp;lt;=2.1 or 2.2&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Resolution&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Metrics from opentsdb may have datapoints with either second or millisecond resolution.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Lookup limit&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Default is 1000.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;query-editor&#34;&gt;Query editor&lt;/h2&gt;
&lt;p&gt;Open a graph in edit mode by click the title. Query editor will differ if the data source has version &amp;lt;=2.1 or = 2.2.
In the former version, only tags can be used to query OpenTSDB. But in the latter version, filters as well as tags
can be used to query opentsdb. Fill Policy is also introduced in OpenTSDB 2.2.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload&#34;
  data-src=&#34;/static/img/docs/v43/opentsdb_query_editor.png&#34;
  alt=&#34;&#34; width=&#34;1171&#34;
     height=&#34;239&#34;/&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; While using OpenTSDB 2.2 data source, make sure you use either Filters or Tags as they are mutually exclusive. If used together, might give you weird results.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3 id=&#34;auto-complete-suggestions&#34;&gt;Auto complete suggestions&lt;/h3&gt;
&lt;p&gt;As soon as you start typing metric names, tag names and tag values , you should see highlighted auto complete suggestions for them.
The autocomplete only works if the OpenTSDB suggest API is enabled.&lt;/p&gt;
&lt;h2 id=&#34;templating-queries&#34;&gt;Templating queries&lt;/h2&gt;
&lt;p&gt;Instead of hard-coding things like server, application and sensor name in your metric queries you can use variables in their place.
Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns make it easy to change the data
being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Check out the &lt;a href=&#34;../../variables/&#34;&gt;Templating&lt;/a&gt; documentation for an introduction to the templating feature and the different
types of template variables.&lt;/p&gt;
&lt;h3 id=&#34;query-variable&#34;&gt;Query variable&lt;/h3&gt;
&lt;p&gt;Grafana&amp;rsquo;s OpenTSDB data source supports template variable queries. This means you can create template variables
that fetch the values from OpenTSDB. For example, metric names, tag names, or tag values.&lt;/p&gt;
&lt;p&gt;When using OpenTSDB with a template variable of &lt;code&gt;query&lt;/code&gt; type you can use following syntax for lookup.&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&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;metrics(prefix)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns metric names with specific prefix (can be empty)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tag_names(cpu)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns tag names (i.e. keys) for a specific cpu metric&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tag_values(cpu, hostname)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns tag values for metric cpu and tag key hostname&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;suggest_tagk(prefix)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns tag names (i.e. keys) for all metrics with specific prefix (can be empty)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;suggest_tagv(prefix)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns tag values for all metrics with specific prefix (can be empty)&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;If you do not see template variables being populated in &lt;code&gt;Preview of values&lt;/code&gt; section, you need to enable
&lt;code&gt;tsd.core.meta.enable_realtime_ts&lt;/code&gt; in the OpenTSDB server settings. Also, to populate metadata of
the existing time series data in OpenTSDB, you need to run &lt;code&gt;tsdb uid metasync&lt;/code&gt; on the OpenTSDB server.&lt;/p&gt;
&lt;h3 id=&#34;nested-templating&#34;&gt;Nested templating&lt;/h3&gt;
&lt;p&gt;One template variable can be used to filter tag values for another template variable. First parameter is the metric name,
second parameter is the tag key for which you need to find tag values, and after that all other dependent template variables.
Some examples are mentioned below to make nested template queries work successfully.&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&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;tag_values(cpu, hostname, env=$env)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Return tag values for cpu metric, selected env tag value and tag key hostname&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tag_values(cpu, hostname, env=$env, region=$region)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Return tag values for cpu metric, selected env tag value, selected region tag value and tag key hostname&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;For details on OpenTSDB metric queries, check out the official &lt;a href=&#34;http://opentsdb.net/docs/build/html/index.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OpenTSDB documentation&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;configure-the-data-source-with-provisioning&#34;&gt;Configure the data source with provisioning&lt;/h2&gt;
&lt;p&gt;It&amp;rsquo;s now possible to configure data sources using config files with Grafana&amp;rsquo;s provisioning system. You can read more about how it works and all the settings you can set for data sources on the &lt;a href=&#34;../../administration/provisioning/#datasources&#34;&gt;provisioning docs page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here are some provisioning examples for this data source.&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: OpenTsdb
    type: opentsdb
    access: proxy
    url: http://localhost:4242
    jsonData:
      tsdbResolution: 1
      tsdbVersion: 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="using-opentsdb-in-grafana">Using OpenTSDB in Grafana&lt;/h1>
&lt;p>Grafana ships with advanced support for OpenTSDB. This topic explains options, variables, querying, and other options specific to the OpenTSDB data source. Refer to &lt;a href="../add-a-data-source/">Add a data source&lt;/a> for instructions on how to add a data source to Grafana. Only users with the organization admin role can add data sources.&lt;/p></description></item><item><title>PostgreSQL</title><link>https://grafana.com/docs/grafana/v8.4/datasources/postgres/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/postgres/</guid><content><![CDATA[&lt;h1 id=&#34;postgresql-data-source&#34;&gt;PostgreSQL data source&lt;/h1&gt;
&lt;p&gt;Grafana ships with a built-in PostgreSQL data source plugin that allows you to query and visualize data from a PostgreSQL compatible database. This topic explains options, variables, querying, and other options specific to this data source. For instructions about how to add a data source to Grafana, refer to &lt;a href=&#34;../add-a-data-source/&#34;&gt;Add a data source&lt;/a&gt;. Only users with the organization admin role can add data sources.&lt;/p&gt;
&lt;h2 id=&#34;postgresql-settings&#34;&gt;PostgreSQL settings&lt;/h2&gt;
&lt;p&gt;To access PostgreSQL settings, hover your mouse over the &lt;strong&gt;Configuration&lt;/strong&gt; (gear) icon, then click &lt;strong&gt;Data Sources&lt;/strong&gt;, and then click the PostgreSQL data source.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The data source name. This is how you refer to the data source in panels and queries.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Default&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Default data source means that it will be pre-selected for new panels.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Host&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The IP address/hostname and optional port of your PostgreSQL instance. &lt;em&gt;Do not&lt;/em&gt; include the database name. The connection string for connecting to Postgres will not be correct and it may cause errors.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Database&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Name of your PostgreSQL database.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;User&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Database user&amp;rsquo;s login/username&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Password&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Database user&amp;rsquo;s password&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;SSL Mode&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server. When SSL Mode is disabled, SSL Method and Auth Details would not be visible.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;SSL Auth Details Method&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Determines whether the SSL Auth details will be configured as a file path or file content. Grafana v7.5&#43;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;SSL Auth Details Value&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;File path or file content of SSL root certificate, client certificate and client key&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Max open&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The maximum number of open connections to the database, default &lt;code&gt;unlimited&lt;/code&gt; (Grafana v5.4&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Max idle&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The maximum number of connections in the idle connection pool, default &lt;code&gt;2&lt;/code&gt; (Grafana v5.4&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Max lifetime&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The maximum amount of time in seconds a connection may be reused, default &lt;code&gt;14400&lt;/code&gt;/4 hours (Grafana v5.4&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Version&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Determines which functions are available in the query builder (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;TimescaleDB&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A time-series database built as a PostgreSQL extension. When enabled, Grafana uses &lt;code&gt;time_bucket&lt;/code&gt; in the &lt;code&gt;$__timeGroup&lt;/code&gt; macro to display TimescaleDB specific aggregate functions in the query builder (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;min-time-interval&#34;&gt;Min time interval&lt;/h3&gt;
&lt;p&gt;A lower limit for the &lt;a href=&#34;../../variables/variable-types/global-variables/#__interval&#34;&gt;$__interval&lt;/a&gt; and &lt;a href=&#34;../../variables/variable-types/global-variables/#__interval_ms&#34;&gt;$__interval_ms&lt;/a&gt; variables.
Recommended to be set to write frequency, for example &lt;code&gt;1m&lt;/code&gt; if your data is written every minute.
This option can also be overridden/configured in a dashboard panel under data source options. It&amp;rsquo;s important to note that this value &lt;strong&gt;needs&lt;/strong&gt; to be formatted as a
number followed by a valid time identifier, e.g. &lt;code&gt;1m&lt;/code&gt; (1 minute) or &lt;code&gt;30s&lt;/code&gt; (30 seconds). The following time identifiers are supported:&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;Identifier&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;y&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;year&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;M&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;month&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;w&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;week&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;d&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;day&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;h&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;hour&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;m&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;minute&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;s&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;second&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ms&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;millisecond&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;database-user-permissions-important&#34;&gt;Database user permissions (Important!)&lt;/h3&gt;
&lt;p&gt;The database user you specify when you add the data source should only be granted SELECT permissions on
the specified database and tables you want to query. Grafana does not validate that the query is safe. The query
could include any SQL statement. For example, statements like &lt;code&gt;DELETE FROM user;&lt;/code&gt; and &lt;code&gt;DROP TABLE user;&lt;/code&gt; would be
executed. To protect against this we &lt;strong&gt;highly&lt;/strong&gt; recommend you create a specific PostgreSQL user with restricted permissions.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt; CREATE USER grafanareader WITH PASSWORD &amp;#39;password&amp;#39;;
 GRANT USAGE ON SCHEMA schema TO grafanareader;
 GRANT SELECT ON schema.table TO grafanareader;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Make sure the user does not get any unwanted privileges from the public role.&lt;/p&gt;
&lt;h2 id=&#34;query-editor&#34;&gt;Query editor&lt;/h2&gt;
&lt;div class=&#34;screenshot&#34; style=&#34;max-width:&#34;&gt;
  &lt;a href=&#34;/static/img/docs/v53/postgres_query.gif&#34; title=&#34;&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==&#34;
         data-src=&#34;/static/img/docs/v53/postgres_query_still.png&#34; class=&#34;screenshot__still lazyload&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;/static/img/docs/v53/postgres_query.gif&#34; class=&#34;screenshot__animated-gif&#34;&gt;
    &lt;div class=&#34;screenshot__play&#34;&gt;
      &lt;i class=&#34;fa fa-play&#34;&gt;&lt;/i&gt;
    &lt;/div&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;You find the PostgreSQL query editor in the metrics tab in Graph or Singlestat panel&amp;rsquo;s edit mode. You enter edit mode by clicking the
panel title, then edit.&lt;/p&gt;
&lt;p&gt;The query editor has a link named &lt;code&gt;Generated SQL&lt;/code&gt; that shows up after a query has been executed, while in panel edit mode. Click on it and it will expand and show the raw interpolated SQL string that was executed.&lt;/p&gt;
&lt;h3 id=&#34;select-table-time-column-and-metric-column-from&#34;&gt;Select table, time column and metric column (FROM)&lt;/h3&gt;
&lt;p&gt;When you enter edit mode for the first time or add a new query Grafana will try to prefill the query builder with the first table that has a timestamp column and a numeric column.&lt;/p&gt;
&lt;p&gt;In the FROM field, Grafana will suggest tables that are in the &lt;code&gt;search_path&lt;/code&gt; of the database user. To select a table or view not in your &lt;code&gt;search_path&lt;/code&gt;
you can manually enter a fully qualified name (schema.table) like &lt;code&gt;public.metrics&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The Time column field refers to the name of the column holding your time values. Selecting a value for the Metric column field is optional. If a value is selected, the Metric column field will be used as the series name.&lt;/p&gt;
&lt;p&gt;The metric column suggestions will only contain columns with a text datatype (char,varchar,text).
If you want to use a column with a different datatype as metric column you may enter the column name with a cast: &lt;code&gt;ip::text&lt;/code&gt;.
You may also enter arbitrary SQL expressions in the metric column field that evaluate to a text datatype like
&lt;code&gt;hostname || &#39; &#39; || container_name&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;columns-window-and-aggregation-functions-select&#34;&gt;Columns, window, and aggregation functions (SELECT)&lt;/h3&gt;
&lt;p&gt;In the &lt;code&gt;SELECT&lt;/code&gt; row you can specify what columns and functions you want to use.
In the column field you may write arbitrary expressions instead of a column name like &lt;code&gt;column1 * column2 / column3&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The available functions in the query editor depend on the PostgreSQL version you selected when configuring the data source.
If you use aggregate functions you need to group your resultset. The editor will automatically add a &lt;code&gt;GROUP BY time&lt;/code&gt; if you add an aggregate function.&lt;/p&gt;
&lt;p&gt;The editor tries to simplify and unify this part of the query. For example:&lt;br&gt;
&lt;img
  class=&#34;lazyload&#34;
  data-src=&#34;/static/img/docs/v53/postgres_select_editor.png&#34;
  alt=&#34;&#34; width=&#34;478&#34;
     height=&#34;40&#34;/&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The above will generate the following PostgreSQL &lt;code&gt;SELECT&lt;/code&gt; clause:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;avg(tx_bytes) OVER (ORDER BY &amp;#34;time&amp;#34; ROWS 5 PRECEDING) AS &amp;#34;tx_bytes&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You may add further value columns by clicking the plus button and selecting &lt;code&gt;Column&lt;/code&gt; from the menu. Multiple value columns will be plotted as separate series in the graph panel.&lt;/p&gt;
&lt;h3 id=&#34;filter-data-where&#34;&gt;Filter data (WHERE)&lt;/h3&gt;
&lt;p&gt;To add a filter click the plus icon to the right of the &lt;code&gt;WHERE&lt;/code&gt; condition. You can remove filters by clicking on
the filter and selecting &lt;code&gt;Remove&lt;/code&gt;. A filter for the current selected timerange is automatically added to new queries.&lt;/p&gt;
&lt;h3 id=&#34;group-by&#34;&gt;Group by&lt;/h3&gt;
&lt;p&gt;To group by time or any other columns click the plus icon at the end of the GROUP BY row. The suggestion dropdown will only show text columns of your currently selected table but you may manually enter any column.
You can remove the group by clicking on the item and then selecting &lt;code&gt;Remove&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you add any grouping, all selected columns need to have an aggregate function applied. The query builder will automatically add aggregate functions to all columns without aggregate functions when you add groupings.&lt;/p&gt;
&lt;h4 id=&#34;gap-filling&#34;&gt;Gap filling&lt;/h4&gt;
&lt;p&gt;Grafana can fill in missing values when you group by time. The time function accepts two arguments. The first argument is the time window that you would like to group by, and the second argument is the value you want Grafana to fill missing items with.&lt;/p&gt;
&lt;h3 id=&#34;text-editor-mode-raw&#34;&gt;Text editor mode (RAW)&lt;/h3&gt;
&lt;p&gt;You can switch to the raw query editor mode by clicking the hamburger icon and selecting &lt;code&gt;Switch editor mode&lt;/code&gt; or by clicking &lt;code&gt;Edit SQL&lt;/code&gt; below the query.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you use the raw query editor, be sure your query at minimum has &lt;code&gt;ORDER BY time&lt;/code&gt; and a filter on the returned time range.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;macros&#34;&gt;Macros&lt;/h2&gt;
&lt;p&gt;Macros can be used within a query to simplify syntax and allow for dynamic parts.&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;Macro example&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__time(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by an expression to convert to a UNIX timestamp and rename the column to &lt;code&gt;time_sec&lt;/code&gt;. For example, &lt;em&gt;UNIX_TIMESTAMP(dateColumn) as time_sec&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeEpoch(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by an expression to convert to a UNIX timestamp and rename the column to &lt;code&gt;time_sec&lt;/code&gt;. For example, &lt;em&gt;UNIX_TIMESTAMP(dateColumn) as time_sec&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeFilter(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by a time range filter using the specified column name. For example, &lt;em&gt;dateColumn BETWEEN FROM_UNIXTIME(1494410783) AND FROM_UNIXTIME(1494410983)&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeFrom()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the start of the currently active time selection. For example, &lt;em&gt;FROM_UNIXTIME(1494410783)&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeTo()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the end of the currently active time selection. For example, &lt;em&gt;FROM_UNIXTIME(1494410983)&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroup(dateColumn,&#39;5m&#39;)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by an expression usable in GROUP BY clause. For example, *cast(cast(UNIX_TIMESTAMP(dateColumn)/(300) as signed)*300 as signed),*&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroup(dateColumn,&#39;5m&#39;, 0)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as above but with a fill parameter so missing points in that series will be added by grafana and 0 will be used as value.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroup(dateColumn,&#39;5m&#39;, NULL)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as above but NULL will be used as value for missing points.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroup(dateColumn,&#39;5m&#39;, previous)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as above but the previous value in that series will be used as fill value if no value has been seen yet NULL will be used (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__timeGroupAlias(dateColumn,&#39;5m&#39;)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced identical to $__timeGroup but with an added column alias (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochFilter(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by a time range filter using the specified column name with times represented as Unix timestamp. For example, &lt;em&gt;dateColumn &amp;gt; 1494410783 AND dateColumn &amp;lt; 1494497183&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochFrom()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the start of the currently active time selection as Unix timestamp. For example, &lt;em&gt;1494410783&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochTo()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the end of the currently active time selection as Unix timestamp. For example, &lt;em&gt;1494497183&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochNanoFilter(dateColumn)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by a time range filter using the specified column name with times represented as nanosecond timestamp. For example, &lt;em&gt;dateColumn &amp;gt; 1494410783152415214 AND dateColumn &amp;lt; 1494497183142514872&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochNanoFrom()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the start of the currently active time selection as nanosecond timestamp. For example, &lt;em&gt;1494410783152415214&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochNanoTo()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by the end of the currently active time selection as nanosecond timestamp. For example, &lt;em&gt;1494497183142514872&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochGroup(dateColumn,&#39;5m&#39;, [fillmode])&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as $__timeGroup but for times stored as Unix timestamp (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;$__unixEpochGroupAlias(dateColumn,&#39;5m&#39;, [fillmode])&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Same as above but also adds a column alias (only available in Grafana 5.3&#43;).&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;We plan to add many more macros. If you have suggestions for what macros you would like to see, please &lt;a href=&#34;https://github.com/grafana/grafana&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;open an issue&lt;/a&gt; in our GitHub repo.&lt;/p&gt;
&lt;h2 id=&#34;table-queries&#34;&gt;Table queries&lt;/h2&gt;
&lt;p&gt;If the &lt;code&gt;Format as&lt;/code&gt; query option is set to &lt;code&gt;Table&lt;/code&gt; then you can basically do any type of SQL query. The table panel will automatically show the results of whatever columns and rows your query returns.&lt;/p&gt;
&lt;p&gt;Query editor with example query:&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload&#34;
  data-src=&#34;/static/img/docs/v46/postgres_table_query.png&#34;
  alt=&#34;&#34; width=&#34;1195&#34;
     height=&#34;336&#34;/&gt;&lt;/p&gt;
&lt;p&gt;The query:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  title as &amp;#34;Title&amp;#34;,
  &amp;#34;user&amp;#34;.login as &amp;#34;Created By&amp;#34;,
  dashboard.created as &amp;#34;Created On&amp;#34;
FROM dashboard
INNER JOIN &amp;#34;user&amp;#34; on &amp;#34;user&amp;#34;.id = dashboard.created_by
WHERE $__timeFilter(dashboard.created)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can control the name of the Table panel columns by using regular &lt;code&gt;as &lt;/code&gt; SQL column selection syntax.&lt;/p&gt;
&lt;p&gt;The resulting table panel:&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/v46/postgres_table.png&#34;
  alt=&#34;postgres table&#34; width=&#34;531&#34;
     height=&#34;239&#34;/&gt;&lt;/p&gt;
&lt;h2 id=&#34;time-series-queries&#34;&gt;Time series queries&lt;/h2&gt;
&lt;p&gt;If you set Format as to &lt;em&gt;Time series&lt;/em&gt;, then the query must have a column named time that returns either a SQL datetime or any numeric datatype representing Unix epoch in seconds. In addition, result sets of time series queries must be sorted by time for panels to properly visualize the result.&lt;/p&gt;
&lt;p&gt;A time series query result is returned in a &lt;a href=&#34;/developers/plugin-tools/introduction/data-frames#wide-format&#34;&gt;wide data frame format&lt;/a&gt;. Any column except time or of type string transforms into value fields in the data frame query result. Any string column transforms into field labels in the data frame query result.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;For backward compatibility, there&amp;rsquo;s an exception to the above rule for queries that return three columns including a string column named metric. Instead of transforming the metric column into field labels, it becomes the field name, and then the series name is formatted as the value of the metric column. See the example with the metric column below.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;You can optionally customize the default series name formatting using instructions in &lt;a href=&#34;../../panels/reference-standard-field-definitions/#display-name&#34;&gt;Reference: Standard field definitions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example with &lt;code&gt;metric&lt;/code&gt; column:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  $__timeGroup(&amp;#34;time_date_time&amp;#34;,&amp;#39;5m&amp;#39;),
  min(&amp;#34;value_double&amp;#34;),
  &amp;#39;min&amp;#39; as metric
FROM test_data
WHERE $__timeFilter(&amp;#34;time_date_time&amp;#34;)
GROUP BY time
ORDER BY time&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Data frame result:&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;text&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-text&#34;&gt;&amp;#43;---------------------&amp;#43;-----------------&amp;#43;
| Name: time          | Name: min       |
| Labels:             | Labels:         |
| Type: []time.Time   | Type: []float64 |
&amp;#43;---------------------&amp;#43;-----------------&amp;#43;
| 2020-01-02 03:05:00 | 3               |
| 2020-01-02 03:10:00 | 6               |
&amp;#43;---------------------&amp;#43;-----------------&amp;#43;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example using the fill parameter in the $__timeGroup macro to convert null values to be zero instead:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  $__timeGroup(&amp;#34;createdAt&amp;#34;,&amp;#39;5m&amp;#39;,0),
  sum(value) as value,
  hostname
FROM test_data
WHERE
  $__timeFilter(&amp;#34;createdAt&amp;#34;)
GROUP BY time, hostname
ORDER BY time&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Given the data frame result in the following example and using the graph panel, you will get two series named &lt;em&gt;value 10.0.1.1&lt;/em&gt; and &lt;em&gt;value 10.0.1.2&lt;/em&gt;. To render the series with a name of &lt;em&gt;10.0.1.1&lt;/em&gt; and &lt;em&gt;10.0.1.2&lt;/em&gt; , use a &lt;a href=&#34;../../panels/reference-standard-field-definitions/#display-name&#34;&gt;Reference: Standard field definitions&lt;/a&gt; display value of &lt;code&gt;${__field.labels.hostname}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Data frame result:&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;text&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-text&#34;&gt;&amp;#43;---------------------&amp;#43;---------------------------&amp;#43;---------------------------&amp;#43;
| Name: time          | Name: value               | Name: value               |
| Labels:             | Labels: hostname=10.0.1.1 | Labels: hostname=10.0.1.2 |
| Type: []time.Time   | Type: []float64           | Type: []float64           |
&amp;#43;---------------------&amp;#43;---------------------------&amp;#43;---------------------------&amp;#43;
| 2020-01-02 03:05:00 | 3                         | 4                         |
| 2020-01-02 03:10:00 | 6                         | 7                         |
&amp;#43;---------------------&amp;#43;---------------------------&amp;#43;---------------------------&amp;#43;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example with multiple columns:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  $__timeGroup(&amp;#34;time_date_time&amp;#34;,&amp;#39;5m&amp;#39;),
  min(&amp;#34;value_double&amp;#34;) as &amp;#34;min_value&amp;#34;,
  max(&amp;#34;value_double&amp;#34;) as &amp;#34;max_value&amp;#34;
FROM test_data
WHERE $__timeFilter(&amp;#34;time_date_time&amp;#34;)
GROUP BY time
ORDER BY time&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Data frame result:&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;text&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-text&#34;&gt;&amp;#43;---------------------&amp;#43;-----------------&amp;#43;-----------------&amp;#43;
| Name: time          | Name: min_value | Name: max_value |
| Labels:             | Labels:         | Labels:         |
| Type: []time.Time   | Type: []float64 | Type: []float64 |
&amp;#43;---------------------&amp;#43;-----------------&amp;#43;-----------------&amp;#43;
| 2020-01-02 03:04:00 | 3               | 4               |
| 2020-01-02 03:05:00 | 6               | 7               |
&amp;#43;---------------------&amp;#43;-----------------&amp;#43;-----------------&amp;#43;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;templating&#34;&gt;Templating&lt;/h2&gt;
&lt;p&gt;Instead of hard-coding things like server, application and sensor name in your metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns make it easy to change the data being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Refer to &lt;a href=&#34;../../variables/&#34;&gt;Templates and variables&lt;/a&gt; for an introduction to the templating feature and the different types of template variables.&lt;/p&gt;
&lt;h3 id=&#34;query-variable&#34;&gt;Query variable&lt;/h3&gt;
&lt;p&gt;If you add a template variable of the type &lt;code&gt;Query&lt;/code&gt;, you can write a PostgreSQL query that can
return things like measurement names, key names or key values that are shown as a dropdown select box.&lt;/p&gt;
&lt;p&gt;For example, you can have a variable that contains all values for the &lt;code&gt;hostname&lt;/code&gt; column in a table if you specify a query like this in the templating variable &lt;em&gt;Query&lt;/em&gt; setting.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT hostname FROM host&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;A query can return multiple columns and Grafana will automatically create a list from them. For example, the query below will return a list with values from &lt;code&gt;hostname&lt;/code&gt; and &lt;code&gt;hostname2&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT host.hostname, other_host.hostname2 FROM host JOIN other_host ON host.city = other_host.city&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To use time range dependent macros like &lt;code&gt;$__timeFilter(column)&lt;/code&gt; in your query the refresh mode of the template variable needs to be set to &lt;em&gt;On Time Range Change&lt;/em&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT event_name FROM event_log WHERE $__timeFilter(time_column)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Another option is a query that can create a key/value variable. The query should return two columns that are named &lt;code&gt;__text&lt;/code&gt; and &lt;code&gt;__value&lt;/code&gt;. The &lt;code&gt;__text&lt;/code&gt; column value should be unique (if it is not unique then the first value is used). The options in the dropdown will have a text and value that allows you to have a friendly name as text and an id as the value. An example query with &lt;code&gt;hostname&lt;/code&gt; as the text and &lt;code&gt;id&lt;/code&gt; as the value:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT hostname AS __text, id AS __value FROM host&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can also create nested variables. Using a variable named &lt;code&gt;region&lt;/code&gt;, you could have
the hosts variable only show hosts from the current selected region with a query like this (if &lt;code&gt;region&lt;/code&gt; is a multi-value variable then use the &lt;code&gt;IN&lt;/code&gt; comparison operator rather than &lt;code&gt;=&lt;/code&gt; to match against multiple values):&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT hostname FROM host  WHERE region IN($region)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;using-__searchfilter-to-filter-results-in-query-variable&#34;&gt;Using &lt;code&gt;__searchFilter&lt;/code&gt; to filter results in Query Variable&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;Available from Grafana 6.5 and above&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Using &lt;code&gt;__searchFilter&lt;/code&gt; in the query field will filter the query result based on what the user types in the dropdown select box.
When nothing has been entered by the user the default value for &lt;code&gt;__searchFilter&lt;/code&gt; is &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Important that you surround the &lt;code&gt;__searchFilter&lt;/code&gt; expression with quotes as Grafana does not do this for you.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The example below shows how to use &lt;code&gt;__searchFilter&lt;/code&gt; as part of the query field to enable searching for &lt;code&gt;hostname&lt;/code&gt; while the user types in the dropdown select box.&lt;/p&gt;
&lt;p&gt;Query&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT hostname FROM my_host  WHERE hostname LIKE &amp;#39;$__searchFilter&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;using-variables-in-queries&#34;&gt;Using Variables in Queries&lt;/h3&gt;
&lt;p&gt;From Grafana 4.3.0 to 4.6.0, template variables are always quoted automatically. If your template variables are strings, do not wrap them in quotes in where clauses.&lt;/p&gt;
&lt;p&gt;From Grafana 4.7.0, template variable values are only quoted when the template variable is a &lt;code&gt;multi-value&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If the variable is a multi-value variable then use the &lt;code&gt;IN&lt;/code&gt; comparison operator rather than &lt;code&gt;=&lt;/code&gt; to match against multiple values.&lt;/p&gt;
&lt;p&gt;There are two syntaxes:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;$&amp;lt;varname&amp;gt;&lt;/code&gt; Example with a template variable named &lt;code&gt;hostname&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  atimestamp as time,
  aint as value
FROM table
WHERE $__timeFilter(atimestamp) and hostname in($hostname)
ORDER BY atimestamp ASC&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;code&gt;[[varname]]&lt;/code&gt; Example with a template variable named &lt;code&gt;hostname&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  atimestamp as time,
  aint as value
FROM table
WHERE $__timeFilter(atimestamp) and hostname in([[hostname]])
ORDER BY atimestamp ASC&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;disabling-quoting-for-multi-value-variables&#34;&gt;Disabling quoting for multi-value variables&lt;/h4&gt;
&lt;p&gt;Grafana automatically creates a quoted, comma-separated string for multi-value variables. For example: if &lt;code&gt;server01&lt;/code&gt; and &lt;code&gt;server02&lt;/code&gt; are selected then it will be formatted as: &lt;code&gt;&#39;server01&#39;, &#39;server02&#39;&lt;/code&gt;. To disable quoting, use the csv formatting option for variables:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;${servers:csv}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Read more about variable formatting options in the &lt;a href=&#34;../../variables/#advanced-formatting-options&#34;&gt;Variables&lt;/a&gt; documentation.&lt;/p&gt;
&lt;h2 id=&#34;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;../../dashboards/annotations/&#34;&gt;Annotations&lt;/a&gt; allow you to overlay rich event information on top of graphs. You add annotation queries via the Dashboard menu / Annotations view.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example query using time column with epoch values:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  epoch_time as time,
  metric1 as text,
  concat_ws(&amp;#39;, &amp;#39;, metric1::text, metric2::text) as tags
FROM
  public.test_data
WHERE
  $__unixEpochFilter(epoch_time)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example region query using time and timeend columns with epoch values:&lt;/strong&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Only available in Grafana v6.6&#43;.&lt;/p&gt;&lt;/blockquote&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  epoch_time as time,
  epoch_time_end as timeend,
  metric1 as text,
  concat_ws(&amp;#39;, &amp;#39;, metric1::text, metric2::text) as tags
FROM
  public.test_data
WHERE
  $__unixEpochFilter(epoch_time)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example query using time column of native SQL date/time data type:&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;SQL&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sql&#34;&gt;SELECT
  native_date_time as time,
  metric1 as text,
  concat_ws(&amp;#39;, &amp;#39;, metric1::text, metric2::text) as tags
FROM
  public.test_data
WHERE
  $__timeFilter(native_date_time)&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;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;time&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The name of the date/time field. Could be a column with a native SQL date/time data type or epoch value.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;timeend&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Optional name of the end date/time field. Could be a column with a native SQL date/time data type or epoch value. (Grafana v6.6&#43;)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;text&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Event description field.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tags&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Optional field name to use for event tags as a comma separated string.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;alerting&#34;&gt;Alerting&lt;/h2&gt;
&lt;p&gt;Time series queries should work in alerting conditions. Table formatted queries are not yet supported in alert rule
conditions.&lt;/p&gt;
&lt;h2 id=&#34;configure-the-data-source-with-provisioning&#34;&gt;Configure the data source with provisioning&lt;/h2&gt;
&lt;p&gt;It&amp;rsquo;s now possible to configure data sources using config files with Grafana&amp;rsquo;s provisioning system. You can read more about how it works and all the settings you can set for data sources on the &lt;a href=&#34;../../administration/provisioning/#datasources&#34;&gt;provisioning docs page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here are some provisioning examples for this data source.&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: Postgres
    type: postgres
    url: localhost:5432
    database: grafana
    user: grafana
    secureJsonData:
      password: &amp;#39;Password!&amp;#39;
    jsonData:
      sslmode: &amp;#39;disable&amp;#39; # disable/require/verify-ca/verify-full
      maxOpenConns: 0 # Grafana v5.4&amp;#43;
      maxIdleConns: 2 # Grafana v5.4&amp;#43;
      connMaxLifetime: 14400 # Grafana v5.4&amp;#43;
      postgresVersion: 903 # 903=9.3, 904=9.4, 905=9.5, 906=9.6, 1000=10
      timescaledb: false&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In the above code, the &lt;code&gt;postgresVersion&lt;/code&gt; value of &lt;code&gt;10&lt;/code&gt; refers to version PotgreSQL 10 and above.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;If you encounter metric request errors or other issues:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Make sure your data source YAML file parameters exactly match the example. This includes parameter names and use of quotation marks.&lt;/li&gt;
&lt;li&gt;Make sure the &lt;code&gt;database&lt;/code&gt; name is not included in the &lt;code&gt;url&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="postgresql-data-source">PostgreSQL data source&lt;/h1>
&lt;p>Grafana ships with a built-in PostgreSQL data source plugin that allows you to query and visualize data from a PostgreSQL compatible database. This topic explains options, variables, querying, and other options specific to this data source. For instructions about how to add a data source to Grafana, refer to &lt;a href="../add-a-data-source/">Add a data source&lt;/a>. Only users with the organization admin role can add data sources.&lt;/p></description></item><item><title>Prometheus</title><link>https://grafana.com/docs/grafana/v8.4/datasources/prometheus/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/prometheus/</guid><content><![CDATA[&lt;h1 id=&#34;prometheus-data-source&#34;&gt;Prometheus data source&lt;/h1&gt;
&lt;p&gt;Grafana includes built-in support for Prometheus. This topic explains options, variables, querying, and other options specific to the Prometheus data source. Refer to &lt;a href=&#34;../add-a-data-source/&#34;&gt;Add a data source&lt;/a&gt; for instructions on how to add a data source to Grafana. Only users with the organization admin role can add data sources.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You can use &lt;a href=&#34;/products/cloud/features/#cloud-logs&#34;&gt;Grafana Cloud&lt;/a&gt; to avoid the overhead of installing, maintaining, and scaling your observability stack. The free forever plan includes Grafana, 10K Prometheus series, 50 GB logs, and more.&lt;a href=&#34;/auth/sign-up/create-user?pg=docs-grafana-install&amp;amp;plcmt=in-text&#34;&gt;Create a free account to get started&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;prometheus-settings&#34;&gt;Prometheus settings&lt;/h2&gt;
&lt;p&gt;To access Prometheus settings, hover your mouse over the &lt;strong&gt;Configuration&lt;/strong&gt; (gear) icon, then click &lt;strong&gt;Data Sources&lt;/strong&gt;, and then click the Prometheus data source.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The data source name. This is how you refer to the data source in panels and queries.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Default&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Default data source that is pre-selected for new panels.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The URL of your Prometheus server, for example, &lt;code&gt;http://prometheus.example.org:9090&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Access&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Server (default) = URL needs to be accessible from the Grafana backend/server, Browser = URL needs to be accessible from the browser. &lt;strong&gt;Note&lt;/strong&gt;: Browser (direct) access is deprecated and will be removed in a future release.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Basic Auth&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enable basic authentication to the Prometheus data source.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;User&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;User name for basic authentication.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Password&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Password for basic authentication.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Scrape interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Set this to the typical scrape and evaluation interval configured in Prometheus. Defaults to 15s.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;HTTP method&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Use either POST or GET HTTP method to query your data source. POST is the recommended and pre-selected method as it allows bigger queries. Change this to GET if you have a Prometheus version older than 2.1 or if POST requests are restricted in your network.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Disable metrics lookup&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Checking this option will disable the metrics chooser and metric/label support in the query field&amp;rsquo;s autocomplete. This helps if you have performance issues with bigger Prometheus instances.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Custom Query Parameters&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Add custom parameters to the Prometheus query URL. For example &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;. Multiple parameters should be concatenated together with an &amp;lsquo;&amp;amp;&amp;rsquo;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Exemplars configuration&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Internal link&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enable this option is you have an internal link. When you enable this option, you will see a data source selector. Select the backend tracing data store for your exemplar data.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Data source&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;You will see this option only if you enable &lt;code&gt;Internal link&lt;/code&gt; option. Select the backend tracing data store for your exemplar data.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;URL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;You will see this option only if the &lt;code&gt;Internal link&lt;/code&gt; option is disabled. Enter the full URL of the external link. You can interpolate the value from the field with &lt;code&gt;${__value.raw }&lt;/code&gt; macro.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;URL Label&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;(Optional) add a custom display label to override the value of the &lt;code&gt;Label name&lt;/code&gt; field.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Label name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Add a name for the exemplar traceID property.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;prometheus-query-editor&#34;&gt;Prometheus query editor&lt;/h2&gt;
&lt;p&gt;Below you can find information and options for Prometheus query editor in dashboard and in Explore.&lt;/p&gt;
&lt;h3 id=&#34;query-editor-in-dashboards&#34;&gt;Query editor in dashboards&lt;/h3&gt;
&lt;p&gt;Open a graph in edit mode by clicking the title &amp;gt; Edit (or by pressing &lt;code&gt;e&lt;/code&gt; key while hovering over panel).&lt;/p&gt;
&lt;div class=&#34;screenshot&#34; style=&#34;max-width:&#34;&gt;
  &lt;a href=&#34;/static/img/docs/v45/prometheus_query_editor.gif&#34; title=&#34;&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==&#34;
         data-src=&#34;/static/img/docs/v45/prometheus_query_editor_still.png&#34; class=&#34;screenshot__still lazyload&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;/static/img/docs/v45/prometheus_query_editor.gif&#34; class=&#34;screenshot__animated-gif&#34;&gt;
    &lt;div class=&#34;screenshot__play&#34;&gt;
      &lt;i class=&#34;fa fa-play&#34;&gt;&lt;/i&gt;
    &lt;/div&gt;&lt;/a&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;Name&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;Query expression&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Prometheus query expression. For more information, refer to the &lt;a href=&#34;http://prometheus.io/docs/querying/basics/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus documentation&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Legend format&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Controls the name of the time series, using name or pattern. For example, &lt;code&gt;{{hostname}}&lt;/code&gt; is replaced by the label value for the label &lt;code&gt;hostname&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Step&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Use &amp;lsquo;Minimum&amp;rsquo; or &amp;lsquo;Maximum&amp;rsquo; step mode to set the lower or upper bounds respectively on the interval between data points. For example, set &amp;ldquo;minimum 1h&amp;rdquo; to hint that measurements are not frequent (taken hourly). Use the &amp;lsquo;Exact&amp;rsquo; step mode to set a precise interval between data points. &lt;code&gt;$__interval&lt;/code&gt; and &lt;code&gt;$__rate_interval&lt;/code&gt; are supported.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Resolution&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;1/1&lt;/code&gt; sets both the &lt;code&gt;$__interval&lt;/code&gt; variable and the &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/api/#range-queries&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;step&lt;/code&gt; parameter of Prometheus range queries&lt;/a&gt; such that each pixel corresponds to one data point. For better performance, you can pick lower resolutions. &lt;code&gt;1/2&lt;/code&gt; only retrieves a data point for every other pixel, and &lt;code&gt;1/10&lt;/code&gt; retrieves one data point per 10 pixels. Both &lt;em&gt;Min time interval&lt;/em&gt; and &lt;em&gt;Step&lt;/em&gt; limit the final value of &lt;code&gt;$__interval&lt;/code&gt; and &lt;code&gt;step&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Metric lookup&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Search for metric names in this input field.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Format as&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;You can switch between &lt;code&gt;Table&lt;/code&gt; &lt;code&gt;Time series&lt;/code&gt; or &lt;code&gt;Heatmap&lt;/code&gt; options. The &lt;code&gt;Table&lt;/code&gt; option works only in the Table panel. &lt;code&gt;Heatmap&lt;/code&gt; displays metrics of the Histogram type on a Heatmap panel. Under the hood, it converts cumulative histograms to regular ones and sorts series by the bucket bound.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Instant&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Perform an &amp;ldquo;instant&amp;rdquo; query to return only the latest value that Prometheus has scraped for the requested time series. Instant queries can return results much faster than normal range queries. Use them to look up label sets.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Min time interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;This value multiplied by the denominator from the &lt;em&gt;Resolution&lt;/em&gt; setting sets a lower limit to both the &lt;code&gt;$__interval&lt;/code&gt; variable and the &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/api/#range-queries&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;step&lt;/code&gt; parameter of Prometheus range queries&lt;/a&gt;. Defaults to &lt;em&gt;Scrape interval&lt;/em&gt; as specified in the data source options.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Exemplars&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Run and show exemplars in the graph.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Grafana modifies the request dates for queries to align them with the dynamically calculated step. This ensures consistent display of metrics data, but it can result in a small gap of data at the right edge of a graph.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h4 id=&#34;instant-queries-in-dashboards&#34;&gt;Instant queries in dashboards&lt;/h4&gt;
&lt;p&gt;The Prometheus data source allows you to run &amp;ldquo;instant&amp;rdquo; queries, which query only the latest value.
You can visualize the results in a table panel to see all available labels of a timeseries.&lt;/p&gt;
&lt;p&gt;Instant query results are made up only of one data point per series but can be shown in the graph panel with the help of &lt;a href=&#34;../../visualizations/graph-panel/#series-overrides&#34;&gt;series overrides&lt;/a&gt;.
To show them in the graph as a latest value point, add a series override and select &lt;code&gt;Points &amp;gt; true&lt;/code&gt;.
To show a horizontal line across the whole graph, add a series override and select &lt;code&gt;Transform &amp;gt; constant&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Support for constant series overrides is available from Grafana v6.4&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3 id=&#34;query-editor-in-explore&#34;&gt;Query editor in Explore&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Query expression&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Prometheus query expression, check out the &lt;a href=&#34;http://prometheus.io/docs/querying/basics/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus documentation&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Step&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/api/#range-queries&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;Step&lt;/code&gt; parameter of Prometheus range queries&lt;/a&gt;. Time units can be used here, for example: 5s, 1m, 3h, 1d, 1y. Default unit if no unit specified is &lt;code&gt;s&lt;/code&gt; (seconds).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Query type&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;Range&lt;/code&gt;, &lt;code&gt;Instant&lt;/code&gt;, or &lt;code&gt;Both&lt;/code&gt;. When running &lt;strong&gt;Range query&lt;/strong&gt;, the result of the query is displayed in graph and table. Instant query returns only the latest value that Prometheus has scraped for the requested time series and it is displayed in the table. When &lt;strong&gt;Both&lt;/strong&gt; is selected, both instant query and range query is run. Result of range query is displayed in graph and the result of instant query is displayed in the table.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Exemplars&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Run and show exemplars in the graph.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;metrics-browser&#34;&gt;Metrics browser&lt;/h3&gt;
&lt;p&gt;The metrics browser allows you to quickly find metrics and select relevant labels to build basic queries.
When you open the browser you will see all available metrics and labels.
If supported by your Prometheus instance, each metric will show its HELP and TYPE as a tooltip.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 800px;&#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/v8/prometheus_metrics_browser.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/v8/prometheus_metrics_browser.png&#34;data-srcset=&#34;/static/img/docs/v8/prometheus_metrics_browser.png?w=320 320w, /static/img/docs/v8/prometheus_metrics_browser.png?w=550 550w, /static/img/docs/v8/prometheus_metrics_browser.png?w=750 750w, /static/img/docs/v8/prometheus_metrics_browser.png?w=900 900w, /static/img/docs/v8/prometheus_metrics_browser.png?w=1040 1040w, /static/img/docs/v8/prometheus_metrics_browser.png?w=1240 1240w, /static/img/docs/v8/prometheus_metrics_browser.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the metrics browser for Prometheus&#34;width=&#34;1744&#34;height=&#34;1198&#34;title=&#34;Screenshot of the metrics browser for Prometheus&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v8/prometheus_metrics_browser.png&#34;
            alt=&#34;Screenshot of the metrics browser for Prometheus&#34;width=&#34;1744&#34;height=&#34;1198&#34;title=&#34;Screenshot of the metrics browser for Prometheus&#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;Screenshot of the metrics browser for Prometheus&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;When you select a metric, the browser narrows down the available labels to show only the ones applicable to the metric.
You can then select one or more labels for which the available label values are shown in lists in the bottom section.
Select one or more values for each label to tighten your query scope.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you do not remember a metric name to start with, you can also select a few labels first, to narrow down the list and then find relevant label values.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;All lists in the metrics browser have a search field above them to quickly filter for metrics or labels that match a certain string. The values section only has one search field. Its filtering applies to all labels to help you find values across labels once they have been selected, for example, among your labels &lt;code&gt;app&lt;/code&gt;, &lt;code&gt;job&lt;/code&gt;, &lt;code&gt;job_name&lt;/code&gt; only one might with the value you are looking for.&lt;/p&gt;
&lt;p&gt;Once you are satisfied with your query, click &amp;ldquo;Use query&amp;rdquo; to run the query. The button &amp;ldquo;Use as rate query&amp;rdquo; adds a &lt;code&gt;rate(...)[$__interval]&lt;/code&gt; around your query to help write queries for counter metrics.
The &amp;ldquo;Validate selector&amp;rdquo; button will check with Prometheus how many time series are available for that selector.&lt;/p&gt;
&lt;h4 id=&#34;limitations&#34;&gt;Limitations&lt;/h4&gt;
&lt;p&gt;The metrics browser has a hard limit of 10,000 labels (keys) and 50,000 label values (including metric names). If your Prometheus instance returns more results, the browser will continue functioning. However, the result sets will be cut off above those maximum limits.&lt;/p&gt;
&lt;h2 id=&#34;templating&#34;&gt;Templating&lt;/h2&gt;
&lt;p&gt;Instead of hard-coding things like server, application and sensor name in your metric queries, you can use variables in their place.
Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns make it easy to change the data
being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Check out the &lt;a href=&#34;../../variables/&#34;&gt;Templating&lt;/a&gt; documentation for an introduction to the templating feature and the different
types of template variables.&lt;/p&gt;
&lt;h3 id=&#34;query-variable&#34;&gt;Query variable&lt;/h3&gt;
&lt;p&gt;Variable of the type &lt;em&gt;Query&lt;/em&gt; allows you to query Prometheus for a list of metrics, labels or label values. The Prometheus data source plugin
provides the following functions you can use in the &lt;code&gt;Query&lt;/code&gt; input field.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Used API endpoints&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;label_names()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of label names.&lt;/td&gt;
              &lt;td&gt;/api/v1/labels&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;label_values(label)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of label values for the &lt;code&gt;label&lt;/code&gt; in every metric.&lt;/td&gt;
              &lt;td&gt;/api/v1/label/&lt;code&gt;label&lt;/code&gt;/values&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;label_values(metric, label)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of label values for the &lt;code&gt;label&lt;/code&gt; in the specified metric.&lt;/td&gt;
              &lt;td&gt;/api/v1/series&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;metrics(metric)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of metrics matching the specified &lt;code&gt;metric&lt;/code&gt; regex.&lt;/td&gt;
              &lt;td&gt;/api/v1/label/__name__/values&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;query_result(query)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of Prometheus query result for the &lt;code&gt;query&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;/api/v1/query&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;For details of what &lt;em&gt;metric names&lt;/em&gt;, &lt;em&gt;label names&lt;/em&gt; and &lt;em&gt;label values&lt;/em&gt; are please 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 documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;using-interval-and-range-variables&#34;&gt;Using interval and range variables&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;Support for &lt;code&gt;$__range&lt;/code&gt;, &lt;code&gt;$__range_s&lt;/code&gt; and &lt;code&gt;$__range_ms&lt;/code&gt; only available from Grafana v5.3&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;You can use some global built-in variables in query variables, for example, &lt;code&gt;$__interval&lt;/code&gt;, &lt;code&gt;$__interval_ms&lt;/code&gt;, &lt;code&gt;$__range&lt;/code&gt;, &lt;code&gt;$__range_s&lt;/code&gt; and &lt;code&gt;$__range_ms&lt;/code&gt;. See &lt;a href=&#34;../../variables/variable-types/global-variables/&#34;&gt;Global built-in variables&lt;/a&gt; for more information. They are convenient to use in conjunction with the &lt;code&gt;query_result&lt;/code&gt; function when you need to filter variable queries since the &lt;code&gt;label_values&lt;/code&gt; function doesn&amp;rsquo;t support queries.&lt;/p&gt;
&lt;p&gt;Make sure to set the variable&amp;rsquo;s &lt;code&gt;refresh&lt;/code&gt; trigger to be &lt;code&gt;On Time Range Change&lt;/code&gt; to get the correct instances when changing the time range on the dashboard.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example usage:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Populate a variable with the busiest 5 request instances based on average QPS over the time range shown in the dashboard:&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;Query: query_result(topk(5, sum(rate(http_requests_total[$__range])) by (instance)))
Regex: /&amp;#34;([^&amp;#34;]&amp;#43;)&amp;#34;/&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Populate a variable with the instances having a certain state over the time range shown in the dashboard, using &lt;code&gt;$__range_s&lt;/code&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;Query: query_result(max_over_time(&amp;lt;metric&amp;gt;[${__range_s}s]) != &amp;lt;state&amp;gt;)
Regex:&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;using-__rate_interval&#34;&gt;Using &lt;code&gt;$__rate_interval&lt;/code&gt;&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Available in Grafana 7.2 and above&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;code&gt;$__rate_interval&lt;/code&gt; is the recommended interval to use in the &lt;code&gt;rate&lt;/code&gt; and &lt;code&gt;increase&lt;/code&gt; functions. It will &amp;ldquo;just work&amp;rdquo; in most cases, avoiding most of the pitfalls that can occur when using a fixed interval or &lt;code&gt;$__interval&lt;/code&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;OK:       rate(http_requests_total[5m])
Better:   rate(http_requests_total[$__rate_interval])&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Details: &lt;code&gt;$__rate_interval&lt;/code&gt; is defined as max(&lt;code&gt;$__interval&lt;/code&gt; &#43; &lt;em&gt;Scrape interval&lt;/em&gt;, 4 * &lt;em&gt;Scrape interval&lt;/em&gt;), where &lt;em&gt;Scrape interval&lt;/em&gt; is the Min step setting (AKA query&lt;em&gt;interval, a setting per PromQL query) if any is set. Otherwise, the Scrape interval setting in the Prometheus data source is used. (The Min interval setting in the panel is modified by the resolution setting and therefore doesn&amp;rsquo;t have any effect on _Scrape interval&lt;/em&gt;.) &lt;a href=&#34;/blog/2020/09/28/new-in-grafana-7.2-__rate_interval-for-prometheus-rate-queries-that-just-work/&#34;&gt;This article&lt;/a&gt; contains additional details.&lt;/p&gt;
&lt;h3 id=&#34;using-variables-in-queries&#34;&gt;Using variables in queries&lt;/h3&gt;
&lt;p&gt;There are two syntaxes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;$&amp;lt;varname&amp;gt;&lt;/code&gt; Example: rate(http_requests_total{job=~&amp;quot;$job&amp;quot;}[5m])&lt;/li&gt;
&lt;li&gt;&lt;code&gt;[[varname]]&lt;/code&gt; Example: rate(http_requests_total{job=~&amp;quot;[[job]]&amp;quot;}[5m])&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of a word. When the &lt;em&gt;Multi-value&lt;/em&gt; or &lt;em&gt;Include all value&lt;/em&gt;
options are enabled, Grafana converts the labels from plain text to a regex compatible string. Which means you have to use &lt;code&gt;=~&lt;/code&gt; instead of &lt;code&gt;=&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;ad-hoc-filters-variable&#34;&gt;Ad hoc filters variable&lt;/h3&gt;
&lt;p&gt;Prometheus supports the special &lt;a href=&#34;../../variables/variable-types/add-ad-hoc-filters/&#34;&gt;ad hoc filters&lt;/a&gt; variable type. It allows you to specify any number of label/value filters on the fly. These filters are automatically
applied to all your Prometheus queries.&lt;/p&gt;
&lt;h2 id=&#34;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;../../dashboards/annotations/&#34;&gt;Annotations&lt;/a&gt; allow you to overlay rich event information on top of graphs. You add annotation
queries via the Dashboard menu / Annotations view.&lt;/p&gt;
&lt;p&gt;Prometheus supports two ways to query annotations.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A regular metric query&lt;/li&gt;
&lt;li&gt;A Prometheus query for pending and firing alerts (for details see &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/#inspecting-alerts-during-runtime&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Inspecting alerts during runtime&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The step option is useful to limit the number of events returned from your query.&lt;/p&gt;
&lt;h2 id=&#34;get-grafana-metrics-into-prometheus&#34;&gt;Get Grafana metrics into Prometheus&lt;/h2&gt;
&lt;p&gt;Grafana exposes metrics for Prometheus on the &lt;code&gt;/metrics&lt;/code&gt; endpoint. We also bundle a dashboard within Grafana so you can get started viewing your metrics faster. You can import the bundled dashboard by going to the data source edit page and click the dashboard tab. There you can find a dashboard for Grafana and one for Prometheus. Import and start viewing all the metrics!&lt;/p&gt;
&lt;p&gt;For detailed instructions, refer to &lt;a href=&#34;../../administration/view-server/internal-metrics/&#34;&gt;Internal Grafana metrics&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;prometheus-api&#34;&gt;Prometheus API&lt;/h2&gt;
&lt;p&gt;The Prometheus data source works with other projects that implement the &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/api/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus query API&lt;/a&gt; including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://cortexmetrics.io/docs/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Cortex&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://thanos.io/v0.17/components/query.md/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Thanos&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For more information on how to query other Prometheus-compatible projects from Grafana, refer to the specific project documentation.&lt;/p&gt;
&lt;h2 id=&#34;provision-the-prometheus-data-source&#34;&gt;Provision the Prometheus data source&lt;/h2&gt;
&lt;p&gt;You can configure data sources using config files with Grafana&amp;rsquo;s provisioning system. Read more about how it works and all the settings you can set for data sources on the &lt;a href=&#34;../../administration/provisioning/#datasources&#34;&gt;provisioning docs page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here are some provisioning examples for this data source:&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 mode - proxy (server in the UI) or direct (browser in the UI).
    access: proxy
    url: http://localhost:9090
    jsonData:
      httpMethod: POST
      exemplarTraceIdDestinations:
        # Field with internal link pointing to data source in Grafana.
        # datasourceUid value can be anything, but it should be unique across all defined data source uids.
        - datasourceUid: my_jaeger_uid
          name: traceID

        # Field with external link.
        - 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;h2 id=&#34;amazon-managed-service-for-prometheus&#34;&gt;Amazon Managed Service for Prometheus&lt;/h2&gt;
&lt;p&gt;The Prometheus data source works with Amazon Managed Service for Prometheus. If you are using an AWS Identity and Access Management (IAM) policy to control access to your Amazon Managed Service for Prometheus domain, then you must use AWS Signature Version 4 (AWS SigV4) to sign all requests to that domain. For more details on AWS SigV4, refer to the &lt;a href=&#34;https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;AWS documentation&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Grafana version 7.3.5 or higher is required to use SigV4 authentication.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;To connect the Prometheus data source to Amazon Managed Service for Prometheus using SigV4 authentication, refer to the AWS guide to &lt;a href=&#34;https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-onboard-query-standalone-grafana.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Set up Grafana open source or Grafana Enterprise for use with AMP&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you are running Grafana in an Amazon EKS cluster, follow the AWS guide to &lt;a href=&#34;https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-onboard-query-grafana-7.3.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Query using Grafana running in an Amazon EKS cluster&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;configuring-exemplars&#34;&gt;Configuring exemplars&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This feature is available in Prometheus 2.26&#43; and Grafana 7.4&#43;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Grafana 7.4 and later versions have the capability to show exemplars data alongside a metric both in Explore and Dashboards.
Exemplars are a way to associate higher cardinality metadata from a specific event with traditional timeseries data.
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 1834px;&#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/v74/exemplars.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/v74/exemplars.png&#34;data-srcset=&#34;/static/img/docs/v74/exemplars.png?w=320 320w, /static/img/docs/v74/exemplars.png?w=550 550w, /static/img/docs/v74/exemplars.png?w=750 750w, /static/img/docs/v74/exemplars.png?w=900 900w, /static/img/docs/v74/exemplars.png?w=1040 1040w, /static/img/docs/v74/exemplars.png?w=1240 1240w, /static/img/docs/v74/exemplars.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot showing the detail window of an Exemplar&#34;width=&#34;1834&#34;height=&#34;840&#34;title=&#34;Screenshot showing the detail window of an Exemplar&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v74/exemplars.png&#34;
            alt=&#34;Screenshot showing the detail window of an Exemplar&#34;width=&#34;1834&#34;height=&#34;840&#34;title=&#34;Screenshot showing the detail window of an Exemplar&#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;Screenshot showing the detail window of an Exemplar&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Configure Exemplars in the data source settings by adding external or internal links.
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 728px;&#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/v74/exemplars-setting.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/v74/exemplars-setting.png&#34;data-srcset=&#34;/static/img/docs/v74/exemplars-setting.png?w=320 320w, /static/img/docs/v74/exemplars-setting.png?w=550 550w, /static/img/docs/v74/exemplars-setting.png?w=750 750w, /static/img/docs/v74/exemplars-setting.png?w=900 900w, /static/img/docs/v74/exemplars-setting.png?w=1040 1040w, /static/img/docs/v74/exemplars-setting.png?w=1240 1240w, /static/img/docs/v74/exemplars-setting.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the Exemplars configuration&#34;width=&#34;728&#34;height=&#34;254&#34;title=&#34;Screenshot of the Exemplars configuration&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v74/exemplars-setting.png&#34;
            alt=&#34;Screenshot of the Exemplars configuration&#34;width=&#34;728&#34;height=&#34;254&#34;title=&#34;Screenshot of the Exemplars configuration&#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;Screenshot of the Exemplars configuration&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;&lt;/p&gt;
]]></content><description>&lt;h1 id="prometheus-data-source">Prometheus data source&lt;/h1>
&lt;p>Grafana includes built-in support for Prometheus. This topic explains options, variables, querying, and other options specific to the Prometheus data source. Refer to &lt;a href="../add-a-data-source/">Add a data source&lt;/a> for instructions on how to add a data source to Grafana. Only users with the organization admin role can add data sources.&lt;/p></description></item><item><title>Tempo</title><link>https://grafana.com/docs/grafana/v8.4/datasources/tempo/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/tempo/</guid><content><![CDATA[&lt;h1 id=&#34;tempo-data-source&#34;&gt;Tempo data source&lt;/h1&gt;
&lt;p&gt;Grafana ships with built-in support for Tempo a high volume, minimal dependency trace storage, OSS tracing solution from Grafana Labs. Add it as a data source, and you are ready to query your traces in &lt;a href=&#34;../../explore/&#34;&gt;Explore&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;add-data-source&#34;&gt;Add data source&lt;/h2&gt;
&lt;p&gt;To access Tempo settings, click the &lt;strong&gt;Configuration&lt;/strong&gt; (gear) icon, then click &lt;strong&gt;Data Sources&lt;/strong&gt; &amp;gt; &lt;strong&gt;Tempo&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;Name&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;Name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The name using which you will refer to the data source in panels, queries, and Explore.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Default&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The default data source will be pre-selected for new panels.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;URL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The URL of the Tempo instance, e.g., &lt;code&gt;http://tempo&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Basic Auth&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enable basic authentication to the Tempo data source.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;User&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;User name for basic authentication.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Password&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Password for basic authentication.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;trace-to-logs&#34;&gt;Trace to logs&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This feature is available in Grafana 7.4&#43;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This is a configuration for the &lt;a href=&#34;../../explore/trace-integration/&#34;&gt;trace to logs feature&lt;/a&gt;. Select target data source (at this moment limited to Loki data sources) and select which tags will be used in the logs query.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Data source -&lt;/strong&gt; Target data source.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tags -&lt;/strong&gt; The tags that will be used in the Loki query. Default is &lt;code&gt;&#39;cluster&#39;, &#39;hostname&#39;, &#39;namespace&#39;, &#39;pod&#39;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Map tag names -&lt;/strong&gt; When enabled, allows configuring how Tempo tag names map to Loki label names. For example, map &lt;code&gt;service.name&lt;/code&gt; to &lt;code&gt;service&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Span start time shift -&lt;/strong&gt; A shift in the start time for the Loki query based on the start time for the span. To extend the time to the past, use a negative value. You can use time units, for example, 5s, 1m, 3h. The default is 0.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Span end time shift -&lt;/strong&gt; Shift in the end time for the Loki query based on the span end time. Time units can be used here, for example, 5s, 1m, 3h. The default is 0.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Filter by Trace ID -&lt;/strong&gt; Toggle to append the trace ID to the Loki query.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Filter by Span ID -&lt;/strong&gt; Toggle to append the span ID to the Loki query.&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: 572px;&#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/explore/traces-to-logs-settings-8-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/explore/traces-to-logs-settings-8-2.png&#34;data-srcset=&#34;/static/img/docs/explore/traces-to-logs-settings-8-2.png?w=320 320w, /static/img/docs/explore/traces-to-logs-settings-8-2.png?w=550 550w, /static/img/docs/explore/traces-to-logs-settings-8-2.png?w=750 750w, /static/img/docs/explore/traces-to-logs-settings-8-2.png?w=900 900w, /static/img/docs/explore/traces-to-logs-settings-8-2.png?w=1040 1040w, /static/img/docs/explore/traces-to-logs-settings-8-2.png?w=1240 1240w, /static/img/docs/explore/traces-to-logs-settings-8-2.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the trace to logs settings&#34;width=&#34;572&#34;height=&#34;342&#34;title=&#34;Screenshot of the trace to logs settings&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/explore/traces-to-logs-settings-8-2.png&#34;
            alt=&#34;Screenshot of the trace to logs settings&#34;width=&#34;572&#34;height=&#34;342&#34;title=&#34;Screenshot of the trace to logs settings&#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;Screenshot of the trace to logs settings&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;service-graph&#34;&gt;Service Graph&lt;/h3&gt;
&lt;p&gt;This is a configuration for the Service Graph feature.&lt;/p&gt;
&lt;p&gt;&amp;ndash; &lt;strong&gt;Data source -&lt;/strong&gt; Prometheus instance where the Service Graph data is stored.&lt;/p&gt;
&lt;h3 id=&#34;search&#34;&gt;Search&lt;/h3&gt;
&lt;p&gt;This is a configuration for Tempo search.&lt;/p&gt;
&lt;p&gt;&amp;ndash; &lt;strong&gt;Hide search -&lt;/strong&gt; Optionally, hide the search query option in Explore in cases where search is not configured in the Tempo instance.&lt;/p&gt;
&lt;h3 id=&#34;node-graph&#34;&gt;Node Graph&lt;/h3&gt;
&lt;p&gt;This is a configuration for the beta Node Graph visualization. The Node Graph is shown after the trace view is loaded and is disabled by default.&lt;/p&gt;
&lt;p&gt;&amp;ndash; &lt;strong&gt;Enable Node Graph -&lt;/strong&gt; Enables the Node Graph visualization.&lt;/p&gt;
&lt;h2 id=&#34;query-traces&#34;&gt;Query traces&lt;/h2&gt;
&lt;p&gt;You can query and display traces from Tempo via &lt;a href=&#34;../../explore/&#34;&gt;Explore&lt;/a&gt;.
You can search for traces if you set up the trace to logs setting in the data source configuration page. To find traces to visualize, use the &lt;a href=&#34;../loki/#loki-query-editor&#34;&gt;Loki query editor&lt;/a&gt;. To get search results, you must have &lt;a href=&#34;../loki/#derived-fields&#34;&gt;derived fields&lt;/a&gt; configured, which point to this data source.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 750px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link captioned&#34;
        href=&#34;/static/img/docs/tempo/query-editor-search.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/tempo/query-editor-search.png&#34;data-srcset=&#34;/static/img/docs/tempo/query-editor-search.png?w=320 320w, /static/img/docs/tempo/query-editor-search.png?w=550 550w, /static/img/docs/tempo/query-editor-search.png?w=750 750w, /static/img/docs/tempo/query-editor-search.png?w=900 900w, /static/img/docs/tempo/query-editor-search.png?w=1040 1040w, /static/img/docs/tempo/query-editor-search.png?w=1240 1240w, /static/img/docs/tempo/query-editor-search.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the Tempo query editor showing the search tab&#34;width=&#34;1912&#34;height=&#34;870&#34;title=&#34;Screenshot of the Tempo query editor showing the search tab&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/tempo/query-editor-search.png&#34;
            alt=&#34;Screenshot of the Tempo query editor showing the search tab&#34;width=&#34;1912&#34;height=&#34;870&#34;title=&#34;Screenshot of the Tempo query editor showing the search tab&#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;Screenshot of the Tempo query editor showing the search tab&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;To query a particular trace, select the &lt;strong&gt;TraceID&lt;/strong&gt; query type, and then put the ID into the Trace ID field.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 750px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link captioned&#34;
        href=&#34;/static/img/docs/tempo/query-editor-traceid.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/tempo/query-editor-traceid.png&#34;data-srcset=&#34;/static/img/docs/tempo/query-editor-traceid.png?w=320 320w, /static/img/docs/tempo/query-editor-traceid.png?w=550 550w, /static/img/docs/tempo/query-editor-traceid.png?w=750 750w, /static/img/docs/tempo/query-editor-traceid.png?w=900 900w, /static/img/docs/tempo/query-editor-traceid.png?w=1040 1040w, /static/img/docs/tempo/query-editor-traceid.png?w=1240 1240w, /static/img/docs/tempo/query-editor-traceid.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the Tempo TraceID query type&#34;width=&#34;1912&#34;height=&#34;974&#34;title=&#34;Screenshot of the Tempo TraceID query type&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/tempo/query-editor-traceid.png&#34;
            alt=&#34;Screenshot of the Tempo TraceID query type&#34;width=&#34;1912&#34;height=&#34;974&#34;title=&#34;Screenshot of the Tempo TraceID query type&#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;Screenshot of the Tempo TraceID query type&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h2 id=&#34;upload-json-trace-file&#34;&gt;Upload JSON trace file&lt;/h2&gt;
&lt;p&gt;You can upload a JSON file that contains a single trace to visualize it. If the file has multiple traces then the first trace is used for visualization.&lt;/p&gt;
&lt;p&gt;Here is an example JSON:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
  &amp;#34;batches&amp;#34;: [
    {
      &amp;#34;resource&amp;#34;: {
        &amp;#34;attributes&amp;#34;: [
          { &amp;#34;key&amp;#34;: &amp;#34;service.name&amp;#34;, &amp;#34;value&amp;#34;: { &amp;#34;stringValue&amp;#34;: &amp;#34;db&amp;#34; } },
          { &amp;#34;key&amp;#34;: &amp;#34;job&amp;#34;, &amp;#34;value&amp;#34;: { &amp;#34;stringValue&amp;#34;: &amp;#34;tns/db&amp;#34; } },
          { &amp;#34;key&amp;#34;: &amp;#34;opencensus.exporterversion&amp;#34;, &amp;#34;value&amp;#34;: { &amp;#34;stringValue&amp;#34;: &amp;#34;Jaeger-Go-2.22.1&amp;#34; } },
          { &amp;#34;key&amp;#34;: &amp;#34;host.name&amp;#34;, &amp;#34;value&amp;#34;: { &amp;#34;stringValue&amp;#34;: &amp;#34;63d16772b4a2&amp;#34; } },
          { &amp;#34;key&amp;#34;: &amp;#34;ip&amp;#34;, &amp;#34;value&amp;#34;: { &amp;#34;stringValue&amp;#34;: &amp;#34;0.0.0.0&amp;#34; } },
          { &amp;#34;key&amp;#34;: &amp;#34;client-uuid&amp;#34;, &amp;#34;value&amp;#34;: { &amp;#34;stringValue&amp;#34;: &amp;#34;39fb01637a579639&amp;#34; } }
        ]
      },
      &amp;#34;instrumentationLibrarySpans&amp;#34;: [
        {
          &amp;#34;instrumentationLibrary&amp;#34;: {},
          &amp;#34;spans&amp;#34;: [
            {
              &amp;#34;traceId&amp;#34;: &amp;#34;AAAAAAAAAABguiq7RPE&amp;#43;rg==&amp;#34;,
              &amp;#34;spanId&amp;#34;: &amp;#34;cmteMBAvwNA=&amp;#34;,
              &amp;#34;parentSpanId&amp;#34;: &amp;#34;OY8PIaPbma4=&amp;#34;,
              &amp;#34;name&amp;#34;: &amp;#34;HTTP GET - root&amp;#34;,
              &amp;#34;kind&amp;#34;: &amp;#34;SPAN_KIND_SERVER&amp;#34;,
              &amp;#34;startTimeUnixNano&amp;#34;: &amp;#34;1627471657255809000&amp;#34;,
              &amp;#34;endTimeUnixNano&amp;#34;: &amp;#34;1627471657256268000&amp;#34;,
              &amp;#34;attributes&amp;#34;: [
                { &amp;#34;key&amp;#34;: &amp;#34;http.status_code&amp;#34;, &amp;#34;value&amp;#34;: { &amp;#34;intValue&amp;#34;: &amp;#34;200&amp;#34; } },
                { &amp;#34;key&amp;#34;: &amp;#34;http.method&amp;#34;, &amp;#34;value&amp;#34;: { &amp;#34;stringValue&amp;#34;: &amp;#34;GET&amp;#34; } },
                { &amp;#34;key&amp;#34;: &amp;#34;http.url&amp;#34;, &amp;#34;value&amp;#34;: { &amp;#34;stringValue&amp;#34;: &amp;#34;/&amp;#34; } },
                { &amp;#34;key&amp;#34;: &amp;#34;component&amp;#34;, &amp;#34;value&amp;#34;: { &amp;#34;stringValue&amp;#34;: &amp;#34;net/http&amp;#34; } }
              ],
              &amp;#34;status&amp;#34;: {}
            }
          ]
        }
      ]
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;service-graph-1&#34;&gt;Service Graph&lt;/h2&gt;
&lt;p&gt;A service graph is a visual representation of the relationships between services. Each node on the graph represents a service such as an API or database. With this graph, customers can easily detect performance issues, increases in error, fault, or throttle rates in any of their services, and dive deep into corresponding traces and root causes.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/node-graph/node-graph-8-0.png&#34;
  alt=&#34;Node graph panel&#34; width=&#34;1768&#34;
     height=&#34;1288&#34;/&gt;&lt;/p&gt;
&lt;p&gt;To display the service graph:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;/docs/tempo/next/grafana-agent/service-graphs/#quickstart&#34;&gt;Configure the Grafana Agent&lt;/a&gt; to generate service graph data&lt;/li&gt;
&lt;li&gt;Link a Prometheus datasource in the Tempo datasource settings.&lt;/li&gt;
&lt;li&gt;Navigate to &lt;a href=&#34;../../explore/&#34;&gt;Explore&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Select the Tempo datasource&lt;/li&gt;
&lt;li&gt;Select the &lt;strong&gt;Service Graph&lt;/strong&gt; query type and run the query&lt;/li&gt;
&lt;li&gt;Optionally, filter by service name&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can pan and zoom the view with buttons or you mouse. For details about the visualization, refer to &lt;a href=&#34;/docs/grafana/latest/panels/visualizations/node-graph/&#34;&gt;Node graph panel&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Each service in the graph is represented as a circle. Numbers on the inside shows average time per request and request per second.&lt;/p&gt;
&lt;p&gt;The color of each circle represents the percentage of requests in each of the following states:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;green = success&lt;/li&gt;
&lt;li&gt;red = fault&lt;/li&gt;
&lt;li&gt;yellow = errors&lt;/li&gt;
&lt;li&gt;purple = throttled responses&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Click on the service to see a context menu with additional links for quick navigation to other relevant information.&lt;/p&gt;
&lt;h2 id=&#34;linking-trace-id-from-logs&#34;&gt;Linking Trace ID from logs&lt;/h2&gt;
&lt;p&gt;You can link to Tempo trace from logs in Loki or Elastic by configuring an internal link. See the &lt;a href=&#34;../loki/#derived-fields&#34;&gt;Derived fields&lt;/a&gt; section in the &lt;a href=&#34;../loki/&#34;&gt;Loki data source&lt;/a&gt; or &lt;a href=&#34;../elasticsearch/#data-links&#34;&gt;Data links&lt;/a&gt; section in the &lt;a href=&#34;../elasticsearch/&#34;&gt;Elastic data source&lt;/a&gt; for configuration instructions.&lt;/p&gt;
&lt;h2 id=&#34;provision-the-tempo-data-source&#34;&gt;Provision the Tempo data source&lt;/h2&gt;
&lt;p&gt;You can modify the Grafana configuration files to provision the Tempo data source. Read more about how it works and all the settings you can set for data sources on the &lt;a href=&#34;../../administration/provisioning/#datasources&#34;&gt;provisioning&lt;/a&gt; topic.&lt;/p&gt;
&lt;p&gt;Here is an example config:&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: Tempo
    type: tempo
    # Access mode - proxy (server in the UI) or direct (browser in the UI).
    access: proxy
    url: http://localhost:3200
    jsonData:
      httpMethod: GET
      tracesToLogs:
        datasourceUid: &amp;#39;loki&amp;#39;
        tags: [&amp;#39;job&amp;#39;, &amp;#39;instance&amp;#39;, &amp;#39;pod&amp;#39;, &amp;#39;namespace&amp;#39;]
        mappedTags: [{ key: &amp;#39;service.name&amp;#39;, value: &amp;#39;service&amp;#39; }]
        mapTagNamesEnabled: false
        spanStartTimeShift: &amp;#39;1h&amp;#39;
        spanEndTimeShift: &amp;#39;1h&amp;#39;
        filterByTraceID: false
        filterBySpanID: false
        lokiSearch: true
      serviceMap:
        datasourceUid: &amp;#39;prometheus&amp;#39;
      search:
        hide: false
      nodeGraph:
        enabled: true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="tempo-data-source">Tempo data source&lt;/h1>
&lt;p>Grafana ships with built-in support for Tempo a high volume, minimal dependency trace storage, OSS tracing solution from Grafana Labs. Add it as a data source, and you are ready to query your traces in &lt;a href="../../explore/">Explore&lt;/a>.&lt;/p></description></item><item><title>TestData</title><link>https://grafana.com/docs/grafana/v8.4/datasources/testdata/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/testdata/</guid><content><![CDATA[&lt;h1 id=&#34;grafana-testdata-db&#34;&gt;Grafana TestData DB&lt;/h1&gt;
&lt;p&gt;The purpose of this data source is to make it easier to create fake data for any panel.
Using &lt;code&gt;TestData DB&lt;/code&gt; you can build your own time series and have any panel render it.
This makes it much easier to verify functionality since the data can be shared very easily.&lt;/p&gt;
&lt;h2 id=&#34;enable&#34;&gt;Enable&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;TestData DB&lt;/code&gt; data source is not enabled by default. To enable it:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In the &lt;strong&gt;Configuration&lt;/strong&gt; menu (small gear on the left side of the screen), click &lt;strong&gt;Data Sources&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add Data Source&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Search and click &lt;code&gt;TestData DB&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save &amp;amp; Test&lt;/strong&gt; to enable it.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;create-mock-data&#34;&gt;Create mock data.&lt;/h2&gt;
&lt;p&gt;Once &lt;code&gt;TestData DB&lt;/code&gt; is enabled, you can use it as a data source in any metric panel.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload&#34;
  data-src=&#34;/static/img/docs/v41/test_data_add.png&#34;
  alt=&#34;&#34; width=&#34;959&#34;
     height=&#34;209&#34;/&gt;&lt;/p&gt;
&lt;h2 id=&#34;csv&#34;&gt;CSV&lt;/h2&gt;
&lt;p&gt;The comma separated values scenario is the most powerful one since it lets you create any kind of graph you like.
Once you provided the numbers, &lt;code&gt;TestData DB&lt;/code&gt; distributes them evenly based on the time range of your query.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload&#34;
  data-src=&#34;/static/img/docs/v41/test_data_csv_example.png&#34;
  alt=&#34;&#34; width=&#34;969&#34;
     height=&#34;638&#34;/&gt;&lt;/p&gt;
&lt;h2 id=&#34;dashboards&#34;&gt;Dashboards&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;TestData DB&lt;/code&gt; also contains some dashboards with examples.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;Configuration&lt;/strong&gt; &amp;gt; &lt;strong&gt;Data Sources&lt;/strong&gt; &amp;gt; &lt;strong&gt;TestData DB&lt;/strong&gt; &amp;gt; &lt;strong&gt;Dashboards&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Import&lt;/strong&gt; the &lt;strong&gt;Simple Streaming Example&lt;/strong&gt; dashboard.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;commit-updates-to-the-dashboards&#34;&gt;Commit updates to the dashboards&lt;/h3&gt;
&lt;p&gt;To submit a change to one of the current dashboards bundled with &lt;code&gt;TestData DB&lt;/code&gt;, update the revision property.
Otherwise the dashboard will not be updated automatically for other Grafana users.&lt;/p&gt;
&lt;h2 id=&#34;using-test-data-in-issues&#34;&gt;Using test data in issues&lt;/h2&gt;
&lt;p&gt;If you post an issue on Github regarding time series data or rendering of time series data, we strongly advise you to use this data source to replicate the data.
That makes it much easier for the developers to replicate and solve the issue you have.&lt;/p&gt;
]]></content><description>&lt;h1 id="grafana-testdata-db">Grafana TestData DB&lt;/h1>
&lt;p>The purpose of this data source is to make it easier to create fake data for any panel.
Using &lt;code>TestData DB&lt;/code> you can build your own time series and have any panel render it.
This makes it much easier to verify functionality since the data can be shared very easily.&lt;/p></description></item><item><title>Zipkin</title><link>https://grafana.com/docs/grafana/v8.4/datasources/zipkin/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/datasources/zipkin/</guid><content><![CDATA[&lt;h1 id=&#34;zipkin-data-source&#34;&gt;Zipkin data source&lt;/h1&gt;
&lt;p&gt;Grafana ships with built-in support for Zipkin, an open source, distributed tracing system.
Just add it as a data source and you are ready to query your traces in &lt;a href=&#34;../../explore/&#34;&gt;Explore&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;adding-the-data-source&#34;&gt;Adding the data source&lt;/h2&gt;
&lt;p&gt;To access Zipkin settings, click the &lt;strong&gt;Configuration&lt;/strong&gt; (gear) icon, then click &lt;strong&gt;Data Sources&lt;/strong&gt; &amp;gt; &lt;strong&gt;Zipkin&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;Name&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;Name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The data source name in panels, queries, and Explore.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Default&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The pre-selected data source for a new panel.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;URL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The URL of the Zipkin instance. For example, &lt;code&gt;http://localhost:9411&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Basic Auth&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enable basic authentication for the Zipkin data source.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;User&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Specify a user name for basic authentication.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Password&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Specify a password for basic authentication.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;trace-to-logs&#34;&gt;Trace to logs&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This feature is available in Grafana 7.4&#43;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This is a configuration for the &lt;a href=&#34;../../explore/trace-integration/&#34;&gt;trace to logs feature&lt;/a&gt;. Select target data source (at this moment limited to Loki data sources) and select which tags will be used in the logs query.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Data source -&lt;/strong&gt; Target data source.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tags -&lt;/strong&gt; The tags that will be used in the Loki query. Default is &lt;code&gt;&#39;cluster&#39;, &#39;hostname&#39;, &#39;namespace&#39;, &#39;pod&#39;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Map tag names -&lt;/strong&gt; When enabled, allows configuring how Zipkin tag names map to Loki label names. For example, map &lt;code&gt;service.name&lt;/code&gt; to &lt;code&gt;service&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Span start time shift -&lt;/strong&gt; Shift in the start time for the Loki query based on the span start time. In order to extend to the past, you need to use a negative value. Use time interval units like 5s, 1m, 3h. The default is 0.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Span end time shift -&lt;/strong&gt; Shift in the end time for the Loki query based on the span end time. Time units can be used here, for example, 5s, 1m, 3h. The default is 0.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Filter by Trace ID -&lt;/strong&gt; Toggle to append the trace ID to the Loki query.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Filter by Span ID -&lt;/strong&gt; Toggle to append the span ID to the Loki query.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/explore/trace-to-logs-settings-8-2.png&#34;
  alt=&#34;Trace to logs settings&#34;/&gt;&lt;/p&gt;
&lt;h3 id=&#34;node-graph&#34;&gt;Node Graph&lt;/h3&gt;
&lt;p&gt;This is a configuration for the beta Node Graph visualization. The Node Graph is shown after the trace view is loaded and is disabled by default.&lt;/p&gt;
&lt;p&gt;&amp;ndash; &lt;strong&gt;Enable Node Graph -&lt;/strong&gt; Enables the Node Graph visualization.&lt;/p&gt;
&lt;h2 id=&#34;query-traces&#34;&gt;Query traces&lt;/h2&gt;
&lt;p&gt;Querying and displaying traces from Zipkin is available via &lt;a href=&#34;../../explore/&#34;&gt;Explore&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: 1468px;&#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/v70/zipkin-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;/static/img/docs/v70/zipkin-query-editor.png&#34;data-srcset=&#34;/static/img/docs/v70/zipkin-query-editor.png?w=320 320w, /static/img/docs/v70/zipkin-query-editor.png?w=550 550w, /static/img/docs/v70/zipkin-query-editor.png?w=750 750w, /static/img/docs/v70/zipkin-query-editor.png?w=900 900w, /static/img/docs/v70/zipkin-query-editor.png?w=1040 1040w, /static/img/docs/v70/zipkin-query-editor.png?w=1240 1240w, /static/img/docs/v70/zipkin-query-editor.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the Zipkin query editor&#34;width=&#34;1468&#34;height=&#34;230&#34;title=&#34;Screenshot of the Zipkin query editor&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v70/zipkin-query-editor.png&#34;
            alt=&#34;Screenshot of the Zipkin query editor&#34;width=&#34;1468&#34;height=&#34;230&#34;title=&#34;Screenshot of the Zipkin query editor&#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;Screenshot of the Zipkin query editor&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;The Zipkin query editor allows you to query by trace ID directly or selecting a trace from trace selector. To query by trace ID, insert the ID into the text input.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 1468px;&#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/v70/zipkin-query-editor-open.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/v70/zipkin-query-editor-open.png&#34;data-srcset=&#34;/static/img/docs/v70/zipkin-query-editor-open.png?w=320 320w, /static/img/docs/v70/zipkin-query-editor-open.png?w=550 550w, /static/img/docs/v70/zipkin-query-editor-open.png?w=750 750w, /static/img/docs/v70/zipkin-query-editor-open.png?w=900 900w, /static/img/docs/v70/zipkin-query-editor-open.png?w=1040 1040w, /static/img/docs/v70/zipkin-query-editor-open.png?w=1240 1240w, /static/img/docs/v70/zipkin-query-editor-open.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the Zipkin query editor with trace selector expanded&#34;width=&#34;1468&#34;height=&#34;528&#34;title=&#34;Screenshot of the Zipkin query editor with trace selector expanded&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v70/zipkin-query-editor-open.png&#34;
            alt=&#34;Screenshot of the Zipkin query editor with trace selector expanded&#34;width=&#34;1468&#34;height=&#34;528&#34;title=&#34;Screenshot of the Zipkin query editor with trace selector expanded&#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;Screenshot of the Zipkin query editor with trace selector expanded&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Use the trace selector to pick particular trace from all traces logged in the time range you have selected in Explore. The trace selector has three levels of nesting:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The service you are interested in.&lt;/li&gt;
&lt;li&gt;Particular operation is part of the selected service&lt;/li&gt;
&lt;li&gt;Specific trace in which the selected operation occurred, represented by the root operation name and trace duration.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;data-mapping-in-the-trace-ui&#34;&gt;Data mapping in the trace UI&lt;/h2&gt;
&lt;p&gt;Zipkin annotations are shown in the trace view as logs with annotation value shown under annotation key.&lt;/p&gt;
&lt;h2 id=&#34;upload-json-trace-file&#34;&gt;Upload JSON trace file&lt;/h2&gt;
&lt;p&gt;You can upload a JSON file that contains a single trace to visualize it.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 1857px;&#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/explore/zipkin-upload-json.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/explore/zipkin-upload-json.png&#34;data-srcset=&#34;/static/img/docs/explore/zipkin-upload-json.png?w=320 320w, /static/img/docs/explore/zipkin-upload-json.png?w=550 550w, /static/img/docs/explore/zipkin-upload-json.png?w=750 750w, /static/img/docs/explore/zipkin-upload-json.png?w=900 900w, /static/img/docs/explore/zipkin-upload-json.png?w=1040 1040w, /static/img/docs/explore/zipkin-upload-json.png?w=1240 1240w, /static/img/docs/explore/zipkin-upload-json.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the Zipkin data source in explore with upload selected&#34;width=&#34;1857&#34;height=&#34;548&#34;title=&#34;Screenshot of the Zipkin data source in explore with upload selected&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/explore/zipkin-upload-json.png&#34;
            alt=&#34;Screenshot of the Zipkin data source in explore with upload selected&#34;width=&#34;1857&#34;height=&#34;548&#34;title=&#34;Screenshot of the Zipkin data source in explore with upload selected&#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;Screenshot of the Zipkin data source in explore with upload selected&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Here is an example JSON:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;[
  {
    &amp;#34;traceId&amp;#34;: &amp;#34;efe9cb8857f68c8f&amp;#34;,
    &amp;#34;parentId&amp;#34;: &amp;#34;efe9cb8857f68c8f&amp;#34;,
    &amp;#34;id&amp;#34;: &amp;#34;8608dc6ce5cafe8e&amp;#34;,
    &amp;#34;kind&amp;#34;: &amp;#34;SERVER&amp;#34;,
    &amp;#34;name&amp;#34;: &amp;#34;get /api&amp;#34;,
    &amp;#34;timestamp&amp;#34;: 1627975249601797,
    &amp;#34;duration&amp;#34;: 23457,
    &amp;#34;localEndpoint&amp;#34;: { &amp;#34;serviceName&amp;#34;: &amp;#34;backend&amp;#34;, &amp;#34;ipv4&amp;#34;: &amp;#34;127.0.0.1&amp;#34;, &amp;#34;port&amp;#34;: 9000 },
    &amp;#34;tags&amp;#34;: {
      &amp;#34;http.method&amp;#34;: &amp;#34;GET&amp;#34;,
      &amp;#34;http.path&amp;#34;: &amp;#34;/api&amp;#34;,
      &amp;#34;jaxrs.resource.class&amp;#34;: &amp;#34;Resource&amp;#34;,
      &amp;#34;jaxrs.resource.method&amp;#34;: &amp;#34;printDate&amp;#34;
    },
    &amp;#34;shared&amp;#34;: true
  }
]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;linking-trace-id-from-logs&#34;&gt;Linking Trace ID from logs&lt;/h2&gt;
&lt;p&gt;You can link to Zipkin trace from logs in Loki by configuring a derived field with internal link. See &lt;a href=&#34;../loki/#derived-fields&#34;&gt;Loki documentation&lt;/a&gt; for details.&lt;/p&gt;
]]></content><description>&lt;h1 id="zipkin-data-source">Zipkin data source&lt;/h1>
&lt;p>Grafana ships with built-in support for Zipkin, an open source, distributed tracing system.
Just add it as a data source and you are ready to query your traces in &lt;a href="../../explore/">Explore&lt;/a>.&lt;/p></description></item></channel></rss>