<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/v6.4/features/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/v6.4/features/datasources/index.xml" rel="self" type="application/rss+xml"/><item><title>AWS CloudWatch</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/cloudwatch/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/datasources/cloudwatch/</guid><content><![CDATA[&lt;h1 id=&#34;using-aws-cloudwatch-in-grafana&#34;&gt;Using AWS CloudWatch in Grafana&lt;/h1&gt;
&lt;p&gt;Grafana ships with built in support for CloudWatch. You just have to add it as a data source and you will be ready to build dashboards for your CloudWatch metrics.&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;code&gt;Cloudwatch&lt;/code&gt; from the &lt;em&gt;Type&lt;/em&gt; dropdown.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;NOTE: If at any moment you have issues with getting this data source to work and Grafana is giving you undescriptive errors then don&amp;rsquo;t
forget to check your log file (try looking in /var/log/grafana/grafana.log).&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;em&gt;Name&lt;/em&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;em&gt;Default&lt;/em&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;em&gt;Default Region&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Used in query editor to set region (can be changed on per query basis)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Custom Metrics namespace&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Specify the CloudWatch namespace of Custom metrics&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Auth Provider&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Specify the provider to get credentials.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Credentials&lt;/em&gt; profile name&lt;/td&gt;
              &lt;td&gt;Specify the name of the profile to use (if you use &lt;code&gt;~/.aws/credentials&lt;/code&gt; file), leave blank for default.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Assume Role Arn&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Specify the ARN of the role to assume&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;authentication&#34;&gt;Authentication&lt;/h2&gt;
&lt;h3 id=&#34;iam-roles&#34;&gt;IAM Roles&lt;/h3&gt;
&lt;p&gt;Currently all access to CloudWatch is done server side by the Grafana backend using the official AWS SDK. If your Grafana
server is running on AWS you can use IAM Roles and authentication will be handled automatically.&lt;/p&gt;
&lt;p&gt;Checkout AWS docs on &lt;a href=&#34;http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;IAM Roles&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;NOTE: AWS Role Switching as described &lt;a href=&#34;https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-cli.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt; it not supported at the moment.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;iam-policies&#34;&gt;IAM Policies&lt;/h2&gt;
&lt;p&gt;Grafana needs permissions granted via IAM to be able to read CloudWatch metrics
and EC2 tags/instances/regions. You can attach these permissions to IAM roles and
utilize Grafana&amp;rsquo;s built-in support for assuming roles.&lt;/p&gt;
&lt;p&gt;Here is a minimal policy 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;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:ListMetrics&amp;#34;,
                &amp;#34;cloudwatch:GetMetricStatistics&amp;#34;,
                &amp;#34;cloudwatch:GetMetricData&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;h3 id=&#34;aws-credentials&#34;&gt;AWS credentials&lt;/h3&gt;
&lt;p&gt;If Auth Provider is &lt;code&gt;Credentials file&lt;/code&gt;, Grafana try to get credentials by following order.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Environment variables. (&lt;code&gt;AWS_ACCESS_KEY_ID&lt;/code&gt; and &lt;code&gt;AWS_SECRET_ACCESS_KEY&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Hard-code credentials.&lt;/li&gt;
&lt;li&gt;Shared credentials file.&lt;/li&gt;
&lt;li&gt;IAM role for Amazon EC2.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Checkout AWS docs on &lt;a href=&#34;https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Configuring the AWS SDK for Go&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&#34;aws-credentials-file&#34;&gt;AWS credentials file&lt;/h3&gt;
&lt;p&gt;Create a file at &lt;code&gt;~/.aws/credentials&lt;/code&gt;. That is the &lt;code&gt;HOME&lt;/code&gt; path for user running grafana-server.
&amp;gt; NOTE: If you think you have the credentials file in the right place but it is still not working then you might try moving your .aws file to &amp;lsquo;/usr/share/grafana/&amp;rsquo; and make sure your credentials file has at most 0644 permissions.&lt;/p&gt;
&lt;p&gt;Example content:&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;[default]
aws_access_key_id = asdsadasdasdasd
aws_secret_access_key = dasdasdsadasdasdasdsa
region = us-west-2&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;metric-query-editor&#34;&gt;Metric Query Editor&lt;/h2&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload&#34;
  data-src=&#34;/static/img/docs/v43/cloudwatch_editor.png&#34;
  alt=&#34;&#34; width=&#34;930&#34;
     height=&#34;141&#34;/&gt;&lt;/p&gt;
&lt;p&gt;You need to specify a namespace, metric, at least one stat, and at least one dimension.&lt;/p&gt;
&lt;h2 id=&#34;metric-math&#34;&gt;Metric Math&lt;/h2&gt;
&lt;p&gt;You can now create new time series metrics by operating on top of Cloudwatch metrics using mathematical functions. Arithmetic operators, unary subtraction and other functions are supported to be applied on 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 operator on a metric, you can do it by giving an alias(a unique string) to the raw metric as shown below. Then you can use this alias and apply arithmetic operator to it in the Expression field of created metric.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload&#34;
  data-src=&#34;/static/img/docs/v60/cloudwatch_metric_math.png&#34;
  alt=&#34;&#34; width=&#34;1766&#34;
     height=&#34;1208&#34;/&gt;&lt;/p&gt;
&lt;h2 id=&#34;templated-queries&#34;&gt;Templated queries&lt;/h2&gt;
&lt;p&gt;Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place.
Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data
being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Checkout the &lt;a href=&#34;../../../reference/templating/&#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;CloudWatch data source plugin provides the following queries you can specify in the &lt;code&gt;Query&lt;/code&gt; field in the Variable
edit view. They allow you to fill a variable&amp;rsquo;s options list with things like &lt;code&gt;region&lt;/code&gt;, &lt;code&gt;namespaces&lt;/code&gt;, &lt;code&gt;metric names&lt;/code&gt;
and &lt;code&gt;dimension keys/values&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In place of &lt;code&gt;region&lt;/code&gt; you can specify &lt;code&gt;default&lt;/code&gt; to use the default region configured in the data source for the query,
e.g. &lt;code&gt;metrics(AWS/DynamoDB, default)&lt;/code&gt; or &lt;code&gt;dimension_values(default, ..., ..., ...)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Read more about the available dimensions in the &lt;a href=&#34;https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CW_Support_For_AWS.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;CloudWatch  Metrics and Dimensions Reference&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;em&gt;regions()&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of regions AWS provides their service.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;namespaces()&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of namespaces CloudWatch support.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;metrics(namespace, [region])&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of metrics in the namespace. (specify region or use &amp;ldquo;default&amp;rdquo; for custom metrics)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;dimension_keys(namespace)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of dimension keys in the namespace.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;dimension_values(region, namespace, metric, dimension_key, [filters])&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of dimension values matching the specified &lt;code&gt;region&lt;/code&gt;, &lt;code&gt;namespace&lt;/code&gt;, &lt;code&gt;metric&lt;/code&gt;, &lt;code&gt;dimension_key&lt;/code&gt; or you can use dimension &lt;code&gt;filters&lt;/code&gt; to get more specific result as well.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;ebs_volume_ids(region, instance_id)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of volume ids matching the specified &lt;code&gt;region&lt;/code&gt;, &lt;code&gt;instance_id&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;ec2_instance_attribute(region, attribute_name, filters)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of attributes matching the specified &lt;code&gt;region&lt;/code&gt;, &lt;code&gt;attribute_name&lt;/code&gt;, &lt;code&gt;filters&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;resource_arns(region, resource_type, tags)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of ARNs matching the specified &lt;code&gt;region&lt;/code&gt;, &lt;code&gt;resource_type&lt;/code&gt; and &lt;code&gt;tags&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;For details about the metrics CloudWatch provides, please refer to the &lt;a href=&#34;https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;CloudWatch documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;examples-templated-queries&#34;&gt;Examples templated Queries&lt;/h4&gt;
&lt;p&gt;Example dimension queries which will return list of resources for individual AWS Services:&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;Service&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;dimension_values(us-east-1,AWS/ELB,RequestCount,LoadBalancerName)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;ELB&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;dimension_values(us-east-1,AWS/ElastiCache,CPUUtilization,CacheClusterId)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;ElastiCache&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;dimension_values(us-east-1,AWS/Redshift,CPUUtilization,ClusterIdentifier)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;RedShift&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;dimension_values(us-east-1,AWS/RDS,CPUUtilization,DBInstanceIdentifier)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;RDS&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;dimension_values(us-east-1,AWS/S3,BucketSizeBytes,BucketName)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;S3&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;dimension_values(us-east-1,CWAgent,disk_used_percent,device,{&amp;ldquo;InstanceId&amp;rdquo;:&amp;quot;$instance_id&amp;quot;})&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;CloudWatch Agent&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;resource_arns(eu-west-1,elasticloadbalancing:loadbalancer,{&amp;ldquo;elasticbeanstalk:environment-name&amp;rdquo;:[&amp;ldquo;myApp-dev&amp;rdquo;,&amp;ldquo;myApp-prod&amp;rdquo;]})&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;ELB&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;resource_arns(eu-west-1,ec2:instance,{&amp;ldquo;elasticbeanstalk:environment-name&amp;rdquo;:[&amp;ldquo;myApp-dev&amp;rdquo;,&amp;ldquo;myApp-prod&amp;rdquo;]})&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;EC2&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;ec2_instance_attribute-examples&#34;&gt;ec2_instance_attribute examples&lt;/h2&gt;
&lt;h3 id=&#34;json-filters&#34;&gt;JSON filters&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;ec2_instance_attribute&lt;/code&gt; query takes &lt;code&gt;filters&lt;/code&gt; in JSON format.
You can specify &lt;a href=&#34;http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;pre-defined filters of ec2:DescribeInstances&lt;/a&gt;.
Note that the actual filtering takes place on Amazon&amp;rsquo;s servers, not in Grafana.&lt;/p&gt;
&lt;p&gt;Filters syntax:&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;JavaScript&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-javascript&#34;&gt;{ filter_name1: [ filter_value1 ], filter_name2: [ filter_value2 ] }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Example &lt;code&gt;ec2_instance_attribute()&lt;/code&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;JavaScript&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-javascript&#34;&gt;ec2_instance_attribute(us-east-1, InstanceId, { &amp;#34;tag:Environment&amp;#34;: [ &amp;#34;production&amp;#34; ] })&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;selecting-attributes&#34;&gt;Selecting Attributes&lt;/h3&gt;
&lt;p&gt;Only 1 attribute per instance can be returned. Any flat attribute can be selected (i.e. if the attribute has a single value and isn&amp;rsquo;t an object or array). Below is a list of available flat attributes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;AmiLaunchIndex&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Architecture&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ClientToken&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;EbsOptimized&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;EnaSupport&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Hypervisor&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;IamInstanceProfile&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ImageId&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;InstanceId&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;InstanceLifecycle&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;InstanceType&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;KernelId&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;KeyName&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;LaunchTime&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Platform&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;PrivateDnsName&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;PrivateIpAddress&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;PublicDnsName&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;PublicIpAddress&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;RamdiskId&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;RootDeviceName&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;RootDeviceType&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SourceDestCheck&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SpotInstanceRequestId&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SriovNetSupport&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SubnetId&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;VirtualizationType&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;VpcId&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Tags can be selected by prepending the tag name with &lt;code&gt;Tags.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Example &lt;code&gt;ec2_instance_attribute()&lt;/code&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;JavaScript&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-javascript&#34;&gt;ec2_instance_attribute(us-east-1, Tags.Name, { &amp;#34;tag:Team&amp;#34;: [ &amp;#34;sysops&amp;#34; ] })&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;using-json-format-template-variables&#34;&gt;Using json format template variables&lt;/h2&gt;
&lt;p&gt;Some of query takes JSON format filter. Grafana support to interpolate template variable to JSON format string, it can use as filter string.&lt;/p&gt;
&lt;p&gt;If &lt;code&gt;env = &#39;production&#39;, &#39;staging&#39;&lt;/code&gt;, following query will return ARNs of EC2 instances which &lt;code&gt;Environment&lt;/code&gt; tag is &lt;code&gt;production&lt;/code&gt; or &lt;code&gt;staging&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;resource_arns(us-east-1, ec2:instance, {&amp;#34;Environment&amp;#34;:${env:json}})&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;cost&#34;&gt;Cost&lt;/h2&gt;
&lt;p&gt;Amazon provides 1 million CloudWatch API requests each month at no additional charge. Past this,
it costs $0.01 per 1,000 GetMetricStatistics or ListMetrics requests. For each query Grafana will
issue a GetMetricStatistics request and every time you pick a dimension in the query editor
Grafana will issue a ListMetrics request.&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;p&gt;Using a credentials 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;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: Cloudwatch
    type: cloudwatch
    jsonData:
      authType: credentials
      defaultRegion: eu-west-2&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using &lt;code&gt;accessKey&lt;/code&gt; and &lt;code&gt;secretKey&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;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: Cloudwatch
    type: cloudwatch
    jsonData:
      authType: keys
      defaultRegion: eu-west-2
    secureJsonData:
      accessKey: &amp;#34;&amp;lt;your access key&amp;gt;&amp;#34;
      secretKey: &amp;#34;&amp;lt;your secret key&amp;gt;&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="using-aws-cloudwatch-in-grafana">Using AWS CloudWatch in Grafana&lt;/h1>
&lt;p>Grafana ships with built in support for CloudWatch. You just have to add it as a data source and you will be ready to build dashboards for your CloudWatch metrics.&lt;/p></description></item><item><title>TestData</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/testdata/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/datasources/testdata/</guid><content><![CDATA[&lt;h1 id=&#34;grafana-testdata&#34;&gt;Grafana TestData&lt;/h1&gt;
&lt;p&gt;The purpose of this data sources is to make it easier to create fake data for any panel.
Using &lt;code&gt;Grafana TestData&lt;/code&gt; you can build your own time series and have any panel render it.
This make is much easier to verify functionally 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;&lt;code&gt;Grafana TestData&lt;/code&gt; is not enabled by default. To enable it, first navigate to the Plugins section, found in your Grafana main menu. Click the Apps tabs in the Plugins section and select the Grafana TestData App. (Or navigate to http://your_grafana_instance/plugins/testdata/edit to go directly there). Finally click the enable button to enable.&lt;/p&gt;
&lt;h2 id=&#34;create-mock-data&#34;&gt;Create mock data.&lt;/h2&gt;
&lt;p&gt;Once &lt;code&gt;Grafana TestData&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;Grafana TestData&lt;/code&gt; will distribute 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;Grafana TestData&lt;/code&gt; also contains some dashboards with example. &lt;code&gt;/plugins/testdata/edit&lt;/code&gt;&lt;/p&gt;
&lt;h3 id=&#34;commit-updates-to-the-dashboards&#34;&gt;Commit updates to the dashboards&lt;/h3&gt;
&lt;p&gt;If you want to submit a change to one of the current dashboards bundled with &lt;code&gt;Grafana TestData&lt;/code&gt; you have to 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 advice 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">Grafana TestData&lt;/h1>
&lt;p>The purpose of this data sources is to make it easier to create fake data for any panel.
Using &lt;code>Grafana TestData&lt;/code> you can build your own time series and have any panel render it.
This make is much easier to verify functionally since the data can be shared very easily.&lt;/p></description></item><item><title>Using Azure Monitor in Grafana</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/azuremonitor/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/datasources/azuremonitor/</guid><content><![CDATA[&lt;h1 id=&#34;using-azure-monitor-in-grafana&#34;&gt;Using Azure Monitor in Grafana&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;Officially released in Grafana v6.0.0&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;As of Grafana 6.0, the Azure Monitor plugin has been moved into Grafana so it now ships with built-in support for Azure Monitor.&lt;/p&gt;
&lt;p&gt;The Azure Monitor data source supports multiple services in the Azure cloud:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;#querying-the-azure-monitor-service&#34;&gt;Azure Monitor&lt;/a&gt;&lt;/strong&gt; is the platform service that provides a single source for monitoring Azure resources.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;#querying-the-application-insights-service&#34;&gt;Application Insights&lt;/a&gt;&lt;/strong&gt; is an extensible Application Performance Management (APM) service for web developers on multiple platforms and can be used to monitor your live web application - it will automatically detect performance anomalies.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;#querying-the-azure-log-analytics-service&#34;&gt;Azure Log Analytics&lt;/a&gt;&lt;/strong&gt; (or Azure Logs) gives you access to log data collected by Azure Monitor.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;#writing-analytics-queries-for-the-application-insights-service&#34;&gt;Application Insights Analytics&lt;/a&gt;&lt;/strong&gt; allows you to query &lt;a href=&#34;https://docs.microsoft.com/en-us/azure/azure-monitor/app/analytics&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Application Insights data&lt;/a&gt; using the same query language used for Azure Log Analytics.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;adding-the-data-source-to-grafana&#34;&gt;Adding the data source to Grafana&lt;/h2&gt;
&lt;p&gt;The data source can access metrics from four different services. You can configure access to the services that you use. It is also possible to use the same credentials for multiple services if that is how you have set it up in Azure AD.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Guide to setting up an Azure Active Directory Application for Azure Monitor.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://dev.loganalytics.io/documentation/Authorization/AAD-Setup&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Guide to setting up an Azure Active Directory Application for Azure Log Analytics.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://dev.applicationinsights.io/quickstart/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Quickstart Guide for Application Insights.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Accessed from the Grafana main menu, newly installed data sources can be added immediately within the Data Sources section. Next, click the &amp;ldquo;Add data source&amp;rdquo; button in the upper right. The Azure Monitor data source will be available for selection in the Cloud section in the list of data sources.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the name field, Grafana will automatically fill in a name for the data source - &lt;code&gt;Azure Monitor&lt;/code&gt; or something like &lt;code&gt;Azure Monitor - 3&lt;/code&gt;. If you are going to configure multiple data sources then change the name to something more informative.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you are using Azure Monitor, you need 4 pieces of information from the Azure portal (see link above for detailed instructions):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Tenant Id&lt;/strong&gt; (Azure Active Directory -&amp;gt; Properties -&amp;gt; Directory ID)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Client Id&lt;/strong&gt; (Azure Active Directory -&amp;gt; App Registrations -&amp;gt; Choose your app -&amp;gt; Application ID)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Client Secret&lt;/strong&gt; ( Azure Active Directory -&amp;gt; App Registrations -&amp;gt; Choose your app -&amp;gt; Keys)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Default Subscription Id&lt;/strong&gt; (Subscriptions -&amp;gt; Choose subscription -&amp;gt; Overview -&amp;gt; Subscription ID)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Paste these four items into the fields in the Azure Monitor API Details section:
&lt;figure
       class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
       style=&#34;max-width: 602px;&#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/v62/config_1_azure_monitor_details.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/v62/config_1_azure_monitor_details.png&#34;data-srcset=&#34;/static/img/docs/v62/config_1_azure_monitor_details.png?w=320 320w, /static/img/docs/v62/config_1_azure_monitor_details.png?w=550 550w, /static/img/docs/v62/config_1_azure_monitor_details.png?w=750 750w, /static/img/docs/v62/config_1_azure_monitor_details.png?w=900 900w, /static/img/docs/v62/config_1_azure_monitor_details.png?w=1040 1040w, /static/img/docs/v62/config_1_azure_monitor_details.png?w=1240 1240w, /static/img/docs/v62/config_1_azure_monitor_details.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Azure Monitor Configuration Details&#34;width=&#34;602&#34;height=&#34;481&#34;title=&#34;Azure Monitor Configuration Details&#34;/&gt;
           &lt;noscript&gt;
             &lt;img
               src=&#34;/static/img/docs/v62/config_1_azure_monitor_details.png&#34;
               alt=&#34;Azure Monitor Configuration Details&#34;width=&#34;602&#34;height=&#34;481&#34;title=&#34;Azure Monitor Configuration Details&#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 Configuration Details&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The Subscription Id can be changed per query. Save the data source and refresh the page to see the list of subscriptions available for the specified Client Id.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you are also using the Azure Log Analytics service, then you need to specify these two config values (or you can reuse the Client Id and Secret from the previous step).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Client Id (Azure Active Directory -&amp;gt; App Registrations -&amp;gt; Choose your app -&amp;gt; Application ID)&lt;/li&gt;
&lt;li&gt;Client Secret (Azure Active Directory -&amp;gt; App Registrations -&amp;gt; Choose your app -&amp;gt; Keys -&amp;gt; Create a key -&amp;gt; Use client secret)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you are using Application Insights, then you need two pieces of information from the Azure Portal (see link above for detailed instructions):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Application ID&lt;/li&gt;
&lt;li&gt;API Key&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Paste these two items into the appropriate fields in the Application Insights API Details section:
&lt;figure
       class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
       style=&#34;max-width: 579px;&#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/v62/config_2_app_insights_api_details.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/v62/config_2_app_insights_api_details.png&#34;data-srcset=&#34;/static/img/docs/v62/config_2_app_insights_api_details.png?w=320 320w, /static/img/docs/v62/config_2_app_insights_api_details.png?w=550 550w, /static/img/docs/v62/config_2_app_insights_api_details.png?w=750 750w, /static/img/docs/v62/config_2_app_insights_api_details.png?w=900 900w, /static/img/docs/v62/config_2_app_insights_api_details.png?w=1040 1040w, /static/img/docs/v62/config_2_app_insights_api_details.png?w=1240 1240w, /static/img/docs/v62/config_2_app_insights_api_details.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Application Insights Configuration Details&#34;width=&#34;579&#34;height=&#34;131&#34;title=&#34;Application Insights Configuration Details&#34;/&gt;
           &lt;noscript&gt;
             &lt;img
               src=&#34;/static/img/docs/v62/config_2_app_insights_api_details.png&#34;
               alt=&#34;Application Insights Configuration Details&#34;width=&#34;579&#34;height=&#34;131&#34;title=&#34;Application Insights Configuration Details&#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;Application Insights Configuration Details&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Test that the configuration details are correct by clicking on the &amp;ldquo;Save &amp;amp; Test&amp;rdquo; button:
&lt;figure
       class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
       style=&#34;max-width: 796px;&#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/v62/config_3_save_and_test.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/v62/config_3_save_and_test.png&#34;data-srcset=&#34;/static/img/docs/v62/config_3_save_and_test.png?w=320 320w, /static/img/docs/v62/config_3_save_and_test.png?w=550 550w, /static/img/docs/v62/config_3_save_and_test.png?w=750 750w, /static/img/docs/v62/config_3_save_and_test.png?w=900 900w, /static/img/docs/v62/config_3_save_and_test.png?w=1040 1040w, /static/img/docs/v62/config_3_save_and_test.png?w=1240 1240w, /static/img/docs/v62/config_3_save_and_test.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Save and Test&#34;width=&#34;796&#34;height=&#34;160&#34;title=&#34;Save and Test&#34;/&gt;
           &lt;noscript&gt;
             &lt;img
               src=&#34;/static/img/docs/v62/config_3_save_and_test.png&#34;
               alt=&#34;Save and Test&#34;width=&#34;796&#34;height=&#34;160&#34;title=&#34;Save and Test&#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;Save and Test&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Alternatively on step 4 if creating a new Azure Active Directory App, use the &lt;a href=&#34;https://docs.microsoft.com/en-us/cli/azure/?view=azure-cli-latest&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Azure CLI&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;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;az ad sp create-for-rbac -n &amp;#34;http://localhost:3000&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;choose-a-service&#34;&gt;Choose a Service&lt;/h2&gt;
&lt;p&gt;In the query editor for a panel, after choosing your Azure Monitor data source, the first option is to choose a service. There are three options here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Azure Monitor&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Application Insights&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Azure Log Analytics&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The query editor will change depending on which one you pick. Azure Monitor is the default.&lt;/p&gt;
&lt;h2 id=&#34;querying-the-azure-monitor-service&#34;&gt;Querying the Azure Monitor Service&lt;/h2&gt;
&lt;p&gt;The Azure Monitor service provides metrics for all the Azure services that you have running. It helps you understand how your applications on Azure are performing and to proactively find issues affecting your applications.&lt;/p&gt;
&lt;p&gt;If your Azure Monitor credentials give you access to multiple subscriptions then choose the appropriate subscription first.&lt;/p&gt;
&lt;p&gt;Examples of metrics that you can get from the service are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Microsoft.Compute/virtualMachines - Percentage CPU&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Microsoft.Network/networkInterfaces - Bytes sent&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Microsoft.Storage/storageAccounts - Used Capacity&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 1585px;&#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/v60/azuremonitor-service-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/v60/azuremonitor-service-query-editor.png&#34;data-srcset=&#34;/static/img/docs/v60/azuremonitor-service-query-editor.png?w=320 320w, /static/img/docs/v60/azuremonitor-service-query-editor.png?w=550 550w, /static/img/docs/v60/azuremonitor-service-query-editor.png?w=750 750w, /static/img/docs/v60/azuremonitor-service-query-editor.png?w=900 900w, /static/img/docs/v60/azuremonitor-service-query-editor.png?w=1040 1040w, /static/img/docs/v60/azuremonitor-service-query-editor.png?w=1240 1240w, /static/img/docs/v60/azuremonitor-service-query-editor.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Azure Monitor Query Editor&#34;width=&#34;1585&#34;height=&#34;508&#34;title=&#34;Azure Monitor Query Editor&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v60/azuremonitor-service-query-editor.png&#34;
            alt=&#34;Azure Monitor Query Editor&#34;width=&#34;1585&#34;height=&#34;508&#34;title=&#34;Azure Monitor 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;Azure Monitor Query Editor&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;formatting-legend-keys-with-aliases-for-the-azure-monitor-service&#34;&gt;Formatting Legend Keys with Aliases for the Azure Monitor Service&lt;/h3&gt;
&lt;p&gt;The default legend formatting for the Azure Monitor API is:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;resourceName{dimensionValue=dimensionName}.metricName&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;These can be quite long but this formatting can be changed using aliases. In the Legend Format field, the aliases which are defined below can be combined any way you want.&lt;/p&gt;
&lt;p&gt;Azure Monitor Examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;dimension: {{dimensionvalue}}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{{resourcegroup}} - {{resourcename}}&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;alias-patterns-for-azure-monitor&#34;&gt;Alias Patterns for Azure Monitor&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;{{resourcegroup}}&lt;/code&gt; = replaced with the value of the Resource Group&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{{namespace}}&lt;/code&gt; = replaced with the value of the Namespace (e.g. Microsoft.Compute/virtualMachines)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{{resourcename}}&lt;/code&gt; = replaced with the value of the Resource Name&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{{metric}}&lt;/code&gt; = replaced with metric name (e.g. Percentage CPU)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{{dimensionname}}&lt;/code&gt; = replaced with dimension key/label (e.g. blobtype)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{{dimensionvalue}}&lt;/code&gt; = replaced with dimension value (e.g. BlockBlob)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;templating-with-variables-for-the-azure-monitor-service&#34;&gt;Templating with Variables for the Azure Monitor Service&lt;/h3&gt;
&lt;p&gt;Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Note that the Azure Monitor service does not support multiple values yet. If you want to visualize multiple time series (for example, metrics for server1 and server2) then you have to add multiple queries to able to view them on the same graph or in the same table.&lt;/p&gt;
&lt;p&gt;The Azure Monitor data source Plugin provides the following queries you can specify in the &lt;code&gt;Query&lt;/code&gt; field in the Variable edit view. They allow you to fill a variable&amp;rsquo;s options list.&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;em&gt;Subscriptions()&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of subscriptions.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;ResourceGroups()&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of resource groups.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;ResourceGroups(12345678-aaaa-bbbb-cccc-123456789aaa)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of resource groups for a specified subscription.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Namespaces(aResourceGroup)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of namespaces for the specified resource group.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Namespaces(12345678-aaaa-bbbb-cccc-123456789aaa, aResourceGroup)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of namespaces for the specified resource group and subscription.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;ResourceNames(aResourceGroup, aNamespace)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of resource names.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;ResourceNames(12345678-aaaa-bbbb-cccc-123456789aaa, aResourceGroup, aNamespace)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of resource names for a specified subscription.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;MetricNamespace(aResourceGroup, aNamespace, aResourceName)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of metric namespaces.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;MetricNamespace(12345678-aaaa-bbbb-cccc-123456789aaa, aResourceGroup, aNamespace, aResourceName)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of metric namespaces for a specified subscription.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;MetricNames(aResourceGroup, aNamespace, aResourceName)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of metric names.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;MetricNames(12345678-aaaa-bbbb-cccc-123456789aaa, aResourceGroup, aNamespace, aResourceName)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of metric names for a specified subscription.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Resource Groups query: &lt;code&gt;ResourceGroups()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Passing in metric name variable: &lt;code&gt;Namespaces(cosmo)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Chaining template variables: &lt;code&gt;ResourceNames($rg, $ns)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Do not quote parameters: &lt;code&gt;MetricNames(hg, Microsoft.Network/publicIPAddresses, grafanaIP)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 940px;&#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/v60/azuremonitor-service-variables.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/v60/azuremonitor-service-variables.png&#34;data-srcset=&#34;/static/img/docs/v60/azuremonitor-service-variables.png?w=320 320w, /static/img/docs/v60/azuremonitor-service-variables.png?w=550 550w, /static/img/docs/v60/azuremonitor-service-variables.png?w=750 750w, /static/img/docs/v60/azuremonitor-service-variables.png?w=900 900w, /static/img/docs/v60/azuremonitor-service-variables.png?w=1040 1040w, /static/img/docs/v60/azuremonitor-service-variables.png?w=1240 1240w, /static/img/docs/v60/azuremonitor-service-variables.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Nested Azure Monitor Template Variables&#34;width=&#34;940&#34;height=&#34;339&#34;title=&#34;Nested Azure Monitor Template Variables&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v60/azuremonitor-service-variables.png&#34;
            alt=&#34;Nested Azure Monitor Template Variables&#34;width=&#34;940&#34;height=&#34;339&#34;title=&#34;Nested Azure Monitor Template Variables&#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;Nested Azure Monitor Template Variables&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Checkout the &lt;a href=&#34;../../../reference/templating/&#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;azure-monitor-metrics-whitelist&#34;&gt;Azure Monitor Metrics Whitelist&lt;/h3&gt;
&lt;p&gt;Not all metrics returned by the Azure Monitor API have values. The Grafana data source has a whitelist to only return metric names if it is possible they might have values. This whitelist is updated regularly as new services and metrics are added to the Azure cloud. You can find the current whitelist &lt;a href=&#34;https://github.com/grafana/grafana/blob/master/public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/supported_namespaces.ts&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;azure-monitor-alerting&#34;&gt;Azure Monitor Alerting&lt;/h3&gt;
&lt;p&gt;Grafana alerting is supported for the Azure Monitor service. This is not Azure Alerts support. Read more about how alerting in Grafana works &lt;a href=&#34;../../../alerting/rules/&#34;&gt;here&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: 2382px;&#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/v60/azuremonitor-alerting.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/v60/azuremonitor-alerting.png&#34;data-srcset=&#34;/static/img/docs/v60/azuremonitor-alerting.png?w=320 320w, /static/img/docs/v60/azuremonitor-alerting.png?w=550 550w, /static/img/docs/v60/azuremonitor-alerting.png?w=750 750w, /static/img/docs/v60/azuremonitor-alerting.png?w=900 900w, /static/img/docs/v60/azuremonitor-alerting.png?w=1040 1040w, /static/img/docs/v60/azuremonitor-alerting.png?w=1240 1240w, /static/img/docs/v60/azuremonitor-alerting.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Azure Monitor Alerting&#34;width=&#34;2382&#34;height=&#34;1076&#34;title=&#34;Azure Monitor Alerting&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v60/azuremonitor-alerting.png&#34;
            alt=&#34;Azure Monitor Alerting&#34;width=&#34;2382&#34;height=&#34;1076&#34;title=&#34;Azure Monitor Alerting&#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 Alerting&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h2 id=&#34;querying-the-application-insights-service&#34;&gt;Querying the Application Insights Service&lt;/h2&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 2376px;&#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/v60/appinsights-service-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/v60/appinsights-service-query-editor.png&#34;data-srcset=&#34;/static/img/docs/v60/appinsights-service-query-editor.png?w=320 320w, /static/img/docs/v60/appinsights-service-query-editor.png?w=550 550w, /static/img/docs/v60/appinsights-service-query-editor.png?w=750 750w, /static/img/docs/v60/appinsights-service-query-editor.png?w=900 900w, /static/img/docs/v60/appinsights-service-query-editor.png?w=1040 1040w, /static/img/docs/v60/appinsights-service-query-editor.png?w=1240 1240w, /static/img/docs/v60/appinsights-service-query-editor.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Application Insights Query Editor&#34;width=&#34;2376&#34;height=&#34;808&#34;title=&#34;Application Insights Query Editor&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v60/appinsights-service-query-editor.png&#34;
            alt=&#34;Application Insights Query Editor&#34;width=&#34;2376&#34;height=&#34;808&#34;title=&#34;Application Insights 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;Application Insights Query Editor&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;formatting-legend-keys-with-aliases-for-the-application-insights-service&#34;&gt;Formatting Legend Keys with Aliases for the Application Insights Service&lt;/h3&gt;
&lt;p&gt;The default legend formatting is:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;metric/name{group/by=&amp;quot;groupbyvalue&amp;quot;}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;In the Legend Format field, the aliases which are defined below can be combined any way you want.&lt;/p&gt;
&lt;p&gt;Application Insights Examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;server: {{groupbyvalue}}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;city: {{groupbyvalue}}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{{groupbyname}}: {{groupbyvalue}}&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;alias-patterns-for-application-insights&#34;&gt;Alias Patterns for Application Insights&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;{{groupbyvalue}}&lt;/code&gt; = replaced with the value of the group by&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{{groupbyname}}&lt;/code&gt; = replaced with the name/label of the group by&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{{metric}}&lt;/code&gt; = replaced with metric name (e.g. requests/count)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;filter-expressions-for-application-insights&#34;&gt;Filter Expressions for Application Insights&lt;/h3&gt;
&lt;p&gt;The filter field takes an OData filter expression.&lt;/p&gt;
&lt;p&gt;Examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;client/city eq &#39;Boydton&#39;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;client/city ne &#39;Boydton&#39;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;client/city ne &#39;Boydton&#39; and client/city ne &#39;Dublin&#39;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;client/city eq &#39;Boydton&#39; or client/city eq &#39;Dublin&#39;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;templating-with-variables-for-application-insights&#34;&gt;Templating with Variables for Application Insights&lt;/h3&gt;
&lt;p&gt;Use the one of the following queries in the &lt;code&gt;Query&lt;/code&gt; field in the Variable edit view.&lt;/p&gt;
&lt;p&gt;Checkout the &lt;a href=&#34;../../../reference/templating/&#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;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;em&gt;AppInsightsMetricNames()&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of metric names.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;AppInsightsGroupBys(aMetricName)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of group bys for the specified metric name.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Metric Names query: &lt;code&gt;AppInsightsMetricNames()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Passing in metric name variable: &lt;code&gt;AppInsightsGroupBys(requests/count)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Chaining template variables: &lt;code&gt;AppInsightsGroupBys($metricnames)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 1872px;&#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/v60/appinsights-service-variables.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/v60/appinsights-service-variables.png&#34;data-srcset=&#34;/static/img/docs/v60/appinsights-service-variables.png?w=320 320w, /static/img/docs/v60/appinsights-service-variables.png?w=550 550w, /static/img/docs/v60/appinsights-service-variables.png?w=750 750w, /static/img/docs/v60/appinsights-service-variables.png?w=900 900w, /static/img/docs/v60/appinsights-service-variables.png?w=1040 1040w, /static/img/docs/v60/appinsights-service-variables.png?w=1240 1240w, /static/img/docs/v60/appinsights-service-variables.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Nested Application Insights Template Variables&#34;width=&#34;1872&#34;height=&#34;708&#34;title=&#34;Nested Application Insights Template Variables&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v60/appinsights-service-variables.png&#34;
            alt=&#34;Nested Application Insights Template Variables&#34;width=&#34;1872&#34;height=&#34;708&#34;title=&#34;Nested Application Insights Template Variables&#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;Nested Application Insights Template Variables&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;application-insights-alerting&#34;&gt;Application Insights Alerting&lt;/h3&gt;
&lt;p&gt;Grafana alerting is supported for Application Insights. This is not Azure Alerts support. Read more about how alerting in Grafana works &lt;a href=&#34;../../../alerting/rules/&#34;&gt;here&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: 2382px;&#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/v60/azuremonitor-alerting.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/v60/azuremonitor-alerting.png&#34;data-srcset=&#34;/static/img/docs/v60/azuremonitor-alerting.png?w=320 320w, /static/img/docs/v60/azuremonitor-alerting.png?w=550 550w, /static/img/docs/v60/azuremonitor-alerting.png?w=750 750w, /static/img/docs/v60/azuremonitor-alerting.png?w=900 900w, /static/img/docs/v60/azuremonitor-alerting.png?w=1040 1040w, /static/img/docs/v60/azuremonitor-alerting.png?w=1240 1240w, /static/img/docs/v60/azuremonitor-alerting.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Azure Monitor Alerting&#34;width=&#34;2382&#34;height=&#34;1076&#34;title=&#34;Azure Monitor Alerting&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v60/azuremonitor-alerting.png&#34;
            alt=&#34;Azure Monitor Alerting&#34;width=&#34;2382&#34;height=&#34;1076&#34;title=&#34;Azure Monitor Alerting&#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 Alerting&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h2 id=&#34;querying-the-azure-log-analytics-service&#34;&gt;Querying the Azure Log Analytics Service&lt;/h2&gt;
&lt;p&gt;Queries are written in the new &lt;a href=&#34;https://docs.loganalytics.io/index&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Azure Log Analytics (or KustoDB) Query Language&lt;/a&gt;. A Log Analytics Query can be formatted as Time Series data or as Table data.&lt;/p&gt;
&lt;p&gt;Time Series queries are for the Graph Panel (and other panels like the Single Stat panel) and must contain a datetime column, a metric name column and a value column. Here is an example query that returns the aggregated count grouped by the Category column and grouped by hour:&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;AzureActivity
| where $__timeFilter(TimeGenerated)
| summarize count() by Category, bin(TimeGenerated, 1h)
| 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 row a list of columns and rows. This example query returns rows with the 6 specified columns:&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;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;p&gt;If your credentials give you access to multiple subscriptions then choose the appropriate subscription first.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 2382px;&#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/v60/azureloganalytics-service-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/v60/azureloganalytics-service-query-editor.png&#34;data-srcset=&#34;/static/img/docs/v60/azureloganalytics-service-query-editor.png?w=320 320w, /static/img/docs/v60/azureloganalytics-service-query-editor.png?w=550 550w, /static/img/docs/v60/azureloganalytics-service-query-editor.png?w=750 750w, /static/img/docs/v60/azureloganalytics-service-query-editor.png?w=900 900w, /static/img/docs/v60/azureloganalytics-service-query-editor.png?w=1040 1040w, /static/img/docs/v60/azureloganalytics-service-query-editor.png?w=1240 1240w, /static/img/docs/v60/azureloganalytics-service-query-editor.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Azure Log Analytics Query Editor&#34;width=&#34;2382&#34;height=&#34;970&#34;title=&#34;Azure Log Analytics Query Editor&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v60/azureloganalytics-service-query-editor.png&#34;
            alt=&#34;Azure Log Analytics Query Editor&#34;width=&#34;2382&#34;height=&#34;970&#34;title=&#34;Azure Log Analytics 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;Azure Log Analytics Query Editor&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;azure-log-analytics-macros&#34;&gt;Azure Log Analytics Macros&lt;/h3&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;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;$__timeFilter()&lt;/code&gt; - Expands to
&lt;code&gt;TimeGenerated ≥ datetime(2018-06-05T18:09:58.907Z) and&lt;/code&gt;
&lt;code&gt;TimeGenerated ≤ 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 From 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; - is to be used with multi-value template variables that contain illegal characters. 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;. 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;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;$__contains(colName, $myVar)&lt;/code&gt; - is to be used 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;, 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 where..in clause.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;azure-log-analytics-builtin-variables&#34;&gt;Azure Log Analytics Builtin Variables&lt;/h3&gt;
&lt;p&gt;There are also some Grafana variables that can be used in Azure Log Analytics queries:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;$__interval&lt;/code&gt; - Grafana calculates the minimum time grain that can be used to group by time in queries. More details on how it works &lt;a href=&#34;../../../reference/templating/#interval-variables&#34;&gt;here&lt;/a&gt;. It returns a time grain like &lt;code&gt;5m&lt;/code&gt; or &lt;code&gt;1h&lt;/code&gt; that can be used in the bin function. E.g. &lt;code&gt;summarize count() by bin(TimeGenerated, $__interval)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;azure-log-analytics-alerting&#34;&gt;Azure Log Analytics Alerting&lt;/h3&gt;
&lt;p&gt;Not implemented yet.&lt;/p&gt;
&lt;h3 id=&#34;writing-analytics-queries-for-the-application-insights-service&#34;&gt;Writing Analytics Queries For the Application Insights Service&lt;/h3&gt;
&lt;p&gt;If you change the service type to &amp;ldquo;Application Insights&amp;rdquo;, the menu icon to the right adds another option, &amp;ldquo;Toggle Edit Mode&amp;rdquo;. Once clicked, the query edit mode changes to give you a full text area in which to write log analytics queries. (This is identical to how the InfluxDB data source lets you write raw queries.)&lt;/p&gt;
&lt;p&gt;Once a query is written, the column names are automatically parsed out of the response data. You can then select them in the &amp;ldquo;X-axis&amp;rdquo;, &amp;ldquo;Y-axis&amp;rdquo;, and &amp;ldquo;Split On&amp;rdquo; dropdown menus, or just type them out.&lt;/p&gt;
&lt;p&gt;There are some important caveats to remember:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;You&amp;rsquo;ll want to order your y-axis in the query, eg. &lt;code&gt;order by timestamp asc&lt;/code&gt;. The graph may come out looking bizarre otherwise. It&amp;rsquo;s better to have Microsoft sort it on their side where it&amp;rsquo;s faster, than to implement this in the plugin.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you copy a log analytics query, typically they&amp;rsquo;ll end with a render instruction, like &lt;code&gt;render barchart&lt;/code&gt;. This is unnecessary, but harmless.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Currently, four default dashboard variables are supported: &lt;code&gt;$__timeFilter()&lt;/code&gt;, &lt;code&gt;$__from&lt;/code&gt;, &lt;code&gt;$__to&lt;/code&gt;, and &lt;code&gt;$__interval&lt;/code&gt;. If you&amp;rsquo;re searching in timestamped data, replace the beginning of your where clause to &lt;code&gt;where $__timeFilter()&lt;/code&gt;. Dashboard changes by time region are handled as you&amp;rsquo;d expect, as long as you leave the name of the &lt;code&gt;timestamp&lt;/code&gt; column alone. Likewise, &lt;code&gt;$__interval&lt;/code&gt; will automatically change based on the dashboard&amp;rsquo;s time region &lt;em&gt;and&lt;/em&gt; the width of the chart being displayed. Use it in bins, so &lt;code&gt;bin(timestamp,$__interval)&lt;/code&gt; changes into something like &lt;code&gt;bin(timestamp,1s)&lt;/code&gt;. Use &lt;code&gt;$__from&lt;/code&gt; and &lt;code&gt;$__to&lt;/code&gt; if you just want the formatted dates to be inserted.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Templated dashboard variables are not yet supported! They will come in a future version.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="using-azure-monitor-in-grafana">Using Azure Monitor in Grafana&lt;/h1>
&lt;blockquote>
&lt;p>Officially released in Grafana v6.0.0&lt;/p>&lt;/blockquote>
&lt;p>As of Grafana 6.0, the Azure Monitor plugin has been moved into Grafana so it now ships with built-in support for Azure Monitor.&lt;/p></description></item><item><title>Using Elasticsearch in Grafana</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/elasticsearch/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/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;em&gt;Elasticsearch&lt;/em&gt; from the &lt;em&gt;Type&lt;/em&gt; dropdown.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;NOTE: 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;em&gt;Name&lt;/em&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;em&gt;Default&lt;/em&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;em&gt;Url&lt;/em&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;em&gt;Access&lt;/em&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;/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;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 to 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.png&#34;
  alt=&#34;Elasticsearch data source details&#34; width=&#34;687&#34;
     height=&#34;148&#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;Be sure to specify your Elasticsearch version in the version selection dropdown. This is very important as there are differences on how queries are composed.
Currently the versions available 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; or &lt;code&gt;7.0&#43;&lt;/code&gt;. The value &lt;code&gt;5.6&#43;&lt;/code&gt; means version 5.6 or higher, but lower than  6.0. The value &lt;code&gt;6.0&#43;&lt;/code&gt; means
version 6.0 or higher, but lower than 7.0. Finally, &lt;code&gt;7.0&#43;&lt;/code&gt; means version 7.0 or higher, but lower than 8.0.&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;logs-beta&#34;&gt;Logs (BETA)&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Only available in Grafana v6.3&#43;.&lt;/p&gt;&lt;/blockquote&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;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.png&#34;
  alt=&#34;Elasticsearch Query Editor&#34; width=&#34;1056&#34;
     height=&#34;171&#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;em&gt;{{term fieldname}}&lt;/em&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;em&gt;{{metric}}&lt;/em&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;em&gt;{{field}}&lt;/em&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&#34;
  data-src=&#34;/static/img/docs/elasticsearch/pipeline_metrics_editor.png&#34;
  alt=&#34;&#34; width=&#34;820&#34;
     height=&#34;280&#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 you metric queries you can use variables in their place.
Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data
being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Checkout the &lt;a href=&#34;../../../reference/templating/&#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.&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;em&gt;{&amp;ldquo;find&amp;rdquo;: &amp;ldquo;fields&amp;rdquo;, &amp;ldquo;type&amp;rdquo;: &amp;ldquo;keyword&amp;rdquo;}&lt;/em&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;em&gt;{&amp;ldquo;find&amp;rdquo;: &amp;ldquo;terms&amp;rdquo;, &amp;ldquo;field&amp;rdquo;: &amp;ldquo;@hostname&amp;rdquo;, &amp;ldquo;size&amp;rdquo;: 1000}&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of values for a field using term aggregation. Query will use current dashboard time range as time range for query.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;{&amp;ldquo;find&amp;rdquo;: &amp;ldquo;terms&amp;rdquo;, &amp;ldquo;field&amp;rdquo;: &amp;ldquo;@hostname&amp;rdquo;, &amp;ldquo;query&amp;rdquo;: &amp;lsquo;&lt;lucene query&gt;&amp;rsquo;}&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of values for a 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&#34;
  data-src=&#34;/static/img/docs/v43/elastic_templating_query.png&#34;
  alt=&#34;&#34; width=&#34;903&#34;
     height=&#34;179&#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;http://play.grafana.org/dashboard/db/elasticsearch-templated&#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;../../../reference/annotations/&#34;&gt;Annotations&lt;/a&gt; allows 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;Query&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;Time&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;Time End&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 regions between time and time-end.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Text&lt;/td&gt;
              &lt;td&gt;Event description field.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Tags&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-beta&#34;&gt;Querying Logs (BETA)&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Only available in Grafana v6.3&#43;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Querying and displaying log data from Elasticsearch is available via &lt;a href=&#34;../../explore/&#34;&gt;Explore&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload&#34;
  data-src=&#34;/static/img/docs/v63/elasticsearch_explore_logs.png&#34;
  alt=&#34;&#34; width=&#34;2710&#34;
     height=&#34;982&#34;/&gt;&lt;/p&gt;
&lt;p&gt;Select the Elasticsearch data source, change to Logs using the Metrics/Logs switcher, and then optionally enter a lucene query into the query field to filter the log messages.&lt;/p&gt;
&lt;p&gt;Finally, press the &lt;code&gt;Enter&lt;/code&gt; key or the &lt;code&gt;Run Query&lt;/code&gt; button to display your logs.&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-beta&#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;#34;[metrics-]YYYY.MM.DD&amp;#34;
    url: http://localhost:9200
    jsonData:
      interval: Daily
      timeField: &amp;#34;@timestamp&amp;#34;&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;#34;[filebeat-]YYYY.MM.DD&amp;#34;
    url: http://localhost:9200
    jsonData:
      interval: Daily
      timeField: &amp;#34;@timestamp&amp;#34;
      esVersion: 70
      logMessageField: message
      logLevelField: fields.level&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&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>Using Graphite in Grafana</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/graphite/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/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;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;Configuration&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;code&gt;Graphite&lt;/code&gt; from the &lt;em&gt;Type&lt;/em&gt; dropdown.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;NOTE: 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;em&gt;Name&lt;/em&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;em&gt;Default&lt;/em&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;em&gt;Url&lt;/em&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;em&gt;Access&lt;/em&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;/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-access-mode&#34;&gt;Browser access mode&lt;/h3&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;h2 id=&#34;metric-editor&#34;&gt;Metric editor&lt;/h2&gt;
&lt;h3 id=&#34;navigate-metric-segments&#34;&gt;Navigate metric segments&lt;/h3&gt;
&lt;p&gt;Click the &lt;code&gt;Select metric&lt;/code&gt; link to start navigating the metric space. One 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/v45/graphite_query1.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/graphite_query1_still.png&#34; class=&#34;screenshot__still lazyload&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;/static/img/docs/v45/graphite_query1.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 to the right 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. To later change
a parameter just click on it and it will turn into a text box. To delete a function click the function name followed
by the x icon.&lt;/p&gt;
&lt;div class=&#34;screenshot&#34; style=&#34;max-width:&#34;&gt;
  &lt;a href=&#34;/static/img/docs/v45/graphite_query2.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/graphite_query2_still.png&#34; class=&#34;screenshot__still lazyload&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;/static/img/docs/v45/graphite_query2.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;optional-parameters&#34;&gt;Optional parameters&lt;/h3&gt;
&lt;p&gt;Some functions like aliasByNode support an optional second argument. To add this parameter specify for example 3,-2 as the first parameter and the function editor will adapt and move the -2 to a second parameter. To remove the second optional parameter just click on it and leave it blank and the editor will remove it.&lt;/p&gt;
&lt;div class=&#34;screenshot&#34; style=&#34;max-width:&#34;&gt;
  &lt;a href=&#34;/static/img/docs/v45/graphite_query3.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/graphite_query3_still.png&#34; class=&#34;screenshot__still lazyload&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;/static/img/docs/v45/graphite_query3.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;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;div class=&#34;screenshot&#34; style=&#34;max-width:&#34;&gt;
  &lt;a href=&#34;/static/img/docs/v45/graphite_nested_queries.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/graphite_nested_queries_still.png&#34; class=&#34;screenshot__still lazyload&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;/static/img/docs/v45/graphite_nested_queries.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;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;em&gt;Notice&lt;/em&gt; This means that legend summary values (max, min, total) cannot be all 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;templating&#34;&gt;Templating&lt;/h2&gt;
&lt;p&gt;Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place.
Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data
being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Checkout the &lt;a href=&#34;../../../reference/templating/&#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;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, then you need to 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;em&gt;tags()&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns all tags.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;tags(server=~backend*)&lt;/em&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;em&gt;tag_values(server)&lt;/em&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;em&gt;tag_values(server, server=~backend*)&lt;/em&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;em&gt;tag_values(server, server=&lt;del&gt;backend*, app=&lt;/del&gt;${apps:regex})&lt;/em&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; will fill the
variable with all possible values that exist in the wildcard position.&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-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; 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;http://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;Checkout the &lt;a href=&#34;../../../reference/templating/#advanced-formatting-options&#34;&gt;Advanced Formatting Options section in the Variables&lt;/a&gt; documentation for examples and details.&lt;/p&gt;
&lt;h2 id=&#34;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;../../../reference/annotations/&#34;&gt;Annotations&lt;/a&gt; allows 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;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;#34;1.1&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&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>Using InfluxDB in Grafana</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/influxdb/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/datasources/influxdb/</guid><content><![CDATA[&lt;h1 id=&#34;using-influxdb-in-grafana&#34;&gt;Using InfluxDB in Grafana&lt;/h1&gt;
&lt;p&gt;Grafana ships with very feature rich data source plugin for InfluxDB. Supporting a feature rich query editor, annotation and templating queries.&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;InfluxDB&lt;/em&gt; from the &lt;em&gt;Type&lt;/em&gt; dropdown.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;NOTE: 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;em&gt;Name&lt;/em&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;em&gt;Default&lt;/em&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;em&gt;Url&lt;/em&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;em&gt;Access&lt;/em&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;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Database&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Name of your InfluxDB database&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;User&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Name of your database user&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Password&lt;/em&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;em&gt;HTTP mode&lt;/em&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;/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-access-mode&#34;&gt;Browser access mode&lt;/h3&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;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;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/v45/influxdb_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/v45/influxdb_query_still.png&#34; class=&#34;screenshot__still lazyload&#34;&gt;
    &lt;img alt=&#34;&#34; src=&#34;/static/img/docs/v45/influxdb_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 InfluxDB 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. The editor allows you to select metrics and tags.&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 select &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
will automatically adjust 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 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/influxdb/select_editor.png&#34;
  alt=&#34;&#34; width=&#34;657&#34;
     height=&#34;46&#34;/&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The above will generate 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 group by 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 please 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;$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;h3 id=&#34;table-query--raw-data&#34;&gt;Table query / raw data&lt;/h3&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload&#34;
  data-src=&#34;/assets/img/blog/v2.6/table_influxdb_logs.png&#34;
  alt=&#34;&#34;/&gt;&lt;/p&gt;
&lt;p&gt;You can remove the group by time by clicking on the &lt;code&gt;time&lt;/code&gt; part and then the &lt;code&gt;x&lt;/code&gt; icon. You can
change the option &lt;code&gt;Format As&lt;/code&gt; to &lt;code&gt;Table&lt;/code&gt; if you want to show raw data in the &lt;code&gt;Table&lt;/code&gt; panel.&lt;/p&gt;
&lt;h2 id=&#34;querying-logs-beta&#34;&gt;Querying Logs (BETA)&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Only available in Grafana v6.3&#43;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Querying and displaying log data from InfluxDB is available via &lt;a href=&#34;../../explore/&#34;&gt;Explore&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload&#34;
  data-src=&#34;/static/img/docs/v63/influxdb_explore_logs.png&#34;
  alt=&#34;&#34; width=&#34;1282&#34;
     height=&#34;697&#34;/&gt;&lt;/p&gt;
&lt;p&gt;Select the InfluxDB data source, change to Logs using the Metrics/Logs switcher,
and then use the &lt;code&gt;Measurements/Fields&lt;/code&gt; button 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;templating&#34;&gt;Templating&lt;/h2&gt;
&lt;p&gt;Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place.
Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data
being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Checkout the &lt;a href=&#34;../../../reference/templating/&#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 InfluxDB exploration (meta data) query. These queries can
return things like measurement names, key names or key values.&lt;/p&gt;
&lt;p&gt;For example you can have a variable that contains all values for tag &lt;code&gt;hostname&lt;/code&gt; 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;SHOW TAG VALUES WITH KEY = &amp;#34;hostname&amp;#34;&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, for example &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:&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;SHOW TAG VALUES WITH KEY = &amp;#34;hostname&amp;#34;  WHERE region =~ /$region/&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can fetch key names for a given measurement.&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;SHOW TAG KEYS [FROM &amp;lt;measurement_name&amp;gt;]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you have a variable with key names you can use this variable in a group by clause. This will allow you to change group by using the variable dropdown at the top
of the dashboard.&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;p&gt;&lt;code&gt;$&amp;lt;varname&amp;gt;&lt;/code&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;SELECT mean(&amp;#34;value&amp;#34;) FROM &amp;#34;logins&amp;#34; WHERE &amp;#34;hostname&amp;#34; =~ /^$host$/ AND $timeFilter GROUP BY time($__interval), &amp;#34;hostname&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;code&gt;[[varname]]&lt;/code&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;SELECT mean(&amp;#34;value&amp;#34;) FROM &amp;#34;logins&amp;#34; WHERE &amp;#34;hostname&amp;#34; =~ /^[[host]]$/ AND $timeFilter GROUP BY time($__interval), &amp;#34;hostname&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&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;p&gt;Example Dashboard:
&lt;a href=&#34;http://play.grafana.org/dashboard/db/influxdb-templated-queries&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;InfluxDB Templated Dashboard&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&#34;ad-hoc-filters-variable&#34;&gt;Ad hoc filters variable&lt;/h3&gt;
&lt;p&gt;InfluxDB supports the special &lt;code&gt;Ad hoc filters&lt;/code&gt; variable type. This variable allows you to specify any number of key/value filters on the fly. These filters will automatically
be applied to all your InfluxDB queries.&lt;/p&gt;
&lt;h2 id=&#34;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;../../../reference/annotations/&#34;&gt;Annotations&lt;/a&gt; allows 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;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 in the above example. You need to have the &lt;code&gt;where $timeFilter&lt;/code&gt;
part. If you only select one column you will not need to enter anything in the column mapping fields. The
Tags field can be a comma separated string.&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 dat asource.&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: InfluxDB
    type: influxdb
    access: proxy
    database: site
    user: grafana
    password: grafana
    url: http://localhost:8086
    jsonData:
      httpMode: GET&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="using-influxdb-in-grafana">Using InfluxDB in Grafana&lt;/h1>
&lt;p>Grafana ships with very feature rich data source plugin for InfluxDB. Supporting a feature rich query editor, annotation and templating queries.&lt;/p></description></item><item><title>Using Loki in Grafana</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/loki/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/datasources/loki/</guid><content><![CDATA[&lt;h1 id=&#34;using-loki-in-grafana&#34;&gt;Using Loki in Grafana&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;BETA: Querying Loki data requires Grafana&amp;rsquo;s Explore section.
Grafana v6.x comes with Explore enabled by default.
In Grafana v5.3.x and v5.4.x. you need to enable Explore manually.
Viewing Loki data in dashboard panels is supported in Grafana v6.4&#43;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Grafana ships with built-in support for Loki, Grafana&amp;rsquo;s log aggregation system.
Just add it as a data source and you are ready to query your log data 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;ol&gt;
&lt;li&gt;Open Grafana and make sure you are logged in.&lt;/li&gt;
&lt;li&gt;In the side menu under the &lt;code&gt;Configuration&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;Add data source&lt;/code&gt; button at the top.&lt;/li&gt;
&lt;li&gt;Select &lt;code&gt;Loki&lt;/code&gt; from the list of data sources.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: 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;em&gt;Name&lt;/em&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;em&gt;Default&lt;/em&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;em&gt;URL&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;The 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;em&gt;Maximum lines&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Upper limit for number of log lines returned by Loki (default is 1000). Decrease 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;h2 id=&#34;querying-logs&#34;&gt;Querying Logs&lt;/h2&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;/features/panels/logs/&#34;&gt;logs panel&lt;/a&gt; in dashboards. Select the Loki data source, and then enter a log query to display your logs.&lt;/p&gt;
&lt;h3 id=&#34;log-queries&#34;&gt;Log Queries&lt;/h3&gt;
&lt;p&gt;A log query consists of two parts: &lt;strong&gt;log stream selector&lt;/strong&gt;, and a &lt;strong&gt;search expression&lt;/strong&gt;. For performance reasons you need to start by choosing a log stream by selecting a log label.&lt;/p&gt;
&lt;p&gt;The Logs Explorer (the &lt;code&gt;Log labels&lt;/code&gt; button) next to the query field shows a list of labels of available log streams. An alternative way to write a query is to use the query field&amp;rsquo;s autocomplete - you start by typing a left curly brace &lt;code&gt;{&lt;/code&gt; and the autocomplete menu will suggest a list of labels. Press the &lt;code&gt;enter&lt;/code&gt; key to execute the query.&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;div class=&#34;medium-6 columns&#34;&gt;
  &lt;video width=&#34;800&#34; height=&#34;500&#34; controls&gt;
    &lt;source src=&#34;/static/assets/videos/explore_loki.mp4&#34; type=&#34;video/mp4&#34;&gt;
    Your browser does not support the video tag.
  &lt;/video&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h3 id=&#34;log-stream-selector&#34;&gt;Log Stream Selector&lt;/h3&gt;
&lt;p&gt;For the label part of the query expression, wrap it in curly braces &lt;code&gt;{}&lt;/code&gt; and then use the key value syntax for selecting labels. Multiple label expressions are separated by a comma:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;{app=&amp;quot;mysql&amp;quot;,name=&amp;quot;mysql-backup&amp;quot;}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The following label matching operators are currently supported:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;=&lt;/code&gt; exactly equal.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;!=&lt;/code&gt; not equal.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;=~&lt;/code&gt; regex-match.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;!~&lt;/code&gt; do not regex-match.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;{name=~&amp;quot;mysql.&#43;&amp;quot;}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{name!~&amp;quot;mysql.&#43;&amp;quot;}&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/basics/#instant-vector-selectors&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;same rules that apply for Prometheus Label Selectors&lt;/a&gt; apply for Loki Log Stream Selectors.&lt;/p&gt;
&lt;p&gt;Another way to add a label selector, is in the table section, clicking on the &lt;strong&gt;Filter&lt;/strong&gt; button beside a label will add the label to the query expression. This even works for multiple queries and will the label selector to each query.&lt;/p&gt;
&lt;h3 id=&#34;search-expression&#34;&gt;Search Expression&lt;/h3&gt;
&lt;p&gt;After writing the Log Stream Selector, you can filter the results further by writing a search expression. The search expression can be just text or a regex expression.&lt;/p&gt;
&lt;p&gt;Example queries:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;{job=&amp;quot;mysql&amp;quot;} |= &amp;quot;error&amp;quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{name=&amp;quot;kafka&amp;quot;} |~ &amp;quot;tsdb-ops.*io:2003&amp;quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{instance=~&amp;quot;kafka-[23]&amp;quot;,name=&amp;quot;kafka&amp;quot;} != &amp;quot;kafka.server:type=ReplicaManager&amp;quot;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Filter operators can be chained and will sequentially filter down the expression. The resulting log lines will satisfy every filter.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;{job=&amp;quot;mysql&amp;quot;} |= &amp;quot;error&amp;quot; != &amp;quot;timeout&amp;quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The following filter types are currently supported:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;|=&lt;/code&gt; line contains string.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;!=&lt;/code&gt; line doesn&amp;rsquo;t contain string.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;|~&lt;/code&gt; line matches regular expression.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;!~&lt;/code&gt; line does not match regular expression.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: For more details about LogQL, Loki&amp;rsquo;s query language, refer to the &lt;a href=&#34;/docs/loki/latest/logql/&#34;&gt;documentation&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;live-tailing&#34;&gt;Live tailing&lt;/h2&gt;
&lt;p&gt;Loki supports Live tailing which displays logs in real-time. This feature is supported in &lt;a href=&#34;/features/explore/#loki-specific-features&#34;&gt;Explore&lt;/a&gt; and in dashboards with a Live toggle in the query editor.&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.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: This feature is only available in Grafana v6.3&#43;&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;log-context&#34;&gt;Log Context&lt;/h2&gt;
&lt;p&gt;When using a search expression as detailed above, you now have the ability to 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;blockquote&gt;
&lt;p&gt;Note: This feature is only available in Grafana v6.3&#43;&lt;/p&gt;&lt;/blockquote&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;Checkout the &lt;a href=&#34;/reference/templating&#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;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;p&gt;You can use any non-metric Loki query as a source for annotations. 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;blockquote&gt;
&lt;p&gt;Note: Annotations for Loki are only available in Grafana v6.4&#43;&lt;/p&gt;&lt;/blockquote&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:&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&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;blockquote>
&lt;p>BETA: Querying Loki data requires Grafana&amp;rsquo;s Explore section.
Grafana v6.x comes with Explore enabled by default.
In Grafana v5.3.x and v5.4.x. you need to enable Explore manually.
Viewing Loki data in dashboard panels is supported in Grafana v6.4+.&lt;/p></description></item><item><title>Using Microsoft SQL Server in Grafana</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/mssql/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/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;blockquote&gt;
&lt;p&gt;Only available in Grafana v5.1&#43;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Grafana ships with a built-in Microsoft SQL Server (MSSQL) data source plugin that allows you to query and visualize data from any Microsoft SQL Server 2005 or newer, including Microsoft Azure SQL 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;Configuration&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;Microsoft SQL Server&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;em&gt;Name&lt;/em&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;em&gt;Default&lt;/em&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;em&gt;Host&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;The IP address/hostname and optional port of your MSSQL instance. If port is omitted, default 1433 will be used.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Database&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Name of your MSSQL database.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;User&lt;/em&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;em&gt;Password&lt;/em&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;em&gt;Encrypt&lt;/em&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; (Grafana v5.4&#43;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Max open&lt;/em&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;em&gt;Max idle&lt;/em&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;em&gt;Max lifetime&lt;/em&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;/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;/reference/templating/#the-interval-variable&#34;&gt;$__interval&lt;/a&gt; and &lt;a href=&#34;/reference/templating/#the-interval-ms-variable&#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 MSSQL 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 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;em&gt;$__time(dateColumn)&lt;/em&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;em&gt;$__timeEpoch(dateColumn)&lt;/em&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;em&gt;$__timeFilter(dateColumn)&lt;/em&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;em&gt;$__timeFrom()&lt;/em&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;em&gt;$__timeTo()&lt;/em&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;em&gt;$__timeGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;[, fillvalue])&lt;/em&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;em&gt;$__timeGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;, 0)&lt;/em&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;em&gt;$__timeGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;, NULL)&lt;/em&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;em&gt;$__timeGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;, previous)&lt;/em&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;em&gt;$__timeGroupAlias(dateColumn,&amp;lsquo;5m&amp;rsquo;)&lt;/em&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;em&gt;$__unixEpochFilter(dateColumn)&lt;/em&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;em&gt;$__unixEpochFrom()&lt;/em&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;em&gt;$__unixEpochTo()&lt;/em&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;em&gt;$__unixEpochNanoFilter(dateColumn)&lt;/em&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;em&gt;$__unixEpochNanoFrom()&lt;/em&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;em&gt;$__unixEpochNanoTo()&lt;/em&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;em&gt;$__unixEpochGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;, [fillmode])&lt;/em&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;em&gt;$__unixEpochGroupAlias(dateColumn,&amp;lsquo;5m&amp;rsquo;, [fillmode])&lt;/em&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 &lt;code&gt;Format as&lt;/code&gt; to &lt;code&gt;Time series&lt;/code&gt;, for use in Graph panel for example, then the query must must have a column named &lt;code&gt;time&lt;/code&gt; that returns either a sql datetime or any numeric datatype representing Unix epoch in seconds. You may return a column named &lt;code&gt;metric&lt;/code&gt; that is used as metric name for the value column. Any column except &lt;code&gt;time&lt;/code&gt; and &lt;code&gt;metric&lt;/code&gt; is treated as a value column. If you omit the &lt;code&gt;metric&lt;/code&gt; column, the name of the value column will be the metric name. You may select multiple value columns, each will have its name as metric.
If you return multiple value columns and a column named &lt;code&gt;metric&lt;/code&gt; then this column is used as prefix for the series name (only available in Grafana 5.3&#43;).&lt;/p&gt;
&lt;p&gt;Resultsets of time series queries need to be sorted by time.&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 metric_values (
  time datetime,
  measurement nvarchar(100),
  valueOne int,
  valueTwo int,
)

INSERT metric_values (time, measurement, valueOne, valueTwo) VALUES(&amp;#39;2018-03-15 12:30:00&amp;#39;, &amp;#39;Metric A&amp;#39;, 62, 6)
INSERT metric_values (time, measurement, valueOne, valueTwo) VALUES(&amp;#39;2018-03-15 12:30:00&amp;#39;, &amp;#39;Metric B&amp;#39;, 49, 11)
...
INSERT metric_values (time, measurement, valueOne, valueTwo) VALUES(&amp;#39;2018-03-15 13:55:00&amp;#39;, &amp;#39;Metric A&amp;#39;, 14, 25)
INSERT metric_values (time, measurement, valueOne, valueTwo) VALUES(&amp;#39;2018-03-15 13:55:00&amp;#39;, &amp;#39;Metric B&amp;#39;, 48, 10)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow docs-image--right&#34;
    style=&#34;max-width: 520px;&#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_time_series_one.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_time_series_one.png&#34;data-srcset=&#34;/static/img/docs/v51/mssql_time_series_one.png?w=320 320w, /static/img/docs/v51/mssql_time_series_one.png?w=550 550w, /static/img/docs/v51/mssql_time_series_one.png?w=750 750w, /static/img/docs/v51/mssql_time_series_one.png?w=900 900w, /static/img/docs/v51/mssql_time_series_one.png?w=1040 1040w, /static/img/docs/v51/mssql_time_series_one.png?w=1240 1240w, /static/img/docs/v51/mssql_time_series_one.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;520&#34;height=&#34;366&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v51/mssql_time_series_one.png&#34;
            alt=&#34;&#34;width=&#34;520&#34;height=&#34;366&#34;class=&#34;docs-image--no-shadow docs-image--right&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;Example with one &lt;code&gt;value&lt;/code&gt; and one &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
  time,
  valueOne,
  measurement as metric
FROM
  metric_values
WHERE
  $__timeFilter(time)
ORDER BY 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When above query are used in a graph panel the result will be two series named &lt;code&gt;Metric A&lt;/code&gt; and &lt;code&gt;Metric B&lt;/code&gt; with value of &lt;code&gt;valueOne&lt;/code&gt; and &lt;code&gt;valueTwo&lt;/code&gt; plotted over &lt;code&gt;time&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;clearfix&#34;&gt;&lt;/div&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow docs-image--right&#34;
    style=&#34;max-width: 519px;&#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_time_series_two.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_time_series_two.png&#34;data-srcset=&#34;/static/img/docs/v51/mssql_time_series_two.png?w=320 320w, /static/img/docs/v51/mssql_time_series_two.png?w=550 550w, /static/img/docs/v51/mssql_time_series_two.png?w=750 750w, /static/img/docs/v51/mssql_time_series_two.png?w=900 900w, /static/img/docs/v51/mssql_time_series_two.png?w=1040 1040w, /static/img/docs/v51/mssql_time_series_two.png?w=1240 1240w, /static/img/docs/v51/mssql_time_series_two.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;519&#34;height=&#34;365&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v51/mssql_time_series_two.png&#34;
            alt=&#34;&#34;width=&#34;519&#34;height=&#34;365&#34;class=&#34;docs-image--no-shadow docs-image--right&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;Example with multiple &lt;code&gt;value&lt;/code&gt; 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
  time,
  valueOne,
  valueTwo
FROM
  metric_values
WHERE
  $__timeFilter(time)
ORDER BY 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When above query are used in a graph panel the result will be two series named &lt;code&gt;valueOne&lt;/code&gt; and &lt;code&gt;valueTwo&lt;/code&gt; with value of &lt;code&gt;valueOne&lt;/code&gt; and &lt;code&gt;valueTwo&lt;/code&gt; plotted over &lt;code&gt;time&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;clearfix&#34;&gt;&lt;/div&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow docs-image--right&#34;
    style=&#34;max-width: 514px;&#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_time_series_three.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_time_series_three.png&#34;data-srcset=&#34;/static/img/docs/v51/mssql_time_series_three.png?w=320 320w, /static/img/docs/v51/mssql_time_series_three.png?w=550 550w, /static/img/docs/v51/mssql_time_series_three.png?w=750 750w, /static/img/docs/v51/mssql_time_series_three.png?w=900 900w, /static/img/docs/v51/mssql_time_series_three.png?w=1040 1040w, /static/img/docs/v51/mssql_time_series_three.png?w=1240 1240w, /static/img/docs/v51/mssql_time_series_three.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;514&#34;height=&#34;366&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v51/mssql_time_series_three.png&#34;
            alt=&#34;&#34;width=&#34;514&#34;height=&#34;366&#34;class=&#34;docs-image--no-shadow docs-image--right&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;Example using the $__timeGroup macro:&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;3m&amp;#39;) as time,
  measurement as metric,
  avg(valueOne)
FROM
  metric_values
WHERE
  $__timeFilter(time)
GROUP BY
  $__timeGroup(time, &amp;#39;3m&amp;#39;),
  measurement
ORDER BY 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When above query are used in a graph panel the result will be two series named &lt;code&gt;Metric A&lt;/code&gt; and &lt;code&gt;Metric B&lt;/code&gt; with an average of &lt;code&gt;valueOne&lt;/code&gt; plotted over &lt;code&gt;time&lt;/code&gt;.
Any two series lacking a value in a 3 minute window will render a line between those two lines. You&amp;rsquo;ll notice that the graph to the right never goes down to zero.&lt;/p&gt;
&lt;div class=&#34;clearfix&#34;&gt;&lt;/div&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow docs-image--right&#34;
    style=&#34;max-width: 516px;&#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_time_series_four.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_time_series_four.png&#34;data-srcset=&#34;/static/img/docs/v51/mssql_time_series_four.png?w=320 320w, /static/img/docs/v51/mssql_time_series_four.png?w=550 550w, /static/img/docs/v51/mssql_time_series_four.png?w=750 750w, /static/img/docs/v51/mssql_time_series_four.png?w=900 900w, /static/img/docs/v51/mssql_time_series_four.png?w=1040 1040w, /static/img/docs/v51/mssql_time_series_four.png?w=1240 1240w, /static/img/docs/v51/mssql_time_series_four.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;516&#34;height=&#34;365&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v51/mssql_time_series_four.png&#34;
            alt=&#34;&#34;width=&#34;516&#34;height=&#34;365&#34;class=&#34;docs-image--no-shadow docs-image--right&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;Example using the $__timeGroup macro with fill parameter set to zero:&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;3m&amp;#39;, 0) as time,
  measurement as metric,
  sum(valueTwo)
FROM
  metric_values
WHERE
  $__timeFilter(time)
GROUP BY
  $__timeGroup(time, &amp;#39;3m&amp;#39;),
  measurement
ORDER BY 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When above query are used in a graph panel the result will be two series named &lt;code&gt;Metric A&lt;/code&gt; and &lt;code&gt;Metric B&lt;/code&gt; with a sum of &lt;code&gt;valueTwo&lt;/code&gt; plotted over &lt;code&gt;time&lt;/code&gt;.
Any series lacking a value in a 3 minute window will have a value of zero which you&amp;rsquo;ll see rendered in the graph to the right.&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 you metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Checkout the &lt;a href=&#34;../../../reference/templating/&#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 MSSQL 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;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 __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;../../../reference/templating/#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;../../../reference/annotations/&#34;&gt;Annotations&lt;/a&gt; allows 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;time&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;text&lt;/td&gt;
              &lt;td&gt;Event description field.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;tags&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 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 why there may exist 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 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 4 series in a graph panel, i.e. 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 actually 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&amp;rsquo;s a lot of lengthy expressions needed -
these could be extracted to MSSQL 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 MSSQL 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;#34;Password!&amp;#34;&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;blockquote>
&lt;p>Only available in Grafana v5.1+.&lt;/p>&lt;/blockquote>
&lt;p>Grafana ships with a built-in Microsoft SQL Server (MSSQL) data source plugin that allows you to query and visualize data from any Microsoft SQL Server 2005 or newer, including Microsoft Azure SQL Database.&lt;/p></description></item><item><title>Using MySQL in Grafana</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/mysql/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/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;Only available in Grafana v4.3&#43;.&lt;/p&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 allow you to query any 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;em&gt;Name&lt;/em&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;em&gt;Default&lt;/em&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;em&gt;Host&lt;/em&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;em&gt;Database&lt;/em&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;em&gt;User&lt;/em&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;em&gt;Password&lt;/em&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;em&gt;Max open&lt;/em&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;em&gt;Max idle&lt;/em&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;em&gt;Max lifetime&lt;/em&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;/reference/templating/#the-interval-variable&#34;&gt;$__interval&lt;/a&gt; and &lt;a href=&#34;/reference/templating/#the-interval-ms-variable&#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;em&gt;$__time(dateColumn)&lt;/em&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;em&gt;$__timeEpoch(dateColumn)&lt;/em&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;em&gt;$__timeFilter(dateColumn)&lt;/em&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;em&gt;$__timeFrom()&lt;/em&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;em&gt;$__timeTo()&lt;/em&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;em&gt;$__timeGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;)&lt;/em&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)&lt;em&gt;300 as signed),&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;$__timeGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;, 0)&lt;/em&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;em&gt;$__timeGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;, NULL)&lt;/em&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;em&gt;$__timeGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;, previous)&lt;/em&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;em&gt;$__timeGroupAlias(dateColumn,&amp;lsquo;5m&amp;rsquo;)&lt;/em&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;em&gt;$__unixEpochFilter(dateColumn)&lt;/em&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;em&gt;$__unixEpochFrom()&lt;/em&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;em&gt;$__unixEpochTo()&lt;/em&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;em&gt;$__unixEpochNanoFilter(dateColumn)&lt;/em&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;em&gt;$__unixEpochNanoFrom()&lt;/em&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;em&gt;$__unixEpochNanoTo()&lt;/em&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;em&gt;$__unixEpochGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;, [fillmode])&lt;/em&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;em&gt;$__unixEpochGroupAlias(dateColumn,&amp;lsquo;5m&amp;rsquo;, [fillmode])&lt;/em&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 show up after a query as 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 &lt;code&gt;Format as&lt;/code&gt; to &lt;code&gt;Time series&lt;/code&gt;, for use in Graph panel for example, then the query must return a column named &lt;code&gt;time&lt;/code&gt; that returns either a sql datetime or any numeric datatype representing Unix epoch.
Any column except &lt;code&gt;time&lt;/code&gt; and &lt;code&gt;metric&lt;/code&gt; is treated as a value column.
You may return a column named &lt;code&gt;metric&lt;/code&gt; that is used as metric name for the value column.
If you return multiple value columns and a column named &lt;code&gt;metric&lt;/code&gt; then this column is used as prefix for the series name (only available in Grafana 5.3&#43;).&lt;/p&gt;
&lt;p&gt;Resultsets of time series queries need to be sorted by time.&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;&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,
  measurement
FROM test_data
WHERE
  $__timeFilter(createdAt)
GROUP BY time, measurement
ORDER BY time&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;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 you metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Checkout the &lt;a href=&#34;../../../reference/templating/&#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 returns 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;../../../reference/templating/#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;../../../reference/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 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;time&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;text&lt;/td&gt;
              &lt;td&gt;Event description field.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;tags&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 is 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
    password: password
    jsonData:
      maxOpenConns: 0         # Grafana v5.4&amp;#43;
      maxIdleConns: 2         # Grafana v5.4&amp;#43;
      connMaxLifetime: 14400  # Grafana v5.4&amp;#43;&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>Only available in Grafana v4.3+.&lt;/p>
&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>Using OpenTSDB in Grafana</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/opentsdb/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/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.&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;OpenTSDB&lt;/em&gt; from the &lt;em&gt;Type&lt;/em&gt; dropdown.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;NOTE: 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;em&gt;Name&lt;/em&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;em&gt;Default&lt;/em&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;em&gt;Url&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;The HTTP protocol, ip and port of you opentsdb server (default port is usually 4242)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Access&lt;/em&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;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Version&lt;/em&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;em&gt;Resolution&lt;/em&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;/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;Note: 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 you metric queries you can use variables in their place.
Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data
being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Checkout the &lt;a href=&#34;../../../reference/templating/&#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;em&gt;metrics(prefix)&lt;/em&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;em&gt;tag_names(cpu)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Return tag names (i.e. keys) for a specific cpu metric&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;tag_values(cpu, hostname)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Return tag values for metric cpu and tag key hostname&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;suggest_tagk(prefix)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Return 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;em&gt;suggest_tagv(prefix)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Return 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;em&gt;tag_values(cpu, hostname, env=$env)&lt;/em&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;em&gt;tag_values(cpu, hostname, env=$env, region=$region)&lt;/em&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 checkout 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.&lt;/p>
&lt;h2 id="adding-the-data-source">Adding the data source&lt;/h2>
&lt;ol>
&lt;li>Open the side menu by clicking the Grafana icon in the top header.&lt;/li>
&lt;li>In the side menu under the &lt;code>Dashboards&lt;/code> link you should find a link named &lt;code>Data Sources&lt;/code>.&lt;/li>
&lt;li>Click the &lt;code>+ Add data source&lt;/code> button in the top header.&lt;/li>
&lt;li>Select &lt;em>OpenTSDB&lt;/em> from the &lt;em>Type&lt;/em> dropdown.&lt;/li>
&lt;/ol>
&lt;blockquote>
&lt;p>NOTE: If you&amp;rsquo;re not seeing the &lt;code>Data Sources&lt;/code> link in your side menu it means that your current user does not have the &lt;code>Admin&lt;/code> role for the current organization.&lt;/p></description></item><item><title>Using PostgreSQL in Grafana</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/postgres/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/datasources/postgres/</guid><content><![CDATA[&lt;h1 id=&#34;using-postgresql-in-grafana&#34;&gt;Using PostgreSQL in Grafana&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;NOTE: In &lt;strong&gt;9.5.18, 9.4.23, 9.6.14, 10.9, 11.4, 12-beta2&lt;/strong&gt; versions of PostgreSQL has a &lt;a href=&#34;https://www.postgresql.org/message-id/flat/28827.1561082086%40sss.pgh.pa.us#df2287bd7481153984bef6bab40af0db&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;bug&lt;/a&gt; which prevents execution of multiple column modifications via &lt;code&gt;ALTER TABLE&lt;/code&gt; statement. Because Grafana uses it during initial database set up and since PostgreSQL has &lt;a href=&#34;https://github.com/postgres/postgres/commit/f946a409143d01951411382fbc3c91c7eb640094&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;fixed&lt;/a&gt; this issue, Grafana &lt;strong&gt;does not support these versions&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&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.&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;Configuration&lt;/code&gt; icon 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;PostgreSQL&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;em&gt;Name&lt;/em&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;em&gt;Default&lt;/em&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;em&gt;Host&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;The IP address/hostname and optional port of your PostgreSQL instance.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Database&lt;/em&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;em&gt;User&lt;/em&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;em&gt;Password&lt;/em&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;em&gt;SSL Mode&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;This option determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Max open&lt;/em&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;em&gt;Max idle&lt;/em&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;em&gt;Max lifetime&lt;/em&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;em&gt;Version&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;This option 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;em&gt;TimescaleDB&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;TimescaleDB is a time-series database built as a PostgreSQL extension. If enabled, Grafana will use &lt;code&gt;time_bucket&lt;/code&gt; in the &lt;code&gt;$__timeGroup&lt;/code&gt; macro and 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;/reference/templating/#the-interval-variable&#34;&gt;$__interval&lt;/a&gt; and &lt;a href=&#34;/reference/templating/#the-interval-ms-variable&#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;blockquote&gt;
&lt;p&gt;Only available in Grafana v5.3&#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/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;em&gt;$__time(dateColumn)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by an expression to rename the column to &lt;code&gt;time&lt;/code&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;em&gt;$__timeSec(dateColumn)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by an expression to rename the column to &lt;code&gt;time&lt;/code&gt; and converting the value to Unix timestamp. For example, &lt;em&gt;extract(epoch from dateColumn) as time&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;$__timeFilter(dateColumn)&lt;/em&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 &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;em&gt;$__timeFrom()&lt;/em&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;em&gt;$__timeTo()&lt;/em&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;em&gt;$__timeGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced by an expression usable in a GROUP BY clause. For example, &lt;em&gt;(extract(epoch from dateColumn)/300)::bigint&lt;/em&gt;300*&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;$__timeGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;, 0)&lt;/em&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 the value.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;$__timeGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;, NULL)&lt;/em&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;em&gt;$__timeGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;, previous)&lt;/em&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;em&gt;$__timeGroupAlias(dateColumn,&amp;lsquo;5m&amp;rsquo;)&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Will be replaced with an expression 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;em&gt;$__unixEpochFilter(dateColumn)&lt;/em&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 timestamps. 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;em&gt;$__unixEpochFrom()&lt;/em&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;em&gt;$__unixEpochTo()&lt;/em&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;em&gt;$__unixEpochNanoFilter(dateColumn)&lt;/em&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 timestamps. 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;em&gt;$__unixEpochNanoFrom()&lt;/em&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;em&gt;$__unixEpochNanoTo()&lt;/em&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;1494497183142514872&lt;/em&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;$__unixEpochGroup(dateColumn,&amp;lsquo;5m&amp;rsquo;, [fillmode])&lt;/em&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;em&gt;$__unixEpochGroupAlias(dateColumn,&amp;lsquo;5m&amp;rsquo;, [fillmode])&lt;/em&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 &lt;code&gt;Format as&lt;/code&gt; to &lt;code&gt;Time series&lt;/code&gt;, for use in Graph panel for example, then the query must return a column named &lt;code&gt;time&lt;/code&gt; that returns either a SQL datetime or any numeric datatype representing Unix epoch.
Any column except &lt;code&gt;time&lt;/code&gt; and &lt;code&gt;metric&lt;/code&gt; are treated as a value column.
You may return a column named &lt;code&gt;metric&lt;/code&gt; that is used as metric name for the value column.
If you return multiple value columns and a column named &lt;code&gt;metric&lt;/code&gt; then this column is used as prefix for the series name (only available in Grafana 5.3&#43;).&lt;/p&gt;
&lt;p&gt;Resultsets of time series queries need to be sorted by time.&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;&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,
  measurement
FROM test_data
WHERE
  $__timeFilter(&amp;#34;createdAt&amp;#34;)
GROUP BY time, measurement
ORDER BY time&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;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 you metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Checkout the &lt;a href=&#34;../../../reference/templating/&#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 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;../../../reference/templating/#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;../../../reference/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 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;time&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;text&lt;/td&gt;
              &lt;td&gt;Event description field.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;tags&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;#34;Password!&amp;#34;
    jsonData:
      sslmode: &amp;#34;disable&amp;#34; # 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;
]]></content><description>&lt;h1 id="using-postgresql-in-grafana">Using PostgreSQL in Grafana&lt;/h1>
&lt;blockquote>
&lt;p>NOTE: In &lt;strong>9.5.18, 9.4.23, 9.6.14, 10.9, 11.4, 12-beta2&lt;/strong> versions of PostgreSQL has a &lt;a href="https://www.postgresql.org/message-id/flat/28827.1561082086%40sss.pgh.pa.us#df2287bd7481153984bef6bab40af0db" target="_blank" rel="noopener noreferrer">bug&lt;/a> which prevents execution of multiple column modifications via &lt;code>ALTER TABLE&lt;/code> statement. Because Grafana uses it during initial database set up and since PostgreSQL has &lt;a href="https://github.com/postgres/postgres/commit/f946a409143d01951411382fbc3c91c7eb640094" target="_blank" rel="noopener noreferrer">fixed&lt;/a> this issue, Grafana &lt;strong>does not support these versions&lt;/strong>&lt;/p></description></item><item><title>Using Prometheus in Grafana</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/prometheus/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/datasources/prometheus/</guid><content><![CDATA[&lt;h1 id=&#34;using-prometheus-in-grafana&#34;&gt;Using Prometheus in Grafana&lt;/h1&gt;
&lt;p&gt;Grafana includes built-in support for Prometheus.&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;code&gt;Prometheus&lt;/code&gt; from the &lt;em&gt;Type&lt;/em&gt; dropdown.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;NOTE: 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;h2 id=&#34;data-source-options&#34;&gt;Data source options&lt;/h2&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;em&gt;Name&lt;/em&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;em&gt;Default&lt;/em&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;em&gt;Url&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;The HTTP protocol, ip and port of you Prometheus server (default port is usually 9090)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Access&lt;/em&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;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Basic Auth&lt;/em&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;em&gt;User&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Name of your Prometheus user&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Password&lt;/em&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;em&gt;Scrape interval&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;This will be used as a lower limit for the Prometheus step query parameter. Default value is 15s.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Custom Query Parameters&lt;/em&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;/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 &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;em&gt;Query expression&lt;/em&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;em&gt;Legend format&lt;/em&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; will be replaced with 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;em&gt;Min step&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Set a lower limit for the Prometheus step option. Step controls how big the jumps are when the Prometheus query engine performs range queries. Sadly there is no official prometheus documentation to link to for this very important option.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Resolution&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Controls the step option. Small steps create high-resolution graphs but can be slow over larger time ranges, lowering the resolution can speed things up. &lt;code&gt;1/2&lt;/code&gt; will try to set step option to generate 1 data point for every other pixel. A value of &lt;code&gt;1/10&lt;/code&gt; will try to set step option so there is a data point every 10 pixels.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Metric lookup&lt;/em&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;em&gt;Format as&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Switch between Table, Time series or Heatmap. Table format will only work in the Table panel. Heatmap format is suitable for displaying metrics having histogram type on Heatmap panel. Under the hood, it converts cumulative histogram to regular and sorts series by the bucket bound.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Instant&lt;/em&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 return results much faster than normal range queries. Use them to look up label sets.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;blockquote&gt;
&lt;p&gt;NOTE: Grafana slightly modifies the request dates for queries to align them with the dynamically calculated step.
This ensures consistent display of metrics data but can result in a small gap of data at the right edge of a graph.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3 id=&#34;instant-queries&#34;&gt;Instant queries&lt;/h3&gt;
&lt;p&gt;The Prometheus datasource allows you to run &amp;ldquo;instant&amp;rdquo; queries, which queries 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 datapoint per series but can be shown in the graph panel with the help of &lt;a href=&#34;/features/panels/graph/#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;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 makes it easy to change the data
being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Checkout the &lt;a href=&#34;../../../reference/templating/&#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;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;label&lt;/em&gt;_&lt;em&gt;names()&lt;/em&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;em&gt;label&lt;/em&gt;_&lt;em&gt;values(label)&lt;/em&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;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;label&lt;/em&gt;_&lt;em&gt;values(metric, label)&lt;/em&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;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;metrics(metric)&lt;/em&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;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;query&lt;/em&gt;_&lt;em&gt;result(query)&lt;/em&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;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;For details of &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;It&amp;rsquo;s possible to 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;, see &lt;a href=&#34;/reference/templating/#global-built-in-variables&#34;&gt;Global built-in variables&lt;/a&gt; for more information. These can be convenient to use in conjunction with the &lt;code&gt;query_result&lt;/code&gt; function when you need to filter variable queries since
&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 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 the more precise &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-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;h2 id=&#34;annotations&#34;&gt;Annotations&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;../../../reference/annotations/&#34;&gt;Annotations&lt;/a&gt; allows 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;getting-grafana-metrics-into-prometheus&#34;&gt;Getting Grafana metrics into Prometheus&lt;/h2&gt;
&lt;p&gt;Since 4.6.0 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;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: Prometheus
    type: prometheus
    access: proxy
    url: http://localhost:9090&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="using-prometheus-in-grafana">Using Prometheus in Grafana&lt;/h1>
&lt;p>Grafana includes built-in support for Prometheus.&lt;/p>
&lt;h2 id="adding-the-data-source">Adding the data source&lt;/h2>
&lt;ol>
&lt;li>Open the side menu by clicking the Grafana icon in the top header.&lt;/li>
&lt;li>In the side menu under the &lt;code>Dashboards&lt;/code> link you should find a link named &lt;code>Data Sources&lt;/code>.&lt;/li>
&lt;li>Click the &lt;code>+ Add data source&lt;/code> button in the top header.&lt;/li>
&lt;li>Select &lt;code>Prometheus&lt;/code> from the &lt;em>Type&lt;/em> dropdown.&lt;/li>
&lt;/ol>
&lt;blockquote>
&lt;p>NOTE: If you&amp;rsquo;re not seeing the &lt;code>Data Sources&lt;/code> link in your side menu it means that your current user does not have the &lt;code>Admin&lt;/code> role for the current organization.&lt;/p></description></item><item><title>Using Stackdriver in Grafana</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/stackdriver/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/datasources/stackdriver/</guid><content><![CDATA[&lt;h1 id=&#34;using-google-stackdriver-in-grafana&#34;&gt;Using Google Stackdriver in Grafana&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;Available as a beta feature in Grafana v5.3.x and v5.4.x.
Officially released in Grafana v6.0.0&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Grafana ships with built-in support for Google Stackdriver. Just add it as a data source and you are ready to build dashboards for your Stackdriver metrics.&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;code&gt;Stackdriver&lt;/code&gt; from the &lt;em&gt;Type&lt;/em&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Upload or paste in the Service Account Key file. See below for steps on how to create a Service Account Key file.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;NOTE: 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;em&gt;Name&lt;/em&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;em&gt;Default&lt;/em&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;em&gt;Service Account Key&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Service Account Key File for a GCP Project. Instructions below on how to create it.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;authentication&#34;&gt;Authentication&lt;/h2&gt;
&lt;p&gt;There are two ways to authenticate the Stackdriver plugin - either by uploading a Google JWT file, or by automatically retrieving credentials from Google metadata server. The latter option is only available when running Grafana on GCE virtual machine.&lt;/p&gt;
&lt;h3 id=&#34;using-a-google-service-account-key-file&#34;&gt;Using a Google Service Account Key File&lt;/h3&gt;
&lt;p&gt;To authenticate with the Stackdriver API, you need to create a Google Cloud Platform (GCP) Service Account for the Project you want to show data for. A Grafana data source integrates with one GCP Project. If you want to visualize data from multiple GCP Projects then you need to create one data source per GCP Project.&lt;/p&gt;
&lt;h4 id=&#34;enable-apis&#34;&gt;Enable APIs&lt;/h4&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: 696px;&#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/v53/stackdriver_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/v53/stackdriver_enable_api.png&#34;data-srcset=&#34;/static/img/docs/v53/stackdriver_enable_api.png?w=320 320w, /static/img/docs/v53/stackdriver_enable_api.png?w=550 550w, /static/img/docs/v53/stackdriver_enable_api.png?w=750 750w, /static/img/docs/v53/stackdriver_enable_api.png?w=900 900w, /static/img/docs/v53/stackdriver_enable_api.png?w=1040 1040w, /static/img/docs/v53/stackdriver_enable_api.png?w=1240 1240w, /static/img/docs/v53/stackdriver_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/v53/stackdriver_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;create-a-gcp-service-account-for-a-project&#34;&gt;Create a GCP Service Account for a Project&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Navigate to the &lt;a href=&#34;https://console.cloud.google.com/apis/credentials&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;APIs and Services Credentials page&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click on the &lt;code&gt;Create credentials&lt;/code&gt; dropdown/button and choose the &lt;code&gt;Service account key&lt;/code&gt; option.&lt;/p&gt;
&lt;figure
        class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
        style=&#34;max-width: 794px;&#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/v53/stackdriver_create_service_account_button.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/v53/stackdriver_create_service_account_button.png&#34;data-srcset=&#34;/static/img/docs/v53/stackdriver_create_service_account_button.png?w=320 320w, /static/img/docs/v53/stackdriver_create_service_account_button.png?w=550 550w, /static/img/docs/v53/stackdriver_create_service_account_button.png?w=750 750w, /static/img/docs/v53/stackdriver_create_service_account_button.png?w=900 900w, /static/img/docs/v53/stackdriver_create_service_account_button.png?w=1040 1040w, /static/img/docs/v53/stackdriver_create_service_account_button.png?w=1240 1240w, /static/img/docs/v53/stackdriver_create_service_account_button.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Create service account button&#34;width=&#34;794&#34;height=&#34;427&#34;title=&#34;Create service account button&#34;/&gt;
            &lt;noscript&gt;
              &lt;img
                src=&#34;/static/img/docs/v53/stackdriver_create_service_account_button.png&#34;
                alt=&#34;Create service account button&#34;width=&#34;794&#34;height=&#34;427&#34;title=&#34;Create service account button&#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;Create service account button&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;On the &lt;code&gt;Create service account key&lt;/code&gt; page, choose key type &lt;code&gt;JSON&lt;/code&gt;. Then in the &lt;code&gt;Service Account&lt;/code&gt; dropdown, choose the &lt;code&gt;New service account&lt;/code&gt; option:&lt;/p&gt;
&lt;figure
        class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
        style=&#34;max-width: 539px;&#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/v53/stackdriver_create_service_account_key.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/v53/stackdriver_create_service_account_key.png&#34;data-srcset=&#34;/static/img/docs/v53/stackdriver_create_service_account_key.png?w=320 320w, /static/img/docs/v53/stackdriver_create_service_account_key.png?w=550 550w, /static/img/docs/v53/stackdriver_create_service_account_key.png?w=750 750w, /static/img/docs/v53/stackdriver_create_service_account_key.png?w=900 900w, /static/img/docs/v53/stackdriver_create_service_account_key.png?w=1040 1040w, /static/img/docs/v53/stackdriver_create_service_account_key.png?w=1240 1240w, /static/img/docs/v53/stackdriver_create_service_account_key.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Create service account key&#34;width=&#34;539&#34;height=&#34;381&#34;title=&#34;Create service account key&#34;/&gt;
            &lt;noscript&gt;
              &lt;img
                src=&#34;/static/img/docs/v53/stackdriver_create_service_account_key.png&#34;
                alt=&#34;Create service account key&#34;width=&#34;539&#34;height=&#34;381&#34;title=&#34;Create service account key&#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;Create service account key&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Some new fields will appear. Fill in a name for the service account in the &lt;code&gt;Service account name&lt;/code&gt; field and then choose the &lt;code&gt;Monitoring Viewer&lt;/code&gt; role from the &lt;code&gt;Role&lt;/code&gt; dropdown:&lt;/p&gt;
&lt;figure
        class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
        style=&#34;max-width: 1076px;&#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/v53/stackdriver_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/v53/stackdriver_service_account_choose_role.png&#34;data-srcset=&#34;/static/img/docs/v53/stackdriver_service_account_choose_role.png?w=320 320w, /static/img/docs/v53/stackdriver_service_account_choose_role.png?w=550 550w, /static/img/docs/v53/stackdriver_service_account_choose_role.png?w=750 750w, /static/img/docs/v53/stackdriver_service_account_choose_role.png?w=900 900w, /static/img/docs/v53/stackdriver_service_account_choose_role.png?w=1040 1040w, /static/img/docs/v53/stackdriver_service_account_choose_role.png?w=1240 1240w, /static/img/docs/v53/stackdriver_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/v53/stackdriver_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;/li&gt;
&lt;li&gt;
&lt;p&gt;Click the Create button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your Stackdriver data.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Upload it to Grafana on the data source Configuration page. You can either upload the file or paste in the contents of the file.&lt;/p&gt;
&lt;figure
        class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
        style=&#34;max-width: 1049px;&#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/v53/stackdriver_grafana_upload_key.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/v53/stackdriver_grafana_upload_key.png&#34;data-srcset=&#34;/static/img/docs/v53/stackdriver_grafana_upload_key.png?w=320 320w, /static/img/docs/v53/stackdriver_grafana_upload_key.png?w=550 550w, /static/img/docs/v53/stackdriver_grafana_upload_key.png?w=750 750w, /static/img/docs/v53/stackdriver_grafana_upload_key.png?w=900 900w, /static/img/docs/v53/stackdriver_grafana_upload_key.png?w=1040 1040w, /static/img/docs/v53/stackdriver_grafana_upload_key.png?w=1240 1240w, /static/img/docs/v53/stackdriver_grafana_upload_key.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Upload service key file to Grafana&#34;width=&#34;1049&#34;height=&#34;521&#34;title=&#34;Upload service key file to Grafana&#34;/&gt;
            &lt;noscript&gt;
              &lt;img
                src=&#34;/static/img/docs/v53/stackdriver_grafana_upload_key.png&#34;
                alt=&#34;Upload service key file to Grafana&#34;width=&#34;1049&#34;height=&#34;521&#34;title=&#34;Upload service key file to Grafana&#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;Upload service key file to Grafana&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The file contents will be encrypted and saved in the Grafana database. Don&amp;rsquo;t forget to save after uploading the file!&lt;/p&gt;
&lt;figure
        class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
        style=&#34;max-width: 1057px;&#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/v53/stackdriver_grafana_key_uploaded.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/v53/stackdriver_grafana_key_uploaded.png&#34;data-srcset=&#34;/static/img/docs/v53/stackdriver_grafana_key_uploaded.png?w=320 320w, /static/img/docs/v53/stackdriver_grafana_key_uploaded.png?w=550 550w, /static/img/docs/v53/stackdriver_grafana_key_uploaded.png?w=750 750w, /static/img/docs/v53/stackdriver_grafana_key_uploaded.png?w=900 900w, /static/img/docs/v53/stackdriver_grafana_key_uploaded.png?w=1040 1040w, /static/img/docs/v53/stackdriver_grafana_key_uploaded.png?w=1240 1240w, /static/img/docs/v53/stackdriver_grafana_key_uploaded.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Service key file is uploaded to Grafana&#34;width=&#34;1057&#34;height=&#34;340&#34;title=&#34;Service key file is uploaded to Grafana&#34;/&gt;
            &lt;noscript&gt;
              &lt;img
                src=&#34;/static/img/docs/v53/stackdriver_grafana_key_uploaded.png&#34;
                alt=&#34;Service key file is uploaded to Grafana&#34;width=&#34;1057&#34;height=&#34;340&#34;title=&#34;Service key file is uploaded to Grafana&#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;Service key file is uploaded to Grafana&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;using-gce-default-service-account&#34;&gt;Using GCE Default Service Account&lt;/h3&gt;
&lt;p&gt;If Grafana is running on a Google Compute Engine (GCE) virtual machine, it is possible for Grafana to automatically retrieve default credentials from the metadata server. This has the advantage of not needing to generate a private key file for the service account and also not having to upload the file to Grafana. However for this to work, there are a few preconditions that need to be met.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;First of all, you need to create a Service Account that can be used by the GCE virtual machine. See detailed instructions on how to do that &lt;a href=&#34;https://cloud.google.com/compute/docs/access/create-enable-service-accounts-for-instances#createanewserviceaccount&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Make sure the GCE virtual machine instance is being run as the service account that you just created. See instructions &lt;a href=&#34;https://cloud.google.com/compute/docs/access/create-enable-service-accounts-for-instances#using&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Allow access to the &lt;code&gt;Stackdriver Monitoring API&lt;/code&gt; scope. See instructions &lt;a href=&#34;changeserviceaccountandscopes&#34;&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Read more about creating and enabling service accounts for GCE VM instances &lt;a href=&#34;https://cloud.google.com/compute/docs/access/create-enable-service-accounts-for-instances&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;metric-query-editor&#34;&gt;Metric Query Editor&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/v53/stackdriver_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/v53/stackdriver_query_editor.png&#34;data-srcset=&#34;/static/img/docs/v53/stackdriver_query_editor.png?w=320 320w, /static/img/docs/v53/stackdriver_query_editor.png?w=550 550w, /static/img/docs/v53/stackdriver_query_editor.png?w=750 750w, /static/img/docs/v53/stackdriver_query_editor.png?w=900 900w, /static/img/docs/v53/stackdriver_query_editor.png?w=1040 1040w, /static/img/docs/v53/stackdriver_query_editor.png?w=1240 1240w, /static/img/docs/v53/stackdriver_query_editor.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;770&#34;height=&#34;359&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v53/stackdriver_query_editor.png&#34;
            alt=&#34;&#34;width=&#34;770&#34;height=&#34;359&#34;class=&#34;docs-image--right&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;The Stackdriver 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;Begin by choosing a &lt;code&gt;Service&lt;/code&gt; and then a metric from the &lt;code&gt;Metric&lt;/code&gt; dropdown. Use the plus and minus icons in the filter and group by sections to add/remove filters or group by clauses.&lt;/p&gt;
&lt;p&gt;Stackdriver metrics can be of different kinds (GAUGE, DELTA, CUMULATIVE) and these kinds have support for different aggregation options (reducers and aligners). The Grafana query editor shows the list of available aggregation methods for a selected metric and sets a default reducer and aligner when you select the metric. Units for the Y-axis are also automatically selected by the query editor.&lt;/p&gt;
&lt;h3 id=&#34;filter&#34;&gt;Filter&lt;/h3&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 filter name and select &lt;code&gt;--remove filter--&lt;/code&gt;.&lt;/p&gt;
&lt;h4 id=&#34;simple-wildcards&#34;&gt;Simple wildcards&lt;/h4&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;h4 id=&#34;regular-expressions&#34;&gt;Regular expressions&lt;/h4&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;h3 id=&#34;aggregation&#34;&gt;Aggregation&lt;/h3&gt;
&lt;p&gt;The aggregation field lets you combine time series based on common statistics. Read more about this option &lt;a href=&#34;https://cloud.google.com/monitoring/charts/metrics-selector#aggregation-options&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;Aligner&lt;/code&gt; field allows you to align multiple time series after the same group by time interval. Read more about how it works &lt;a href=&#34;https://cloud.google.com/monitoring/charts/metrics-selector#alignment&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;alignment-periodgroup-by-time&#34;&gt;Alignment Period/Group by Time&lt;/h4&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 Stackdriver default groupings (which allows you to compare graphs in Grafana with graphs in the Stackdriver UI).
The option is called &lt;code&gt;Stackdriver 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 graph panel. Read more about the details &lt;a href=&#34;http://docs.grafana.org/reference/templating/#the-interval-variable&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It is also possible to 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;h3 id=&#34;group-by&#34;&gt;Group By&lt;/h3&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 by. E.g. Group by instance_name to see an aggregated metric for a Compute instance.&lt;/p&gt;
&lt;h3 id=&#34;alias-patterns&#34;&gt;Alias Patterns&lt;/h3&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;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Example Alias By: &lt;code&gt;{{metric.type}} - {{metric.labels.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;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 you metric queries you can use variables in their place.
Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data
being displayed in your dashboard.&lt;/p&gt;
&lt;p&gt;Checkout the &lt;a href=&#34;../../../reference/templating/&#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 Stackdriver for various types of data. The Stackdriver 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;em&gt;Metric Types&lt;/em&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;em&gt;Labels Keys&lt;/em&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;em&gt;Labels Values&lt;/em&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;em&gt;Resource Types&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of resource types for the the specified metric.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Aggregations&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of aggregations (cross series reducers) for the the specified metric.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Aligners&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of aligners (per series aligners) for the the specified metric.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;Alignment periods&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Returns a list of all alignment periods that are available in Stackdriver query editor in Grafana&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;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: &lt;code&gt;metric.label.$metric_label&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;[[varname]]&lt;/code&gt; Example: &lt;code&gt;metric.label.[[metric_label]]&lt;/code&gt;&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;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/v53/stackdriver_annotations_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/v53/stackdriver_annotations_query_editor.png&#34;data-srcset=&#34;/static/img/docs/v53/stackdriver_annotations_query_editor.png?w=320 320w, /static/img/docs/v53/stackdriver_annotations_query_editor.png?w=550 550w, /static/img/docs/v53/stackdriver_annotations_query_editor.png?w=750 750w, /static/img/docs/v53/stackdriver_annotations_query_editor.png?w=900 900w, /static/img/docs/v53/stackdriver_annotations_query_editor.png?w=1040 1040w, /static/img/docs/v53/stackdriver_annotations_query_editor.png?w=1240 1240w, /static/img/docs/v53/stackdriver_annotations_query_editor.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;&#34;width=&#34;1426&#34;height=&#34;524&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v53/stackdriver_annotations_query_editor.png&#34;
            alt=&#34;&#34;width=&#34;1426&#34;height=&#34;524&#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;../../../reference/annotations/&#34;&gt;Annotations&lt;/a&gt; allows 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 Stackdriver 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 Stackdriver.&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;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 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: Stackdriver
    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: Stackdriver
    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-stackdriver-in-grafana">Using Google Stackdriver in Grafana&lt;/h1>
&lt;blockquote>
&lt;p>Available as a beta feature in Grafana v5.3.x and v5.4.x.
Officially released in Grafana v6.0.0&lt;/p>&lt;/blockquote>
&lt;p>Grafana ships with built-in support for Google Stackdriver. Just add it as a data source and you are ready to build dashboards for your Stackdriver metrics.&lt;/p></description></item><item><title>Using the Mixed Data Source in Grafana</title><link>https://grafana.com/docs/grafana/v6.4/features/datasources/mixed/</link><pubDate>Fri, 06 Mar 2026 22:21:21 +0000</pubDate><guid>https://grafana.com/docs/grafana/v6.4/features/datasources/mixed/</guid><content><![CDATA[&lt;h1 id=&#34;mixed-data-source&#34;&gt;Mixed Data Source&lt;/h1&gt;
&lt;p&gt;This Data Source allows you to specify data source on a per query basis.&lt;/p&gt;
&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&gt;
&lt;p&gt;To use the Mixed Data Source, create a new panel or edit an existing panel and navigate to the Queries tab. From the Query popup, select &amp;ldquo;&amp;ndash; Mixed &amp;ndash;&amp;rdquo;. Click &amp;ldquo;Add Query&amp;rdquo; and select the desired source.&lt;/p&gt;
&lt;p&gt;You cannot change an existing query to use the Mixed Data Source.&lt;/p&gt;
]]></content><description>&lt;h1 id="mixed-data-source">Mixed Data Source&lt;/h1>
&lt;p>This Data Source allows you to specify data source on a per query basis.&lt;/p>
&lt;h2 id="usage">Usage&lt;/h2>
&lt;p>To use the Mixed Data Source, create a new panel or edit an existing panel and navigate to the Queries tab. From the Query popup, select &amp;ldquo;&amp;ndash; Mixed &amp;ndash;&amp;rdquo;. Click &amp;ldquo;Add Query&amp;rdquo; and select the desired source.&lt;/p></description></item></channel></rss>