docs/sources/datasources/google-cloud-monitoring/google-authentication/index.md
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.
All requests to Google APIs are performed on the server-side by the Grafana backend.
Before you configure authentication, ensure you have the following:
The Google Cloud Monitoring data source supports the following authentication methods:
| Method | Use case |
|---|---|
| Google JWT File | Use when Grafana runs outside of GCP, or when you need explicit control over credentials. |
| GCE Default Service Account | Use when Grafana runs on a Google Compute Engine VM with a configured service account. |
| Service Account Impersonation | Use when you need Grafana to act as a different service account than the one it authenticates with. |
Use this method when Grafana runs outside of Google Cloud Platform, or when you need explicit control over which credentials are used.
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.
To create a service account and download its key file:
Navigate to the APIs and Services Credentials page in the GCP Console.
Click the Create credentials dropdown and select Service account.
In Service account name, enter a name for the account.
Click Create and continue.
In the Grant this service account access to project section, select the Monitoring Viewer role from the Role dropdown.
Click Continue, then click Done.
In the service accounts list, click the service account you created.
Go to the Keys tab and click Add key > Create new key.
Select JSON and click Create.
A JSON key file downloads to your computer.
Store the key file securely. It grants access to your Google Cloud data.
You can configure a single service account to access multiple GCP projects:
[email protected]).When Grafana runs on a Google Compute Engine (GCE) virtual machine, it can automatically retrieve credentials from the GCE metadata server. This method doesn't require you to create or manage key files.
Before using this method, ensure the following:
For more information about GCE service accounts, refer to the Google documentation on service accounts for instances.
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:
The service account used by Grafana (the "caller") must have the following:
iam.serviceAccounts.getAccessToken permission on the target service account.roles/iam.serviceAccountTokenCreator).The service account being impersonated (the "target") must have:
For more information, refer to the Google documentation on service account impersonation.