# Integrate Google Cloud Monitoring Grafana Datasource

To set up the Google Cloud Monitoring datasource in Grafana, you need to configure the necessary credentials and permissions. This involves creating a service account in GCP with appropriate permissions to access metrics and data.

{% hint style="info" %}
For more information see Grafana's Google Cloud Monitoring Datasource [documentation](https://grafana.com/docs/grafana/latest/datasources/google-cloud-monitoring/#configure-a-gcp-service-account)
{% endhint %}

### Setting up the service account

Grafana's Google Cloud Monitoring datasource requires a service account with the `Monitoring Viewer` role.

Create a new service account in the GCP console.

1. Choose a unique service name, such as `groundcover-monitoring`
2. Choose `JSON` as the key type
3. Assign the `Monitoring Viewer` role

<figure><img src="/files/DFpfJcKFsR8ZKTC2f6TG" alt=""><figcaption><p>Source: <a href="https://grafana.com/docs/grafana/latest/datasources/google-cloud-monitoring/#configure-a-gcp-service-account">Grafana</a></p></figcaption></figure>

### Create a new service account key

After provisioning the service account above, you will need to create a key to allow the Grafana datasource to authenticate with it.

1. Access the newly provisioned service account through the `Service Accounts` page
2. Click on the `Keys` tab and choose `Add key` -> `Create new key`
3. Choose the `JSON` key type
4. Click `Create`

The key will be downloaded as a local `.json` file. You will need this file for the next step.

### Provisioning the datasource

{% hint style="info" %}
Self provisioning of data sources is only available as part of the enterprise plan. If you are on the team plan, contact the groundcover's team to provision the new datasource.
{% endhint %}

{% hint style="info" %}
The following steps require a user with admin privileges in the platform
{% endhint %}

In the Grafana `Data sources` page, add a new `Google Cloud Monitoring` datasource.

1. Name: Select a meaningful name to your choosing.
2. Authentication:
   1. Authentication type: Select `Google JWT File`
   2. JWT token: Either upload the file created previously or paste its contents directly using `Paste JWT token`

Click `Save & test` to verify the data source correctness.

### Use the datasource in groundcover

After provisioning you can now use new Google Cloud Monitoring datasource in groundcover's Grafana. Explore, built dashboards and create alerts based on any metric availalbe in the GCP monitoring stack.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.groundcover.com/integrations/data-sources/google-cloud-monitoring/integrate-google-cloud-monitoring-grafana-datasource.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
