<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Google Cloud Monitoring data source on Grafana Labs</title><link>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/</link><description>Recent content in Google Cloud Monitoring data source on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/grafana/v12.4/datasources/google-cloud-monitoring/index.xml" rel="self" type="application/rss+xml"/><item><title>Configure the Google Cloud Monitoring data source</title><link>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/configure/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/configure/</guid><content><![CDATA[&lt;h1 id=&#34;configure-the-google-cloud-monitoring-data-source&#34;&gt;Configure the Google Cloud Monitoring data source&lt;/h1&gt;
&lt;p&gt;This document provides instructions for configuring the Google Cloud Monitoring data source in Grafana.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Before you begin, ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Grafana permissions:&lt;/strong&gt; You must have the &lt;code&gt;Organization administrator&lt;/code&gt; role to configure data sources.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GCP project:&lt;/strong&gt; A Google Cloud Platform project.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GCP permissions:&lt;/strong&gt; Permissions to create a service account or configure GCE default service account settings in your GCP project.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Grafana includes built-in support for Google Cloud Monitoring, so you don&amp;rsquo;t need to install a plugin.&lt;/p&gt;
&lt;h2 id=&#34;set-up-gcp-authentication&#34;&gt;Set up GCP authentication&lt;/h2&gt;
&lt;p&gt;Before you can request data from Google Cloud Monitoring, you must configure authentication.
All requests to Google APIs are performed on the server-side by the Grafana backend.&lt;/p&gt;
&lt;p&gt;For authentication options and configuration details, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/google-authentication/&#34;&gt;Google authentication&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When you configure Google authentication, note the following requirements specific to Google Cloud Monitoring.&lt;/p&gt;
&lt;h3 id=&#34;configure-a-gcp-service-account&#34;&gt;Configure a GCP Service Account&lt;/h3&gt;
&lt;p&gt;When you 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/google-authentication/#create-a-gcp-service-account-and-key-file&#34;&gt;create a Google Cloud Platform (GCP) Service Account and key file&lt;/a&gt;, the Service Account must have the &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role (&lt;strong&gt;Role &amp;gt; Select a role &amp;gt; Monitoring &amp;gt; Monitoring Viewer&lt;/strong&gt;):&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 600px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link captioned&#34;
        href=&#34;/static/img/docs/v71/cloudmonitoring_service_account_choose_role.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload mb-0&#34;
          data-src=&#34;/static/img/docs/v71/cloudmonitoring_service_account_choose_role.png&#34;data-srcset=&#34;/static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=320 320w, /static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=550 550w, /static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=750 750w, /static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=900 900w, /static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=1040 1040w, /static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=1240 1240w, /static/img/docs/v71/cloudmonitoring_service_account_choose_role.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Choose role&#34;width=&#34;1076&#34;height=&#34;743&#34;title=&#34;Choose role&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v71/cloudmonitoring_service_account_choose_role.png&#34;
            alt=&#34;Choose role&#34;width=&#34;1076&#34;height=&#34;743&#34;title=&#34;Choose role&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Choose role&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;grant-the-gce-default-service-account-scope&#34;&gt;Grant the GCE Default Service Account scope&lt;/h3&gt;
&lt;p&gt;If Grafana is running on a Google Compute Engine (GCE) virtual machine, when you 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/google-authentication/#use-gce-default-service-account&#34;&gt;configure a GCE Default Service Account&lt;/a&gt;, you must also grant that Service Account access to the &amp;ldquo;Cloud Monitoring API&amp;rdquo; scope.&lt;/p&gt;
&lt;h2 id=&#34;enable-google-cloud-platform-apis&#34;&gt;Enable Google Cloud Platform APIs&lt;/h2&gt;
&lt;p&gt;Before you can request data from Google Cloud Monitoring, you must enable the necessary APIs in your GCP project.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Open the Monitoring and Cloud Resource Manager API pages:&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;/li&gt;
&lt;li&gt;
&lt;p&gt;On each page, click &lt;strong&gt;Enable&lt;/strong&gt;.&lt;/p&gt;
&lt;figure
       class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
       style=&#34;max-width: 450px;&#34;
       itemprop=&#34;associatedMedia&#34;
       itemscope=&#34;&#34;
       itemtype=&#34;http://schema.org/ImageObject&#34;
     &gt;&lt;a
           class=&#34;lightbox-link captioned&#34;
           href=&#34;/static/img/docs/v71/cloudmonitoring_enable_api.png&#34;
           itemprop=&#34;contentUrl&#34;
         &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
             class=&#34;lazyload mb-0&#34;
             data-src=&#34;/static/img/docs/v71/cloudmonitoring_enable_api.png&#34;data-srcset=&#34;/static/img/docs/v71/cloudmonitoring_enable_api.png?w=320 320w, /static/img/docs/v71/cloudmonitoring_enable_api.png?w=550 550w, /static/img/docs/v71/cloudmonitoring_enable_api.png?w=750 750w, /static/img/docs/v71/cloudmonitoring_enable_api.png?w=900 900w, /static/img/docs/v71/cloudmonitoring_enable_api.png?w=1040 1040w, /static/img/docs/v71/cloudmonitoring_enable_api.png?w=1240 1240w, /static/img/docs/v71/cloudmonitoring_enable_api.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Enable GCP APIs&#34;width=&#34;696&#34;height=&#34;373&#34;title=&#34;Enable GCP APIs&#34;/&gt;
           &lt;noscript&gt;
             &lt;img
               src=&#34;/static/img/docs/v71/cloudmonitoring_enable_api.png&#34;
               alt=&#34;Enable GCP APIs&#34;width=&#34;696&#34;height=&#34;373&#34;title=&#34;Enable GCP APIs&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
           &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Enable GCP APIs&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;add-the-data-source&#34;&gt;Add the data source&lt;/h2&gt;
&lt;p&gt;To add the Google Cloud Monitoring data source:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;Connections&lt;/strong&gt; in the left-side menu.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add new connection&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter &lt;code&gt;Google Cloud Monitoring&lt;/code&gt; in the search bar.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Google Cloud Monitoring&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add new data source&lt;/strong&gt; in the upper right.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You&amp;rsquo;re taken to the &lt;strong&gt;Settings&lt;/strong&gt; tab where you configure the data source.&lt;/p&gt;
&lt;h2 id=&#34;configure-the-data-source-in-the-ui&#34;&gt;Configure the data source in the UI&lt;/h2&gt;
&lt;p&gt;The following are configuration options for the Google Cloud Monitoring data source.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Setting&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Name&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Sets the name you use to refer to the data source in panels and queries.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Default&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Sets whether the data source is pre-selected for new panels.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Universe Domain&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;The universe domain to connect to. For more information, refer to the &lt;a href=&#34;https://cloud.google.com/docs/overview#universe_domains&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Google Cloud universe domains documentation&lt;/a&gt;. Defaults to &lt;code&gt;googleapis.com&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;authentication&#34;&gt;Authentication&lt;/h3&gt;
&lt;p&gt;Configure how Grafana authenticates with Google Cloud.&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;Setting&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Authentication type&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Select the authentication method. Choose &lt;strong&gt;Google JWT File&lt;/strong&gt; to use a service account key file, or &lt;strong&gt;GCE Default Service Account&lt;/strong&gt; if Grafana is running on a GCE virtual machine.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;jwt-key-details&#34;&gt;JWT Key Details&lt;/h3&gt;
&lt;p&gt;These settings appear when you select &lt;strong&gt;Google JWT File&lt;/strong&gt; as the authentication 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;Setting&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;JWT token&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Upload or paste your Google JWT token. You can drag and drop a &lt;code&gt;.json&lt;/code&gt; key file, click &lt;strong&gt;Click to browse files&lt;/strong&gt; to upload, or use &lt;strong&gt;Paste JWT Token&lt;/strong&gt; or &lt;strong&gt;Fill In JWT Token manually&lt;/strong&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;service-account-impersonation&#34;&gt;Service account impersonation&lt;/h3&gt;
&lt;p&gt;Use service account impersonation to have Grafana authenticate as a different service account than the one provided in the JWT token.&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;Setting&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Enable&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Toggle to enable service account impersonation.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Service account to impersonate&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Enter the email address of the service account to impersonate when making requests to Google Cloud.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;private-data-source-connect&#34;&gt;Private data source connect&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Only available for Grafana Cloud.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Use private data source connect (PDC) to connect to and query data within a secure network without opening that network to inbound traffic from Grafana Cloud. For more information on how PDC works, refer to &lt;a href=&#34;/docs/grafana-cloud/connect-externally-hosted/private-data-source-connect/&#34;&gt;Private data source connect&lt;/a&gt;. For steps on setting up a PDC connection, refer to &lt;a href=&#34;/docs/grafana-cloud/connect-externally-hosted/private-data-source-connect/configure-pdc/#configure-grafana-private-data-source-connect-pdc&#34;&gt;Configure Grafana private data source connect (PDC)&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;Setting&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Private data source connect&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Select a PDC connection from the drop-down menu or create a new connection.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;save-and-test&#34;&gt;Save and test&lt;/h3&gt;
&lt;p&gt;Click &lt;strong&gt;Save &amp;amp; test&lt;/strong&gt; to test the connection. A successful connection displays the following message:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Successfully queried the Google Cloud Monitoring API.&lt;/code&gt;&lt;/p&gt;
&lt;h2 id=&#34;provision-the-data-source&#34;&gt;Provision the data source&lt;/h2&gt;
&lt;p&gt;You can define and configure the data source in YAML files as part of the Grafana provisioning system.
For more information about provisioning, and for available configuration options, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/administration/provisioning/#data-sources&#34;&gt;Provisioning Grafana&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;provisioning-examples&#34;&gt;Provisioning examples&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Using the JWT (Service Account key file) authentication 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;YAML&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;apiVersion: 1

datasources:
  - name: Google Cloud Monitoring
    type: stackdriver
    access: proxy
    jsonData:
      tokenUri: https://oauth2.googleapis.com/token
      clientEmail: stackdriver@myproject.iam.gserviceaccount.com
      authenticationType: jwt
      defaultProject: my-project-name
      universeDomain: googleapis.com
    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;&lt;strong&gt;Using the JWT (Service Account private key path) authentication 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;YAML&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;apiVersion: 1

datasources:
  - name: Google Cloud Monitoring
    type: stackdriver
    access: proxy
    jsonData:
      tokenUri: https://oauth2.googleapis.com/token
      clientEmail: stackdriver@myproject.iam.gserviceaccount.com
      authenticationType: jwt
      defaultProject: my-project-name
      universeDomain: googleapis.com
      privateKeyPath: /etc/secrets/gce.pem&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Using GCE Default Service Account authentication:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;YAML&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;apiVersion: 1

datasources:
  - name: Google Cloud Monitoring
    type: stackdriver
    access: proxy
    jsonData:
      authenticationType: gce
      universeDomain: googleapis.com&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;provision-the-data-source-using-terraform&#34;&gt;Provision the data source using Terraform&lt;/h2&gt;
&lt;p&gt;You can provision the Google Cloud Monitoring data source using &lt;a href=&#34;https://www.terraform.io/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Terraform&lt;/a&gt; with the &lt;a href=&#34;https://registry.terraform.io/providers/grafana/grafana/latest/docs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana Terraform provider&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For more information about provisioning resources with Terraform, refer to the &lt;a href=&#34;/docs/grafana-cloud/developer-resources/infrastructure-as-code/terraform/&#34;&gt;Grafana as code using Terraform&lt;/a&gt; documentation.&lt;/p&gt;
&lt;h3 id=&#34;terraform-prerequisites&#34;&gt;Terraform prerequisites&lt;/h3&gt;
&lt;p&gt;Before you begin, ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.terraform.io/downloads&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Terraform&lt;/a&gt; installed.&lt;/li&gt;
&lt;li&gt;Grafana Terraform provider configured with appropriate credentials.&lt;/li&gt;
&lt;li&gt;For Grafana Cloud: A &lt;a href=&#34;/docs/grafana-cloud/account-management/authentication-and-permissions/access-policies/&#34;&gt;Cloud Access Policy token&lt;/a&gt; with data source permissions.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;provider-configuration&#34;&gt;Provider configuration&lt;/h3&gt;
&lt;p&gt;Configure the Grafana provider to connect to your Grafana instance:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;hcl&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;terraform {
  required_providers {
    grafana = {
      source  = &amp;#34;grafana/grafana&amp;#34;
      version = &amp;#34;&amp;gt;= 2.0.0&amp;#34;
    }
  }
}

# For Grafana Cloud
provider &amp;#34;grafana&amp;#34; {
  url  = &amp;#34;&amp;lt;YOUR_GRAFANA_CLOUD_STACK_URL&amp;gt;&amp;#34;
  auth = &amp;#34;&amp;lt;YOUR_SERVICE_ACCOUNT_TOKEN&amp;gt;&amp;#34;
}

# For self-hosted Grafana
# provider &amp;#34;grafana&amp;#34; {
#   url  = &amp;#34;http://localhost:3000&amp;#34;
#   auth = &amp;#34;&amp;lt;API_KEY_OR_SERVICE_ACCOUNT_TOKEN&amp;gt;&amp;#34;
# }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;terraform-examples&#34;&gt;Terraform examples&lt;/h3&gt;
&lt;p&gt;The following examples show how to configure the Google Cloud Monitoring data source for each authentication method.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Using the JWT (Service Account key file) authentication 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;hcl&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;resource &amp;#34;grafana_data_source&amp;#34; &amp;#34;google_cloud_monitoring&amp;#34; {
  type = &amp;#34;stackdriver&amp;#34;
  name = &amp;#34;Google Cloud Monitoring&amp;#34;

  json_data_encoded = jsonencode({
    tokenUri           = &amp;#34;https://oauth2.googleapis.com/token&amp;#34;
    clientEmail        = &amp;#34;&amp;lt;SERVICE_ACCOUNT_EMAIL&amp;gt;&amp;#34;
    authenticationType = &amp;#34;jwt&amp;#34;
    defaultProject     = &amp;#34;&amp;lt;GCP_PROJECT_ID&amp;gt;&amp;#34;
    universeDomain     = &amp;#34;googleapis.com&amp;#34;
  })

  secure_json_data_encoded = jsonencode({
    privateKey = &amp;#34;&amp;lt;PRIVATE_KEY_CONTENT&amp;gt;&amp;#34;
  })
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Using the JWT (Service Account private key path) authentication 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;hcl&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;resource &amp;#34;grafana_data_source&amp;#34; &amp;#34;google_cloud_monitoring&amp;#34; {
  type = &amp;#34;stackdriver&amp;#34;
  name = &amp;#34;Google Cloud Monitoring&amp;#34;

  json_data_encoded = jsonencode({
    tokenUri           = &amp;#34;https://oauth2.googleapis.com/token&amp;#34;
    clientEmail        = &amp;#34;&amp;lt;SERVICE_ACCOUNT_EMAIL&amp;gt;&amp;#34;
    authenticationType = &amp;#34;jwt&amp;#34;
    defaultProject     = &amp;#34;&amp;lt;GCP_PROJECT_ID&amp;gt;&amp;#34;
    universeDomain     = &amp;#34;googleapis.com&amp;#34;
    privateKeyPath     = &amp;#34;/etc/secrets/gce.pem&amp;#34;
  })
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Using GCE Default Service Account authentication:&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;hcl&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-hcl&#34;&gt;resource &amp;#34;grafana_data_source&amp;#34; &amp;#34;google_cloud_monitoring&amp;#34; {
  type = &amp;#34;stackdriver&amp;#34;
  name = &amp;#34;Google Cloud Monitoring&amp;#34;

  json_data_encoded = jsonencode({
    authenticationType = &amp;#34;gce&amp;#34;
    universeDomain     = &amp;#34;googleapis.com&amp;#34;
  })
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For all available configuration options, refer to the &lt;a href=&#34;https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/data_source&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana provider data source resource documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;next-steps&#34;&gt;Next steps&lt;/h2&gt;
&lt;p&gt;After you configure the Google Cloud Monitoring data source, you can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/query-editor/&#34;&gt;Query GCP metrics&lt;/a&gt; using the visual Builder, MQL, SLO, or PromQL query types.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/template-variables/&#34;&gt;Create template variables&lt;/a&gt; for dynamic, reusable dashboards.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/annotations/&#34;&gt;Add annotations&lt;/a&gt; to overlay GCP events on your graphs.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/alerting/&#34;&gt;Set up alerting&lt;/a&gt; to receive notifications based on GCP metrics and SLOs.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/explore/&#34;&gt;Explore your data&lt;/a&gt; to investigate metrics without building a dashboard.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/&#34;&gt;Import pre-configured dashboards&lt;/a&gt; for popular GCP services.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="configure-the-google-cloud-monitoring-data-source">Configure the Google Cloud Monitoring data source&lt;/h1>
&lt;p>This document provides instructions for configuring the Google Cloud Monitoring data source in Grafana.&lt;/p>
&lt;h2 id="before-you-begin">Before you begin&lt;/h2>
&lt;p>Before you begin, ensure you have the following:&lt;/p></description></item><item><title>Google authentication</title><link>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/google-authentication/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/google-authentication/</guid><content><![CDATA[&lt;h1 id=&#34;google-authentication&#34;&gt;Google authentication&lt;/h1&gt;
&lt;p&gt;This document explains how to configure authentication between Grafana and Google Cloud Platform (GCP). You must configure authentication before you can use the Google Cloud Monitoring data source to query metrics and SLOs.&lt;/p&gt;
&lt;p&gt;All requests to Google APIs are performed on the server-side by the Grafana backend.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Before you configure authentication, ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A Google Cloud Platform project with the Monitoring API enabled.&lt;/li&gt;
&lt;li&gt;Permissions to create service accounts or configure GCE instance settings in your GCP project.&lt;/li&gt;
&lt;li&gt;Access to the Grafana data source configuration page.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;supported-authentication-methods&#34;&gt;Supported authentication methods&lt;/h2&gt;
&lt;p&gt;The Google Cloud Monitoring data source supports the following authentication methods:&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;Method&lt;/th&gt;
              &lt;th&gt;Use case&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Google JWT File&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Use when Grafana runs outside of GCP, or when you need explicit control over credentials.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;GCE Default Service Account&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Use when Grafana runs on a Google Compute Engine VM with a configured service account.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Service Account Impersonation&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Use when you need Grafana to act as a different service account than the one it authenticates with.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;use-a-google-service-account-key-file&#34;&gt;Use a Google service account key file&lt;/h2&gt;
&lt;p&gt;Use this method when Grafana runs outside of Google Cloud Platform, or when you need explicit control over which credentials are used.&lt;/p&gt;
&lt;p&gt;Each Grafana data source connects to one GCP project by default. To visualize data from multiple GCP projects, create one data source per project, or use service account impersonation.&lt;/p&gt;
&lt;h3 id=&#34;create-a-gcp-service-account-and-key-file&#34;&gt;Create a GCP service account and key file&lt;/h3&gt;
&lt;p&gt;To create a service account and download its key file:&lt;/p&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; in the GCP Console.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click the &lt;strong&gt;Create credentials&lt;/strong&gt; dropdown and select &lt;strong&gt;Service account&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In &lt;strong&gt;Service account name&lt;/strong&gt;, enter a name for the account.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Create and continue&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Grant this service account access to project&lt;/strong&gt; section, select the &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role from the &lt;strong&gt;Role&lt;/strong&gt; dropdown.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Continue&lt;/strong&gt;, then click &lt;strong&gt;Done&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the service accounts list, click the service account you created.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to the &lt;strong&gt;Keys&lt;/strong&gt; tab and click &lt;strong&gt;Add key&lt;/strong&gt; &amp;gt; &lt;strong&gt;Create new key&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select &lt;strong&gt;JSON&lt;/strong&gt; and click &lt;strong&gt;Create&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;A JSON key file downloads to your computer.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Store the key file securely. It grants access to your Google Cloud data.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;upload-the-key-file-to-grafana&#34;&gt;Upload the key file to Grafana&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;In Grafana, navigate to the Google Cloud Monitoring data source configuration page.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Authentication type&lt;/strong&gt;, select &lt;strong&gt;Google JWT File&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Upload the JSON key file using one of the available methods (drag and drop, browse, or paste).&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save &amp;amp; test&lt;/strong&gt; to verify the connection.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;grant-access-to-multiple-projects&#34;&gt;Grant access to multiple projects&lt;/h3&gt;
&lt;p&gt;You can configure a single service account to access multiple GCP projects:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a service account and key file following the steps above.&lt;/li&gt;
&lt;li&gt;Note the service account email address (for example, &lt;code&gt;grafana-monitoring@my-project.iam.gserviceaccount.com&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;In each additional project you want to access:
&lt;ol&gt;
&lt;li&gt;Navigate to &lt;strong&gt;IAM &amp;amp; Admin&lt;/strong&gt; &amp;gt; &lt;strong&gt;IAM&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Grant access&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter the service account email address.&lt;/li&gt;
&lt;li&gt;Assign the &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Use the original key file in Grafana. The service account can now access all configured projects.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;use-gce-default-service-account&#34;&gt;Use GCE Default Service Account&lt;/h2&gt;
&lt;p&gt;When Grafana runs on a Google Compute Engine (GCE) virtual machine, it can automatically retrieve credentials from the GCE metadata server. This method doesn&amp;rsquo;t require you to create or manage key files.&lt;/p&gt;
&lt;h3 id=&#34;prerequisites-for-gce-authentication&#34;&gt;Prerequisites for GCE authentication&lt;/h3&gt;
&lt;p&gt;Before using this method, ensure the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Grafana is running on a GCE virtual machine.&lt;/li&gt;
&lt;li&gt;The VM has a service account assigned with the &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role.&lt;/li&gt;
&lt;li&gt;The VM has the &lt;strong&gt;Cloud Monitoring API&lt;/strong&gt; scope enabled.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;configure-the-gce-instance&#34;&gt;Configure the GCE instance&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;In the GCP Console, navigate to &lt;strong&gt;Compute Engine&lt;/strong&gt; &amp;gt; &lt;strong&gt;VM instances&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Stop the VM if it&amp;rsquo;s running (you can&amp;rsquo;t change scopes on a running VM).&lt;/li&gt;
&lt;li&gt;Click the VM name, then click &lt;strong&gt;Edit&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Service account&lt;/strong&gt;, select a service account with the &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Access scopes&lt;/strong&gt;, select &lt;strong&gt;Set access for each API&lt;/strong&gt; and enable the &lt;strong&gt;Cloud Monitoring API&lt;/strong&gt; (read-only).&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save&lt;/strong&gt; and restart the VM.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-the-data-source&#34;&gt;Configure the data source&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;In Grafana, navigate to the Google Cloud Monitoring data source configuration page.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Authentication type&lt;/strong&gt;, select &lt;strong&gt;GCE Default Service Account&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save &amp;amp; test&lt;/strong&gt; to verify the connection.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For more information about GCE service accounts, refer to the &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;Google documentation on service accounts for instances&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;configure-service-account-impersonation&#34;&gt;Configure service account impersonation&lt;/h2&gt;
&lt;p&gt;Service account impersonation allows Grafana to authenticate as one service account but act as a different service account when making API requests. This is useful for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Accessing resources across multiple projects with a single configuration.&lt;/li&gt;
&lt;li&gt;Following the principle of least privilege by separating authentication from authorization.&lt;/li&gt;
&lt;li&gt;Auditing and tracking which service account accessed specific resources.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;prerequisites-for-impersonation&#34;&gt;Prerequisites for impersonation&lt;/h3&gt;
&lt;p&gt;The service account used by Grafana (the &amp;ldquo;caller&amp;rdquo;) must have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;iam.serviceAccounts.getAccessToken&lt;/code&gt; permission on the target service account.&lt;/li&gt;
&lt;li&gt;This permission is included in the &lt;strong&gt;Service Account Token Creator&lt;/strong&gt; role (&lt;code&gt;roles/iam.serviceAccountTokenCreator&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The service account being impersonated (the &amp;ldquo;target&amp;rdquo;) must have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role on the projects you want to access.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;configure-impersonation&#34;&gt;Configure impersonation&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;In the GCP Console, grant the caller service account the &lt;strong&gt;Service Account Token Creator&lt;/strong&gt; role on the target service account.&lt;/li&gt;
&lt;li&gt;Grant the target service account the &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role on the relevant projects.&lt;/li&gt;
&lt;li&gt;In Grafana, navigate to the Google Cloud Monitoring data source configuration page.&lt;/li&gt;
&lt;li&gt;Configure authentication using either &lt;strong&gt;Google JWT File&lt;/strong&gt; or &lt;strong&gt;GCE Default Service Account&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enable &lt;strong&gt;Service Account Impersonation&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter the email address of the target service account.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save &amp;amp; test&lt;/strong&gt; to verify the connection.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For more information, refer to the &lt;a href=&#34;https://cloud.google.com/iam/docs/service-account-impersonation&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Google documentation on service account impersonation&lt;/a&gt;.&lt;/p&gt;
]]></content><description>&lt;h1 id="google-authentication">Google authentication&lt;/h1>
&lt;p>This document explains how to configure authentication between Grafana and Google Cloud Platform (GCP). You must configure authentication before you can use the Google Cloud Monitoring data source to query metrics and SLOs.&lt;/p></description></item><item><title>Google Cloud Monitoring query editor</title><link>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/query-editor/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/query-editor/</guid><content><![CDATA[&lt;h1 id=&#34;google-cloud-monitoring-query-editor&#34;&gt;Google Cloud Monitoring query editor&lt;/h1&gt;
&lt;p&gt;This topic explains querying specific to the Google Cloud Monitoring data source.
For general documentation on querying data sources in Grafana, see 
    &lt;a href=&#34;/docs/grafana/v12.4/panels-visualizations/query-transform-data/&#34;&gt;Query and transform data&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;query-types&#34;&gt;Query types&lt;/h2&gt;
&lt;p&gt;The Google Cloud Monitoring query editor supports the following query types:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Query type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#query-metrics&#34;&gt;&lt;strong&gt;Builder&lt;/strong&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Build metrics queries visually by selecting a service, metric, filters, and aggregation options.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#use-the-monitoring-query-language&#34;&gt;&lt;strong&gt;MQL&lt;/strong&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Write queries using the Monitoring Query Language for advanced use cases.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#query-service-level-objectives&#34;&gt;&lt;strong&gt;Service Level Objectives (SLO)&lt;/strong&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Query SLO data to track service reliability and error budgets.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#query-with-promql&#34;&gt;&lt;strong&gt;PromQL&lt;/strong&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Write Prometheus-style queries against Google Cloud Monitoring metrics.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;query-metrics&#34;&gt;Query metrics&lt;/h2&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#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 captioned&#34;
        href=&#34;/static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload mb-0&#34;
          data-src=&#34;/static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png&#34;data-srcset=&#34;/static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=320 320w, /static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=550 550w, /static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=750 750w, /static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=900 900w, /static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=1040 1040w, /static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=1240 1240w, /static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Google Cloud Monitoring metrics query builder&#34;width=&#34;1016&#34;height=&#34;291&#34;title=&#34;Google Cloud Monitoring metrics query builder&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/google-cloud-monitoring/metric-query-builder-8-0.png&#34;
            alt=&#34;Google Cloud Monitoring metrics query builder&#34;width=&#34;1016&#34;height=&#34;291&#34;title=&#34;Google Cloud Monitoring metrics query builder&#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;Google Cloud Monitoring metrics query builder&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;The metrics query editor helps you select metrics, group and aggregate by labels and time, and use filters to specify which time series you want to query.&lt;/p&gt;
&lt;h3 id=&#34;create-a-metrics-query&#34;&gt;Create a metrics query&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Select &lt;strong&gt;Builder&lt;/strong&gt; in the &lt;strong&gt;Query type&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Select a project from the &lt;strong&gt;Project&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Select a Google Cloud Platform service from the &lt;strong&gt;Service&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Select a metric from the &lt;strong&gt;Metric&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;(Optional)&lt;/em&gt; Use the plus and minus icons in the filter and group-by sections to add and remove filters or group-by clauses.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Google Cloud Monitoring supports several metrics types, such as &lt;code&gt;GAUGE&lt;/code&gt;, &lt;code&gt;DELTA,&lt;/code&gt; and &lt;code&gt;CUMULATIVE&lt;/code&gt;.
Each supports different aggregation options, such as reducers and aligners. Additionally, metrics have specific value types that can be either scalar or a distribution.&lt;/p&gt;
&lt;p&gt;The metrics query editor lists available aggregation methods for a selected metric, and sets a default aggregation, reducer and aligner when you select a metric.&lt;/p&gt;
&lt;p&gt;In the case that the metric value type is a distribution, the aggregation will be set by default to the mean. For scalar value types, there is no aggregation by default.&lt;/p&gt;
&lt;p&gt;The various metrics are documented &lt;a href=&#34;https://cloud.google.com/monitoring/api/metrics_gcp&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt; and further details on the kinds and types of metrics can be found &lt;a href=&#34;https://cloud.google.com/monitoring/api/v3/kinds-and-types&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Distribution metrics are typically best visualized as either a heatmap or histogram. When visualizing in this way, aggregation is not necessary. However, for other visualization types, performance degradation may be observed when attempting to query distribution metrics that are not aggregated due to the number of potential buckets that can be returned. For more information on how to visualize distribution metrics refer to &lt;a href=&#34;https://cloud.google.com/monitoring/charts/charting-distribution-metrics&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;this page&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;apply-a-filter&#34;&gt;Apply a filter&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;To add and apply a filter:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click the plus icon in the filter section.&lt;/li&gt;
&lt;li&gt;Select a field to filter by.&lt;/li&gt;
&lt;li&gt;Enter a filter value, such as &lt;code&gt;instance_name = grafana-1&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To remove the filter, click the trash icon.&lt;/p&gt;
&lt;h4 id=&#34;use-simple-wildcards&#34;&gt;Use simple wildcards&lt;/h4&gt;
&lt;p&gt;When you set the operator to &lt;code&gt;=&lt;/code&gt; or &lt;code&gt;!=&lt;/code&gt;, you can add wildcards to the filter value field.&lt;/p&gt;
&lt;p&gt;For example, entering &lt;code&gt;us-*&lt;/code&gt; captures all values that start with &amp;ldquo;us-&amp;rdquo;, and entering &lt;code&gt;*central-a&lt;/code&gt; captures all values that end with &amp;ldquo;central-a&amp;rdquo;.
&lt;code&gt;*-central-*&lt;/code&gt; captures all values with the substring of &amp;ldquo;-central-&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Simple wildcards perform better than regular expressions.&lt;/p&gt;
&lt;h4 id=&#34;use-regular-expressions&#34;&gt;Use regular expressions&lt;/h4&gt;
&lt;p&gt;When you set the operator to &lt;code&gt;=~&lt;/code&gt; or &lt;code&gt;!=~&lt;/code&gt;, you can add regular expressions to the filter value field.&lt;/p&gt;
&lt;p&gt;For example, entering &lt;code&gt;us-central[1-3]-[af]&lt;/code&gt; matches all values that start with &amp;ldquo;us-central&amp;rdquo;, then are 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;.&lt;/p&gt;
&lt;p&gt;You don&amp;rsquo;t need leading and trailing slashes when you create these regular expressions.&lt;/p&gt;
&lt;h3 id=&#34;configure-pre-processing-options&#34;&gt;Configure pre-processing options&lt;/h3&gt;
&lt;p&gt;The query editor displays pre-processing options when the selected metric has a metric type of &lt;code&gt;DELTA&lt;/code&gt; or &lt;code&gt;CUMULATIVE&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;Rate&lt;/strong&gt; option aligns and converts data points to a rate per time series.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Delta&lt;/strong&gt; option aligns data points by their delta (difference) per time series.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;group-time-series&#34;&gt;Group time series&lt;/h3&gt;
&lt;p&gt;To combine multiple time series and reduce the amount of data returned for a metric, specify a grouping and a function.&lt;/p&gt;
&lt;h4 id=&#34;group-by&#34;&gt;Group by&lt;/h4&gt;
&lt;p&gt;Use the &lt;strong&gt;Group By&lt;/strong&gt; segment to group resource or metric labels, which reduces the number of time series and aggregates the results by group.&lt;/p&gt;
&lt;p&gt;For example, if you group by &lt;code&gt;instance_name&lt;/code&gt;, Grafana displays an aggregated metric for the specified Compute instance.&lt;/p&gt;
&lt;h5 id=&#34;metadata-labels&#34;&gt;Metadata labels&lt;/h5&gt;
&lt;p&gt;Resource metadata labels contain information that can uniquely identify a resource in Google Cloud.
A time series response returns metadata labels only if they&amp;rsquo;re part of the Group By segment in the time series request.&lt;/p&gt;
&lt;p&gt;There&amp;rsquo;s no API for retrieving metadata labels, so you can&amp;rsquo;t populate the Group By list with the metadata labels that are available for the selected service and metric.
However, the &lt;strong&gt;Group By&lt;/strong&gt; field list comes with a pre-defined set of common system labels.&lt;/p&gt;
&lt;p&gt;You can&amp;rsquo;t pre-define user labels, but you can enter them manually in the &lt;strong&gt;Group By&lt;/strong&gt; field.
If you include a metadata label, user label, or system label in the &lt;strong&gt;Group By&lt;/strong&gt; segment, you can create filters based on it and expand its value on the &lt;strong&gt;Alias&lt;/strong&gt; field.&lt;/p&gt;
&lt;h4 id=&#34;group-by-function&#34;&gt;Group by function&lt;/h4&gt;
&lt;p&gt;To combine the time series in the group into a single time series, select a grouping function.&lt;/p&gt;
&lt;h3 id=&#34;align-data&#34;&gt;Align data&lt;/h3&gt;
&lt;p&gt;You can align all data points received in a fixed length of time by applying an alignment function to combine those data points, and then assigning a timestamp to the result.&lt;/p&gt;
&lt;h4 id=&#34;select-an-alignment-function&#34;&gt;Select an alignment function&lt;/h4&gt;
&lt;p&gt;During alignment, all data points are received in a fixed interval.
Within each interval, as defined by the &lt;a href=&#34;#alignment-period&#34;&gt;alignment period&lt;/a&gt;), and for each time series, the data is aggregated into a single point.
The value of that point is determined by the type of alignment function you use.&lt;/p&gt;
&lt;p&gt;For more information on alignment functions, refer to &lt;a href=&#34;https://cloud.google.com/monitoring/charts/metrics-selector#alignment&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;alignment metric selector&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;define-the-alignment-period&#34;&gt;Define the alignment period&lt;/h4&gt;
&lt;p&gt;You can set the &lt;strong&gt;Alignment Period&lt;/strong&gt; field to group a metric by time if you&amp;rsquo;ve chosen an aggregation.&lt;/p&gt;
&lt;p&gt;The default, called &amp;ldquo;cloud monitoring auto&amp;rdquo;, uses GCP Google Cloud Monitoring&amp;rsquo;s default groupings.
These enable you to compare graphs in Grafana with graphs in the Google Cloud Monitoring UI.&lt;/p&gt;
&lt;p&gt;The default values for &amp;ldquo;cloud monitoring auto&amp;rdquo; 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 &amp;ldquo;grafana auto&amp;rdquo;, which automatically sets the Group By time depending on the time range chosen and width of the time series panel.&lt;/p&gt;
&lt;p&gt;For more information about &amp;ldquo;grafana auto&amp;rdquo;, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/dashboards/variables/add-template-variables/#add-an-interval-variable&#34;&gt;Interval variable&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can also choose fixed time intervals to group by, like &lt;code&gt;1h&lt;/code&gt; or &lt;code&gt;1d&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;set-alias-patterns&#34;&gt;Set alias patterns&lt;/h3&gt;
&lt;p&gt;The &lt;strong&gt;Alias By&lt;/strong&gt; helps you control the format of legend keys.
By default, Grafana shows the metric name and labels, which can be long and difficult to read.&lt;/p&gt;
&lt;p&gt;You can use patterns in the alias field to customize the legend key&amp;rsquo;s format:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Alias pattern&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;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;{{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;{{resource.label.xxx}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the resource label value.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{resource.label.zone}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;us-east1-b&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{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;{{resource.type}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;gce_instance&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metadata.system_labels.xxx}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the metadata system label value.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{metadata.system_labels.name}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;grafana&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{metadata.user_labels.xxx}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the metadata user label value.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;{{metadata.user_labels.tag}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;production&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h4 id=&#34;alias-pattern-examples&#34;&gt;Alias pattern examples&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Using metric labels:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can select from a list of metric and resource labels for a metric in the Group By dropdown.
You can then include them in the legend key using alias patterns.&lt;/p&gt;
&lt;p&gt;For example, given this value of Alias By: &lt;code&gt;{{metric.type}} - {{metric.label.instance_name}}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;An expected result would look like: &lt;code&gt;compute.googleapis.com/instance/cpu/usage_time - server1-prod&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Using the Monitored Resource Type:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can also resolve the name of the Monitored Resource Type with the &lt;code&gt;resource.type&lt;/code&gt; alias.&lt;/p&gt;
&lt;p&gt;For example, given this value of Alias By: &lt;code&gt;{{resource.type}} - {{metric.type}}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;An expected result would look like: &lt;code&gt;gce_instance - compute.googleapis.com/instance/cpu/usage_time&lt;/code&gt;&lt;/p&gt;
&lt;h3 id=&#34;deep-link-from-grafana-panels-to-the-google-cloud-console-metrics-explorer&#34;&gt;Deep-link from Grafana panels to the Google Cloud Console Metrics Explorer&lt;/h3&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 500px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link captioned&#34;
        href=&#34;/static/img/docs/v71/cloudmonitoring_deep_linking.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload mb-0&#34;
          data-src=&#34;/static/img/docs/v71/cloudmonitoring_deep_linking.png&#34;data-srcset=&#34;/static/img/docs/v71/cloudmonitoring_deep_linking.png?w=320 320w, /static/img/docs/v71/cloudmonitoring_deep_linking.png?w=550 550w, /static/img/docs/v71/cloudmonitoring_deep_linking.png?w=750 750w, /static/img/docs/v71/cloudmonitoring_deep_linking.png?w=900 900w, /static/img/docs/v71/cloudmonitoring_deep_linking.png?w=1040 1040w, /static/img/docs/v71/cloudmonitoring_deep_linking.png?w=1240 1240w, /static/img/docs/v71/cloudmonitoring_deep_linking.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Google Cloud Monitoring deep linking&#34;width=&#34;450&#34;height=&#34;163&#34;title=&#34;Google Cloud Monitoring deep linking&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/v71/cloudmonitoring_deep_linking.png&#34;
            alt=&#34;Google Cloud Monitoring deep linking&#34;width=&#34;450&#34;height=&#34;163&#34;title=&#34;Google Cloud Monitoring deep linking&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Google Cloud Monitoring deep linking&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;You can click on a time series in the panel to access a context menu, which contains a link to &lt;strong&gt;View in Metrics Explorer in Google Cloud Console&lt;/strong&gt;.
The link points to the Google Cloud Console&amp;rsquo;s Metrics Explorer and runs the Grafana panel&amp;rsquo;s query there.&lt;/p&gt;
&lt;p&gt;If you select the link, you first select an account in the Google Account Chooser.
Google then redirects you to the Metrics Explorer.&lt;/p&gt;
&lt;p&gt;The provided link is valid for any account, but displays the query only if your account has access to the query&amp;rsquo;s specified GCP project.&lt;/p&gt;
&lt;h3 id=&#34;understand-automatic-unit-detection&#34;&gt;Understand automatic unit detection&lt;/h3&gt;
&lt;p&gt;Grafana issues one query to the Cloud Monitoring API per query editor row, and each API response includes a unit.
Grafana attempts to convert the returned unit into a unit compatible with its time series panel.&lt;/p&gt;
&lt;p&gt;If successful, Grafana displays the unit on the panel&amp;rsquo;s Y-axis.
If the query editor rows return different units, Grafana uses the unit from the last query editor row in the time series panel.&lt;/p&gt;
&lt;h3 id=&#34;use-the-monitoring-query-language&#34;&gt;Use the Monitoring Query Language&lt;/h3&gt;
&lt;p&gt;The Monitoring Query Language (MQL) query builder helps you query and display MQL results in time series format.
To understand basic MQL concepts, refer to &lt;a href=&#34;https://cloud.google.com/monitoring/mql&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Introduction to Monitoring Query Language&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;create-an-mql-query&#34;&gt;Create an MQL query&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;To create an MQL query:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Select &lt;strong&gt;MQL&lt;/strong&gt; in the &lt;strong&gt;Query type&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Select a project from the &lt;strong&gt;Project&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Enter your MQL query in the text area.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;(Optional)&lt;/em&gt; Configure the &lt;strong&gt;Graph period&lt;/strong&gt; setting.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Press &lt;code&gt;Shift&#43;Enter&lt;/code&gt; to run the query.&lt;/p&gt;
&lt;h4 id=&#34;configure-mql-options&#34;&gt;Configure MQL options&lt;/h4&gt;
&lt;p&gt;The following options are available for MQL queries:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Setting&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Alias by&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Control the format of legend keys. Refer to &lt;a href=&#34;#set-alias-patterns-for-mql-queries&#34;&gt;Set alias patterns for MQL queries&lt;/a&gt; for available patterns.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Graph period&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Enable the toggle to override the default time period. Select a period from the dropdown to control the granularity of the returned time series data.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;set-alias-patterns-for-mql-queries&#34;&gt;Set alias patterns for MQL queries&lt;/h3&gt;
&lt;p&gt;MQL queries use the same alias patterns as &lt;a href=&#34;#set-alias-patterns&#34;&gt;metric queries&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;However, &lt;code&gt;{{metric.service}}&lt;/code&gt; is not supported, and &lt;code&gt;{{metric.type}}&lt;/code&gt; and &lt;code&gt;{{metric.name}}&lt;/code&gt; show the time series key in the response.&lt;/p&gt;
&lt;h2 id=&#34;query-service-level-objectives&#34;&gt;Query Service Level Objectives&lt;/h2&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#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 captioned&#34;
        href=&#34;/static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload mb-0&#34;
          data-src=&#34;/static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png&#34;data-srcset=&#34;/static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=320 320w, /static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=550 550w, /static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=750 750w, /static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=900 900w, /static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=1040 1040w, /static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=1240 1240w, /static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Service Level Objectives (SLO) query editor&#34;width=&#34;735&#34;height=&#34;259&#34;title=&#34;Service Level Objectives (SLO) query editor&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/google-cloud-monitoring/slo-query-builder-8-0.png&#34;
            alt=&#34;Service Level Objectives (SLO) query editor&#34;width=&#34;735&#34;height=&#34;259&#34;title=&#34;Service Level Objectives (SLO) 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;Service Level Objectives (SLO) query editor&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;The SLO query builder helps you visualize SLO data in time series format.
To understand basic concepts in service monitoring, refer to the &lt;a href=&#34;https://cloud.google.com/monitoring/service-monitoring&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Google Cloud Monitoring documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;create-an-slo-query&#34;&gt;Create an SLO query&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;To create an SLO query:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Select &lt;strong&gt;Service Level Objectives (SLO)&lt;/strong&gt; in the &lt;strong&gt;Query type&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Select a project from the &lt;strong&gt;Project&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Select an &lt;a href=&#34;https://cloud.google.com/monitoring/api/ref_v3/rest/v3/services&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;SLO service&lt;/a&gt; from the &lt;strong&gt;Service&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Select an &lt;a href=&#34;https://cloud.google.com/monitoring/api/ref_v3/rest/v3/services.serviceLevelObjectives&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;SLO&lt;/a&gt; from the &lt;strong&gt;SLO&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Select a &lt;a href=&#34;https://cloud.google.com/stackdriver/docs/solutions/slo-monitoring/api/timeseries-selectors#ts-selector-list&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;time series selector&lt;/a&gt; from the &lt;strong&gt;Selector&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Grafana&amp;rsquo;s time series selectors use descriptive names that map to system names that Google uses in the Service Monitoring documentation:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Selector dropdown value&lt;/th&gt;
              &lt;th&gt;Corresponding time series selector&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;SLI Value&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;select_slo_health&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;SLO Compliance&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;select_slo_compliance&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;SLO Error Budget Remaining&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;select_slo_budget_fraction&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;SLO Burn Rate&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;select_slo_burn_rate&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;alias-patterns-for-slo-queries&#34;&gt;Alias patterns for SLO queries&lt;/h3&gt;
&lt;p&gt;The &lt;strong&gt;Alias By&lt;/strong&gt; field helps you control the format of legend keys for SLO queries.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Alias pattern&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Example result&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{project}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the GCP project name.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;myProject&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{service}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the service name.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;myService&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{slo}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the SLO.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;latency-slo&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{{selector}}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns the selector.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;select_slo_health&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;alignment-period-and-group-by-time-for-slo-queries&#34;&gt;Alignment period and group-by time for SLO queries&lt;/h3&gt;
&lt;p&gt;SLO queries use the same alignment period functionality as &lt;a href=&#34;#define-the-alignment-period&#34;&gt;metric queries&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;query-with-promql&#34;&gt;Query with PromQL&lt;/h2&gt;
&lt;p&gt;The PromQL query type allows you to query Google Cloud Monitoring metrics using Prometheus Query Language (PromQL) syntax. This is useful if you&amp;rsquo;re familiar with PromQL from Prometheus or Grafana Mimir and want to use the same query syntax with Google Cloud Monitoring data.&lt;/p&gt;
&lt;p&gt;For more information about PromQL support in Google Cloud Monitoring, refer to the &lt;a href=&#34;https://cloud.google.com/monitoring/promql&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Google Cloud documentation on PromQL&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;create-a-promql-query&#34;&gt;Create a PromQL query&lt;/h3&gt;
&lt;p&gt;To create a PromQL query:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Select &lt;strong&gt;PromQL&lt;/strong&gt; in the &lt;strong&gt;Query type&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Select a project from the &lt;strong&gt;Project&lt;/strong&gt; dropdown.&lt;/li&gt;
&lt;li&gt;Enter your PromQL query in the text area.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-promql-options&#34;&gt;Configure PromQL options&lt;/h3&gt;
&lt;p&gt;The following options are available for PromQL queries:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Setting&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Min step&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Defines the lower bounds on the interval between data points. For example, set this to &lt;code&gt;1h&lt;/code&gt; to hint that measurements are taken hourly. Supports the &lt;code&gt;$__interval&lt;/code&gt; and &lt;code&gt;$__rate_interval&lt;/code&gt; macros.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;promql-query-examples&#34;&gt;PromQL query examples&lt;/h3&gt;
&lt;p&gt;The following examples show common PromQL query patterns for Google Cloud Monitoring:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Query CPU utilization for Compute Engine instances:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;promql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-promql&#34;&gt;compute_googleapis_com:instance_cpu_utilization&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Filter by label:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;promql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-promql&#34;&gt;compute_googleapis_com:instance_cpu_utilization{instance_name=&amp;#34;my-instance&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Calculate the rate of a counter metric:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;promql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-promql&#34;&gt;rate(logging_googleapis_com:log_entry_count[5m])&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="google-cloud-monitoring-query-editor">Google Cloud Monitoring query editor&lt;/h1>
&lt;p>This topic explains querying specific to the Google Cloud Monitoring data source.
For general documentation on querying data sources in Grafana, see
&lt;a href="/docs/grafana/v12.4/panels-visualizations/query-transform-data/">Query and transform data&lt;/a>.&lt;/p></description></item><item><title>Google Cloud Monitoring template variables</title><link>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/template-variables/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/template-variables/</guid><content><![CDATA[&lt;h1 id=&#34;google-cloud-monitoring-template-variables&#34;&gt;Google Cloud Monitoring template variables&lt;/h1&gt;
&lt;p&gt;Instead of hard-coding details such as server, application, and sensor names in metric queries, you can use variables.
Grafana lists these variables in dropdown select boxes at the top of the dashboard to help you change the data displayed in your dashboard.
Grafana refers to such variables as template variables.&lt;/p&gt;
&lt;p&gt;For an introduction to templating and template variables, refer to the 
    &lt;a href=&#34;/docs/grafana/v12.4/dashboards/variables/&#34;&gt;Templating&lt;/a&gt; and 
    &lt;a href=&#34;/docs/grafana/v12.4/dashboards/variables/add-template-variables/&#34;&gt;Add and manage variables&lt;/a&gt; documentation.&lt;/p&gt;
&lt;h2 id=&#34;use-query-variables&#34;&gt;Use query variables&lt;/h2&gt;
&lt;p&gt;Variables of the type &lt;em&gt;Query&lt;/em&gt; help you query Google Cloud Monitoring for various types of data.
The Google Cloud Monitoring data source provides the following &lt;strong&gt;Query Types&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;List returned&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Metric Types&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Metric type names available for the specified service.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Labels Keys&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;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;strong&gt;Labels Values&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Values for the label in the specified metric.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Resource Types&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Resource types for the specified metric.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Aggregations&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Aggregations (cross-series reducers) for the specified metric.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Aligners&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Aligners (per-series aligners) for the specified metric.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Alignment periods&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;All alignment periods available in the query editor in Grafana.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Selectors&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Selectors for SLO (Service Level Objectives) queries.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;SLO Services&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Service Monitoring services for SLO queries.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Service Level Objectives (SLO)&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;SLOs for the specified SLO service.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;use-variables-in-queries&#34;&gt;Use variables in queries&lt;/h2&gt;
&lt;p&gt;Use Grafana&amp;rsquo;s variable syntax to include variables in queries.
For details, refer to the 
    &lt;a href=&#34;/docs/grafana/v12.4/dashboards/variables/variable-syntax/&#34;&gt;variable syntax documentation&lt;/a&gt;.&lt;/p&gt;
]]></content><description>&lt;h1 id="google-cloud-monitoring-template-variables">Google Cloud Monitoring template variables&lt;/h1>
&lt;p>Instead of hard-coding details such as server, application, and sensor names in metric queries, you can use variables.
Grafana lists these variables in dropdown select boxes at the top of the dashboard to help you change the data displayed in your dashboard.
Grafana refers to such variables as template variables.&lt;/p></description></item><item><title>Google Cloud Monitoring annotations</title><link>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/annotations/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/annotations/</guid><content><![CDATA[&lt;h1 id=&#34;google-cloud-monitoring-annotations&#34;&gt;Google Cloud Monitoring annotations&lt;/h1&gt;
&lt;p&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/dashboards/build-dashboards/annotate-visualizations/&#34;&gt;Annotations&lt;/a&gt; overlay rich event information on top of graphs. You can use annotations to mark important events, deployments, or incidents on your dashboards.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Before you configure annotations, ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A configured Google Cloud Monitoring data source.&lt;/li&gt;
&lt;li&gt;A dashboard where you want to add annotations.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;annotation-limitations&#34;&gt;Annotation limitations&lt;/h2&gt;
&lt;p&gt;Keep the following limitations in mind when using annotations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Performance:&lt;/strong&gt; Rendering annotations is expensive. Limit the number of rows returned to maintain dashboard performance.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Native events:&lt;/strong&gt; There&amp;rsquo;s no support for displaying Google Cloud Monitoring&amp;rsquo;s native annotations and events. However, annotations work well with &lt;a href=&#34;https://cloud.google.com/monitoring/custom-metrics/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;custom metrics&lt;/a&gt; in Google Cloud Monitoring.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;add-an-annotation-query&#34;&gt;Add an annotation query&lt;/h2&gt;
&lt;p&gt;To add an annotation query to a dashboard:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the dashboard where you want to add annotations.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Dashboard settings&lt;/strong&gt; (gear icon).&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Annotations&lt;/strong&gt; in the left menu.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add annotation query&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select your Google Cloud Monitoring data source.&lt;/li&gt;
&lt;li&gt;Configure the annotation query using the query editor.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;configure-the-annotation-query&#34;&gt;Configure the annotation query&lt;/h2&gt;
&lt;p&gt;With the query editor for annotations, you can select a metric and filters to define which data points create annotations.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;Title&lt;/strong&gt; and &lt;strong&gt;Text&lt;/strong&gt; fields support templating and can use data returned from the query.&lt;/p&gt;
&lt;p&gt;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;h2 id=&#34;annotation-patterns&#34;&gt;Annotation patterns&lt;/h2&gt;
&lt;p&gt;Use the following patterns in the &lt;strong&gt;Title&lt;/strong&gt; and &lt;strong&gt;Text&lt;/strong&gt; fields to display metric data in your annotations:&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 format&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Example&lt;/th&gt;
              &lt;th&gt;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;example-annotate-uptime-check-failures&#34;&gt;Example: Annotate uptime check failures&lt;/h2&gt;
&lt;p&gt;To create annotations for uptime check failures:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Add an annotation query using the Google Cloud Monitoring data source.&lt;/li&gt;
&lt;li&gt;Select the &lt;code&gt;monitoring.googleapis.com/uptime_check/check_passed&lt;/code&gt; metric.&lt;/li&gt;
&lt;li&gt;Add a filter for &lt;code&gt;check_passed = false&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Set the &lt;strong&gt;Title&lt;/strong&gt; to: &lt;code&gt;Uptime check failed: {{metric.label.check_id}}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Set the &lt;strong&gt;Text&lt;/strong&gt; to: &lt;code&gt;Region: {{resource.label.zone}}&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This creates an annotation marker on your graph each time an uptime check fails.&lt;/p&gt;
]]></content><description>&lt;h1 id="google-cloud-monitoring-annotations">Google Cloud Monitoring annotations&lt;/h1>
&lt;p>
&lt;a href="/docs/grafana/v12.4/dashboards/build-dashboards/annotate-visualizations/">Annotations&lt;/a> overlay rich event information on top of graphs. You can use annotations to mark important events, deployments, or incidents on your dashboards.&lt;/p></description></item><item><title>Google Cloud Monitoring alerting</title><link>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/alerting/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/alerting/</guid><content><![CDATA[&lt;h1 id=&#34;google-cloud-monitoring-alerting&#34;&gt;Google Cloud Monitoring alerting&lt;/h1&gt;
&lt;p&gt;The Google Cloud Monitoring data source supports 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/&#34;&gt;Grafana Alerting&lt;/a&gt;, allowing you to create alert rules based on GCP metrics and Service Level Objectives (SLOs). You can monitor your Google Cloud environment and receive notifications when specific conditions are met.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Before you create alert rules, ensure the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You have appropriate permissions to create alert rules in Grafana.&lt;/li&gt;
&lt;li&gt;Your Google Cloud Monitoring data source is configured and working correctly. Refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/configure/&#34;&gt;Configure the data source&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;You&amp;rsquo;re familiar with 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/fundamentals/&#34;&gt;Grafana Alerting concepts&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;supported-query-types-for-alerting&#34;&gt;Supported query types for alerting&lt;/h2&gt;
&lt;p&gt;The following query types support alerting:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Query type&lt;/th&gt;
              &lt;th&gt;Use case&lt;/th&gt;
              &lt;th&gt;Notes&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Builder&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Threshold-based alerts on GCP resource metrics&lt;/td&gt;
              &lt;td&gt;Best suited for alerting; returns time-series data&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;MQL&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Complex metric queries using Monitoring Query Language&lt;/td&gt;
              &lt;td&gt;Use for advanced filtering and aggregations&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Service Level Objectives (SLO)&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Alert on SLO compliance, error budgets, or burn rate&lt;/td&gt;
              &lt;td&gt;Monitor service reliability&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;PromQL&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Prometheus-style queries on GCP metrics&lt;/td&gt;
              &lt;td&gt;Familiar syntax for Prometheus users&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;

&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Alert queries must return numeric data that Grafana can evaluate against a threshold. Queries that return only text or non-numeric data can&amp;rsquo;t be used directly for alerting.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;authentication-requirements&#34;&gt;Authentication requirements&lt;/h2&gt;
&lt;p&gt;Alerting rules run as background processes without a user context. Both supported authentication methods work with alerting:&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;Authentication method&lt;/th&gt;
              &lt;th&gt;Supported&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Google JWT File&lt;/td&gt;
              &lt;td&gt;✓&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;GCE Default Service Account&lt;/td&gt;
              &lt;td&gt;✓&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;create-an-alert-rule&#34;&gt;Create an alert rule&lt;/h2&gt;
&lt;p&gt;To create an alert rule using Google Cloud Monitoring data:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Alerting&lt;/strong&gt; &amp;gt; &lt;strong&gt;Alert rules&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;New alert rule&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a name for your alert rule.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Define query and alert condition&lt;/strong&gt; section:
&lt;ul&gt;
&lt;li&gt;Select your Google Cloud Monitoring data source.&lt;/li&gt;
&lt;li&gt;Configure your query (for example, a Builder query for CPU usage or an SLO query for error budget).&lt;/li&gt;
&lt;li&gt;Add a &lt;strong&gt;Reduce&lt;/strong&gt; expression if your query returns multiple series.&lt;/li&gt;
&lt;li&gt;Add a &lt;strong&gt;Threshold&lt;/strong&gt; expression to define the alert condition.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Configure the &lt;strong&gt;Set evaluation behavior&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Select or create a folder and evaluation group.&lt;/li&gt;
&lt;li&gt;Set the evaluation interval (how often the alert is checked).&lt;/li&gt;
&lt;li&gt;Set the pending period (how long the condition must be true before firing).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Add labels and annotations to provide context for notifications.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save rule&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For detailed instructions, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/create-grafana-managed-rule/&#34;&gt;Create a Grafana-managed alert rule&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;example-vm-cpu-usage-alert&#34;&gt;Example: VM CPU usage alert&lt;/h2&gt;
&lt;p&gt;This example creates an alert that fires when Compute Engine VM CPU utilization exceeds 80%:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a new alert rule.&lt;/li&gt;
&lt;li&gt;Configure the query:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Query type&lt;/strong&gt;: Builder&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Project&lt;/strong&gt;: Select your GCP project&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Service&lt;/strong&gt;: Compute Engine&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Metric&lt;/strong&gt;: &lt;code&gt;instance/cpu/utilization&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Group by function&lt;/strong&gt;: mean&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Add expressions:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Reduce&lt;/strong&gt;: Last (to get the most recent data point)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Threshold&lt;/strong&gt;: Is above 0.8 (CPU utilization is returned as a decimal)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Set evaluation to run every 1 minute with a 5-minute pending period.&lt;/li&gt;
&lt;li&gt;Save the rule.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;example-slo-error-budget-alert&#34;&gt;Example: SLO error budget alert&lt;/h2&gt;
&lt;p&gt;This example alerts when an SLO&amp;rsquo;s error budget remaining drops below 20%:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a new alert rule.&lt;/li&gt;
&lt;li&gt;Configure the query:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Query type&lt;/strong&gt;: Service Level Objectives (SLO)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Project&lt;/strong&gt;: Select your GCP project&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Service&lt;/strong&gt;: Select your SLO service&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SLO&lt;/strong&gt;: Select your SLO&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Selector&lt;/strong&gt;: SLO Error Budget Remaining&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Add expressions:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Reduce&lt;/strong&gt;: Last&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Threshold&lt;/strong&gt;: Is below 0.2 (20% remaining)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Set evaluation to run every 5 minutes.&lt;/li&gt;
&lt;li&gt;Save the rule.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;example-cloud-sql-memory-alert&#34;&gt;Example: Cloud SQL memory alert&lt;/h2&gt;
&lt;p&gt;This example alerts when Cloud SQL instance memory usage exceeds 90%:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a new alert rule.&lt;/li&gt;
&lt;li&gt;Configure the query:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Query type&lt;/strong&gt;: Builder&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Project&lt;/strong&gt;: Select your GCP project&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Service&lt;/strong&gt;: Cloud SQL&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Metric&lt;/strong&gt;: &lt;code&gt;database/memory/utilization&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Filter&lt;/strong&gt;: Add a filter for specific database instances if needed&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Add expressions:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Reduce&lt;/strong&gt;: Last&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Threshold&lt;/strong&gt;: Is above 0.9&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Set evaluation to run every 1 minute.&lt;/li&gt;
&lt;li&gt;Save the rule.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;best-practices&#34;&gt;Best practices&lt;/h2&gt;
&lt;p&gt;Follow these recommendations to create reliable and efficient alerts with Google Cloud Monitoring data.&lt;/p&gt;
&lt;h3 id=&#34;use-appropriate-query-intervals&#34;&gt;Use appropriate query intervals&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Set the alert evaluation interval to be greater than or equal to the minimum data resolution from Google Cloud Monitoring.&lt;/li&gt;
&lt;li&gt;Most GCP metrics have 1-minute granularity at minimum.&lt;/li&gt;
&lt;li&gt;Avoid very short intervals (less than 1 minute) as they may cause evaluation timeouts or miss data points.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;reduce-multiple-series&#34;&gt;Reduce multiple series&lt;/h3&gt;
&lt;p&gt;When your query returns multiple time series (for example, CPU usage across multiple VMs), use the &lt;strong&gt;Reduce&lt;/strong&gt; expression to aggregate them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Last&lt;/strong&gt;: Use the most recent value&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mean&lt;/strong&gt;: Average across all series&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Max/Min&lt;/strong&gt;: Use the highest or lowest value&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sum&lt;/strong&gt;: Total across all series&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;use-appropriate-alignment-periods&#34;&gt;Use appropriate alignment periods&lt;/h3&gt;
&lt;p&gt;For alerting queries, ensure the alignment period provides enough data points:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use &amp;ldquo;cloud monitoring auto&amp;rdquo; or &amp;ldquo;grafana auto&amp;rdquo; for most cases.&lt;/li&gt;
&lt;li&gt;For more precise control, set a fixed alignment period that matches your evaluation interval.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;handle-no-data-conditions&#34;&gt;Handle no data conditions&lt;/h3&gt;
&lt;p&gt;Configure what happens when no data is returned:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In the alert rule, find &lt;strong&gt;Configure no data and error handling&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Choose an appropriate action:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No Data&lt;/strong&gt;: Keep the alert in its current state&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Alerting&lt;/strong&gt;: Treat no data as an alert condition&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OK&lt;/strong&gt;: Treat no data as a healthy state&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;test-queries-before-alerting&#34;&gt;Test queries before alerting&lt;/h3&gt;
&lt;p&gt;Always verify your query returns expected data before creating an alert:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Explore&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select your Google Cloud Monitoring data source.&lt;/li&gt;
&lt;li&gt;Run the query you plan to use for alerting.&lt;/li&gt;
&lt;li&gt;Confirm the data format and values are correct.&lt;/li&gt;
&lt;li&gt;Verify the query returns numeric data suitable for threshold evaluation.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;recording-rules&#34;&gt;Recording rules&lt;/h2&gt;
&lt;p&gt;The Google Cloud Monitoring data source supports 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/create-recording-rules/&#34;&gt;Grafana-managed recording rules&lt;/a&gt;. Recording rules periodically pre-compute frequently used or computationally expensive queries, saving the results as a new time series metric.&lt;/p&gt;
&lt;p&gt;Use recording rules to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Reduce query load on Google Cloud Monitoring by pre-computing complex aggregations.&lt;/li&gt;
&lt;li&gt;Create derived metrics from GCP data for use in alerts and dashboards.&lt;/li&gt;
&lt;li&gt;Import Google Cloud Monitoring data into a Prometheus-compatible database.&lt;/li&gt;
&lt;/ul&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Grafana-managed recording rules write results to a Prometheus-compatible database (such as Grafana Mimir or the Grafana Cloud managed Prometheus). You must configure a target data source for storing the recorded metrics.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;For instructions on creating recording rules, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/create-recording-rules/&#34;&gt;Create recording rules&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;troubleshooting&#34;&gt;Troubleshooting&lt;/h2&gt;
&lt;p&gt;If your Google Cloud Monitoring alerts aren&amp;rsquo;t working as expected, use the following sections to diagnose and resolve common issues.&lt;/p&gt;
&lt;h3 id=&#34;alerts-not-firing&#34;&gt;Alerts not firing&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Check that the query returns numeric data in Explore.&lt;/li&gt;
&lt;li&gt;Ensure the evaluation interval allows enough time for data to be available.&lt;/li&gt;
&lt;li&gt;Verify the threshold is set correctly (remember that many GCP metrics return decimals, not percentages).&lt;/li&gt;
&lt;li&gt;Review the alert rule&amp;rsquo;s health and any error messages in the Alerting UI.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;authentication-errors-in-alert-evaluation&#34;&gt;Authentication errors in alert evaluation&lt;/h3&gt;
&lt;p&gt;If you see authentication errors when alerts evaluate:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Verify the service account has the &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role.&lt;/li&gt;
&lt;li&gt;If using a JWT key file, ensure it hasn&amp;rsquo;t been deleted or revoked.&lt;/li&gt;
&lt;li&gt;Check that the required APIs (Monitoring API, Cloud Resource Manager API) are enabled.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;query-timeout-errors&#34;&gt;Query timeout errors&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Increase the alignment period to reduce the number of data points.&lt;/li&gt;
&lt;li&gt;Reduce the time range in the query.&lt;/li&gt;
&lt;li&gt;Simplify complex MQL queries.&lt;/li&gt;
&lt;li&gt;Add filters to narrow the result set.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For additional troubleshooting help, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/troubleshooting/&#34;&gt;Troubleshoot Google Cloud Monitoring&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;additional-resources&#34;&gt;Additional resources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/&#34;&gt;Grafana Alerting documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/create-grafana-managed-rule/&#34;&gt;Create alert rules&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/alerting/alerting-rules/create-recording-rules/&#34;&gt;Create recording rules&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/query-editor/&#34;&gt;Google Cloud Monitoring query editor&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="google-cloud-monitoring-alerting">Google Cloud Monitoring alerting&lt;/h1>
&lt;p>The Google Cloud Monitoring data source supports
&lt;a href="/docs/grafana/v12.4/alerting/">Grafana Alerting&lt;/a>, allowing you to create alert rules based on GCP metrics and Service Level Objectives (SLOs). You can monitor your Google Cloud environment and receive notifications when specific conditions are met.&lt;/p></description></item><item><title>Troubleshoot Google Cloud Monitoring data source issues</title><link>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/troubleshooting/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/datasources/google-cloud-monitoring/troubleshooting/</guid><content><![CDATA[&lt;h1 id=&#34;troubleshoot-google-cloud-monitoring-data-source-issues&#34;&gt;Troubleshoot Google Cloud Monitoring data source issues&lt;/h1&gt;
&lt;p&gt;This document provides solutions to common issues you may encounter when configuring or using the Google Cloud Monitoring data source. For configuration instructions, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/configure/&#34;&gt;Configure Google Cloud Monitoring&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;authentication-errors&#34;&gt;Authentication errors&lt;/h2&gt;
&lt;p&gt;These errors occur when GCP credentials are invalid, missing, or don&amp;rsquo;t have the required permissions.&lt;/p&gt;
&lt;h3 id=&#34;permission-denied-or-access-denied&#34;&gt;&amp;ldquo;Permission denied&amp;rdquo; or &amp;ldquo;Access denied&amp;rdquo;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Save &amp;amp; test fails with permission errors&lt;/li&gt;
&lt;li&gt;Queries return authorization errors&lt;/li&gt;
&lt;li&gt;Projects, metrics, or labels don&amp;rsquo;t load&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Possible causes and solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Cause&lt;/th&gt;
              &lt;th&gt;Solution&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Service account missing required permissions&lt;/td&gt;
              &lt;td&gt;Assign the &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role to the service account in the GCP Console under &lt;strong&gt;IAM &amp;amp; Admin&lt;/strong&gt; &amp;gt; &lt;strong&gt;IAM&lt;/strong&gt;. Refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/configure/&#34;&gt;Configure Google Cloud Monitoring&lt;/a&gt; for details.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Incorrect service account key file&lt;/td&gt;
              &lt;td&gt;Verify the JSON key file was downloaded correctly and contains valid credentials. Generate a new key if necessary.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Service account key has been deleted&lt;/td&gt;
              &lt;td&gt;Check the service account in GCP Console under &lt;strong&gt;IAM &amp;amp; Admin&lt;/strong&gt; &amp;gt; &lt;strong&gt;Service Accounts&lt;/strong&gt;. If the key was deleted, create a new one.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Wrong project selected&lt;/td&gt;
              &lt;td&gt;Verify the default project in the data source configuration matches a project the service account has access to.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;APIs not enabled&lt;/td&gt;
              &lt;td&gt;Enable the Monitoring API and Cloud Resource Manager API in the GCP Console. Refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/configure/&#34;&gt;Configure Google Cloud Monitoring&lt;/a&gt; for links.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;invalid-jwt-or-jwt-token-error&#34;&gt;&amp;ldquo;Invalid JWT&amp;rdquo; or &amp;ldquo;JWT token error&amp;rdquo;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Authentication fails when using Google JWT File&lt;/li&gt;
&lt;li&gt;Error message references invalid or malformed JWT&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify you uploaded the complete JSON key file, not just the private key portion.&lt;/li&gt;
&lt;li&gt;Check that the JSON file is properly formatted and not corrupted.&lt;/li&gt;
&lt;li&gt;Ensure the key file contains all required fields: &lt;code&gt;type&lt;/code&gt;, &lt;code&gt;project_id&lt;/code&gt;, &lt;code&gt;private_key_id&lt;/code&gt;, &lt;code&gt;private_key&lt;/code&gt;, &lt;code&gt;client_email&lt;/code&gt;, &lt;code&gt;client_id&lt;/code&gt;, &lt;code&gt;auth_uri&lt;/code&gt;, &lt;code&gt;token_uri&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Generate a new service account key and re-upload it.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;gce-default-service-account-not-working&#34;&gt;GCE Default Service Account not working&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Data source test fails when using GCE Default Service Account&lt;/li&gt;
&lt;li&gt;Works with JWT but fails with GCE authentication&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify Grafana is running on a Google Compute Engine (GCE) virtual machine.&lt;/li&gt;
&lt;li&gt;Check that the GCE instance has the &lt;strong&gt;Cloud Monitoring API&lt;/strong&gt; scope enabled.&lt;/li&gt;
&lt;li&gt;Verify the GCE default service account has the &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role.&lt;/li&gt;
&lt;li&gt;If the VM was created without the required scope, you may need to stop the instance, edit it to add the scope, and restart.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;service-account-impersonation-errors&#34;&gt;Service account impersonation errors&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Authentication fails when service account impersonation is enabled&lt;/li&gt;
&lt;li&gt;Error: &amp;ldquo;Unable to impersonate service account&amp;rdquo;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify the primary service account has the &lt;code&gt;roles/iam.serviceAccountTokenCreator&lt;/code&gt; role on the target service account.&lt;/li&gt;
&lt;li&gt;Check that the target service account email is entered correctly.&lt;/li&gt;
&lt;li&gt;Ensure the target service account has the &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role.&lt;/li&gt;
&lt;li&gt;Verify both service accounts are in projects that have the required APIs enabled.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;connection-errors&#34;&gt;Connection errors&lt;/h2&gt;
&lt;p&gt;These errors occur when Grafana cannot reach Google Cloud Monitoring endpoints.&lt;/p&gt;
&lt;h3 id=&#34;request-timed-out-or-connection-failures&#34;&gt;&amp;ldquo;Request timed out&amp;rdquo; or connection failures&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Data source test times out&lt;/li&gt;
&lt;li&gt;Queries fail with timeout errors&lt;/li&gt;
&lt;li&gt;Intermittent connection issues&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify network connectivity from the Grafana server to Google Cloud endpoints (&lt;code&gt;monitoring.googleapis.com&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Check firewall rules allow outbound HTTPS (port 443) to Google Cloud services.&lt;/li&gt;
&lt;li&gt;For Grafana Cloud connecting to private resources, configure &lt;a href=&#34;/docs/grafana-cloud/connect-externally-hosted/private-data-source-connect/&#34;&gt;Private data source connect&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Check if a corporate proxy is blocking connections to Google Cloud.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;ssl-certificate-problem&#34;&gt;&amp;ldquo;SSL certificate problem&amp;rdquo;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SSL/TLS handshake errors&lt;/li&gt;
&lt;li&gt;Certificate verification failures&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Ensure the system time is correct on the Grafana server.&lt;/li&gt;
&lt;li&gt;Verify the Grafana server has up-to-date CA certificates installed.&lt;/li&gt;
&lt;li&gt;Check if a corporate proxy is intercepting HTTPS traffic.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;metrics-query-errors&#34;&gt;Metrics query errors&lt;/h2&gt;
&lt;p&gt;These errors occur when querying Google Cloud Monitoring metrics.&lt;/p&gt;
&lt;h3 id=&#34;no-data-or-empty-results&#34;&gt;&amp;ldquo;No data&amp;rdquo; or empty results&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Query executes without error but returns no data&lt;/li&gt;
&lt;li&gt;Charts show &amp;ldquo;No data&amp;rdquo; message&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Possible causes and solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Cause&lt;/th&gt;
              &lt;th&gt;Solution&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Time range doesn&amp;rsquo;t contain data&lt;/td&gt;
              &lt;td&gt;Expand the dashboard time range. GCP metrics have different retention periods based on the metric type.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Wrong project selected&lt;/td&gt;
              &lt;td&gt;Verify you&amp;rsquo;ve selected the correct project in the query editor.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Incorrect metric type&lt;/td&gt;
              &lt;td&gt;Verify the service, metric type, and metric are correct. Check available metrics in the GCP Console Metrics Explorer.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Missing labels/filters&lt;/td&gt;
              &lt;td&gt;Some metrics require specific label filters to return data. Try removing filters to see if data appears.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Resource not emitting metrics&lt;/td&gt;
              &lt;td&gt;Verify the resource exists and is actively emitting metrics. Some metrics only populate under certain conditions.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;metrics-dont-appear-in-drop-down&#34;&gt;Metrics don&amp;rsquo;t appear in drop-down&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Expected metrics don&amp;rsquo;t appear in the query editor&lt;/li&gt;
&lt;li&gt;Metric drop-down is empty for a service&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify the metric exists in the selected project and region.&lt;/li&gt;
&lt;li&gt;Check that the service account has the &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role.&lt;/li&gt;
&lt;li&gt;Some metrics are only available for specific resource types. Check the &lt;a href=&#34;https://cloud.google.com/monitoring/api/metrics_gcp&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Google Cloud metrics list&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Use the Query Inspector to verify the API request and response.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;label-values-not-loading&#34;&gt;Label values not loading&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Label value drop-down doesn&amp;rsquo;t populate&lt;/li&gt;
&lt;li&gt;Filters can&amp;rsquo;t be applied&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify the service account has the &lt;strong&gt;Monitoring Viewer&lt;/strong&gt; role.&lt;/li&gt;
&lt;li&gt;Ensure a project, service, and metric are selected before label values can load.&lt;/li&gt;
&lt;li&gt;Label values are populated from existing metric data. If no metrics match the current selection, no values appear.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;mql-query-errors&#34;&gt;MQL query errors&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Monitoring Query Language (MQL) queries fail with syntax errors&lt;/li&gt;
&lt;li&gt;MQL query returns unexpected results&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Validate your MQL syntax using the &lt;a href=&#34;https://cloud.google.com/monitoring/mql/reference&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;MQL reference documentation&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Check for typos in metric types, label names, or function names.&lt;/li&gt;
&lt;li&gt;Ensure time range syntax is valid in your query.&lt;/li&gt;
&lt;li&gt;Test the query in the GCP Console Metrics Explorer before using it in Grafana.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;too-many-data-points-or-api-throttling&#34;&gt;&amp;ldquo;Too many data points&amp;rdquo; or API throttling&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Queries fail with quota errors&lt;/li&gt;
&lt;li&gt;Performance degrades with multiple panels&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Increase the alignment period to reduce the number of data points.&lt;/li&gt;
&lt;li&gt;Reduce the time range of your queries.&lt;/li&gt;
&lt;li&gt;Use fewer metric queries per panel.&lt;/li&gt;
&lt;li&gt;Request a quota increase in the GCP Console under &lt;strong&gt;APIs &amp;amp; Services&lt;/strong&gt; &amp;gt; &lt;strong&gt;Quotas&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enable query caching in Grafana to reduce API calls.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;slo-query-errors&#34;&gt;SLO query errors&lt;/h2&gt;
&lt;p&gt;These errors are specific to Service Level Objective (SLO) queries.&lt;/p&gt;
&lt;h3 id=&#34;slo-services-dont-appear&#34;&gt;SLO services don&amp;rsquo;t appear&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SLO service selector is empty&lt;/li&gt;
&lt;li&gt;Can&amp;rsquo;t find expected SLO services&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify SLOs are defined in Google Cloud Monitoring for the selected project.&lt;/li&gt;
&lt;li&gt;Check that the service account has access to view SLOs.&lt;/li&gt;
&lt;li&gt;Ensure the project has services configured in the Service Monitoring section of the GCP Console.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;slo-query-returns-no-data&#34;&gt;SLO query returns no data&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SLO query executes but returns no data&lt;/li&gt;
&lt;li&gt;SLO values show as empty&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify the SLO exists and is active in the GCP Console.&lt;/li&gt;
&lt;li&gt;Check that the time range includes periods when the SLO had data.&lt;/li&gt;
&lt;li&gt;Ensure the selected SLO selector (SLI value, compliance, error budget, etc.) is appropriate for the SLO type.&lt;/li&gt;
&lt;li&gt;Some SLOs may not have data if the underlying service hasn&amp;rsquo;t received traffic.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;template-variable-errors&#34;&gt;Template variable errors&lt;/h2&gt;
&lt;p&gt;These errors occur when using template variables with the Google Cloud Monitoring data source.&lt;/p&gt;
&lt;h3 id=&#34;variables-return-no-values&#34;&gt;Variables return no values&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Variable drop-down is empty&lt;/li&gt;
&lt;li&gt;Dashboard fails to load with variable errors&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify the data source connection is working.&lt;/li&gt;
&lt;li&gt;Check that the service account has permissions to list the requested resources.&lt;/li&gt;
&lt;li&gt;For dependent variables, ensure parent variables have valid selections.&lt;/li&gt;
&lt;li&gt;Verify the project is selected correctly in the variable query.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;variables-are-slow-to-load&#34;&gt;Variables are slow to load&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Dashboard takes a long time to load&lt;/li&gt;
&lt;li&gt;Variable selectors are slow to populate&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Set variable refresh to &lt;strong&gt;On dashboard load&lt;/strong&gt; instead of &lt;strong&gt;On time range change&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Reduce the scope of variable queries (filter by specific project or service).&lt;/li&gt;
&lt;li&gt;Limit the number of dependent variables in a chain.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For more information on template variables, refer to the 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/google-cloud-monitoring/template-variables/&#34;&gt;template variables documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;pre-configured-dashboard-issues&#34;&gt;Pre-configured dashboard issues&lt;/h2&gt;
&lt;p&gt;These issues occur with the bundled pre-configured dashboards.&lt;/p&gt;
&lt;h3 id=&#34;imported-dashboards-show-no-data&#34;&gt;Imported dashboards show no data&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Symptoms:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Imported dashboards show empty panels&lt;/li&gt;
&lt;li&gt;Template variables don&amp;rsquo;t load&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Verify the data source name in the dashboard matches your Google Cloud Monitoring data source.&lt;/li&gt;
&lt;li&gt;Check that the service account has access to the projects shown in the project variable.&lt;/li&gt;
&lt;li&gt;Ensure the resources (Compute Engine instances, Cloud SQL, etc.) exist and are emitting metrics.&lt;/li&gt;
&lt;li&gt;Verify the required GCP services are enabled in your project.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;enable-debug-logging&#34;&gt;Enable debug logging&lt;/h2&gt;
&lt;p&gt;To capture detailed error information for troubleshooting:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Set the Grafana log level to &lt;code&gt;debug&lt;/code&gt; in the configuration 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;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[log]
level = debug&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Review logs in &lt;code&gt;/var/log/grafana/grafana.log&lt;/code&gt; (or your configured log location).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Look for Google Cloud Monitoring-specific entries that include request and response details.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Reset the log level to &lt;code&gt;info&lt;/code&gt; after troubleshooting to avoid excessive log volume.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;get-additional-help&#34;&gt;Get additional help&lt;/h2&gt;
&lt;p&gt;If you&amp;rsquo;ve tried the solutions above and still encounter issues:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Check the &lt;a href=&#34;https://community.grafana.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana community forums&lt;/a&gt; for similar issues.&lt;/li&gt;
&lt;li&gt;Review &lt;a href=&#34;https://github.com/grafana/grafana/issues&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Google Cloud Monitoring issues on GitHub&lt;/a&gt; for known bugs.&lt;/li&gt;
&lt;li&gt;Consult the &lt;a href=&#34;https://cloud.google.com/monitoring/docs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Google Cloud Monitoring documentation&lt;/a&gt; for service-specific guidance.&lt;/li&gt;
&lt;li&gt;Contact Grafana Support if you&amp;rsquo;re an Enterprise, Cloud Pro, or Cloud Contracted user.&lt;/li&gt;
&lt;li&gt;When reporting issues, include:
&lt;ul&gt;
&lt;li&gt;Grafana version&lt;/li&gt;
&lt;li&gt;GCP project (redact if sensitive)&lt;/li&gt;
&lt;li&gt;Error messages (redact sensitive information)&lt;/li&gt;
&lt;li&gt;Steps to reproduce&lt;/li&gt;
&lt;li&gt;Query configuration (redact credentials)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="troubleshoot-google-cloud-monitoring-data-source-issues">Troubleshoot Google Cloud Monitoring data source issues&lt;/h1>
&lt;p>This document provides solutions to common issues you may encounter when configuring or using the Google Cloud Monitoring data source. For configuration instructions, refer to
&lt;a href="/docs/grafana/v12.4/datasources/google-cloud-monitoring/configure/">Configure Google Cloud Monitoring&lt;/a>.&lt;/p></description></item></channel></rss>