# GCP Metrics

Contents

* [Configure GCP](#configuring-gcp)
  * [Create a Service Account Key](#create-a-service-account-key)
  * [Roles](#roles)
  * [Enable Monitoring](#enable-monitoring)
* [Configuring Hosted Graphite](#configuring-hosted-graphite)
  * [Enabling GCP Add-On](#enabling-the-gcp-add-on)
  * [Additional Configs](#additional-configs)
    * [Tags](#tags)
    * [Account Naming](#enabling-account-naming)
* [Metric Name Mapping](#metric-name-mapping)
* [GCP Overview Dashboard](#gcp-overview-dashboard)
* [Disabling the GCP Add-0n](#disabling-the-gcp-add-on)
* [Disclaimer](#disclaimer)

{% embed url="<https://www.youtube.com/watch?t=1s&v=Vk959lTmEN8>" %}
GCPP Video Tutorial
{% endembed %}

### [Configuring GCP](#configuring-gcp)

To connect to your GCP project, you need to provide the following information:

* Service Account Key

#### [Create a Service Account Key](#create-a-service-account-key)

In the main Google Console page select the 'IAM & Admin' panel.  On the side panel navigate to the 'Service Account' link:

<figure><img src="https://495119770-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZtHmoGZNsmARIViZEdbz%2Fuploads%2FhsrOeLI5gXM1zG8UeRrT%2Fgcp-side-panel-servicekey.png?alt=media&#x26;token=8543723f-9e32-40bc-90ef-d7d590e69d89" alt=""><figcaption><p>GCP IAM Policy</p></figcaption></figure>

and create a Service account.

#### [Roles](#roles)

In the creation of the service account there are two roles that need to be added order for Hosted Graphite to pull these metrics into your account: 'monitoring.viewer' and 'computer.viewer' (if monitoring compute services).

<figure><img src="https://495119770-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZtHmoGZNsmARIViZEdbz%2Fuploads%2FxjdE3JB9aNbm3OHPSh1N%2Fgcp-monitoring-viewer.png?alt=media&#x26;token=f761b13c-b052-4976-9601-fc131c350ea5" alt=""><figcaption><p>monitoring.viewer</p></figcaption></figure>

<figure><img src="https://495119770-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZtHmoGZNsmARIViZEdbz%2Fuploads%2FTHNnpqdvEOuBtCMyNHEE%2Fgcp-compute-viewer.png?alt=media&#x26;token=7f9c2a9b-a4d3-4096-9361-692b29e81254" alt=""><figcaption><p>compute.viewer</p></figcaption></figure>

Once the account has been created, in the Service Accounts page click on the account and create a key.

<figure><img src="https://495119770-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZtHmoGZNsmARIViZEdbz%2Fuploads%2FXFmdlZlxNmTRxWepBdMX%2Fgcp-serviceaccount.png?alt=media&#x26;token=818dc312-c528-4e9e-a3ea-23be9ba1496e" alt=""><figcaption><p>creating a service key</p></figcaption></figure>

Ensure that the key type is JSON:

<figure><img src="https://495119770-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZtHmoGZNsmARIViZEdbz%2Fuploads%2FBIvrGJELEn7PWOb1aryP%2Fgcp-auth-json.png?alt=media&#x26;token=79ce569c-d9ff-42d2-91d0-d205b8fa8fa2" alt=""><figcaption><p>key type-json</p></figcaption></figure>

This will download a json file to you computer, which can then be uploaded to Hosted Graphite giving us permission to pull metrics from your GCP services.

#### [Enable Monitoring](#enable-monitoring)

The last thing you will need to do in your GCP account is to enable the Stackdriver API, which enables monitoring for your active GCP services:

<figure><img src="https://495119770-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZtHmoGZNsmARIViZEdbz%2Fuploads%2FrI3xUNvIyzLuTh7c1LPp%2Fstackdriver.png?alt=media&#x26;token=df75bd46-6ca3-48bb-8379-f8355e48c7ea" alt=""><figcaption><p>enable the stackdriver API</p></figcaption></figure>

### [Configuring Hosted Graphite](#configuring-hosted-graphite)

#### [Enabling The GCP Add-On](#enabling-the-azure-add-on)

To enable the GCP add-on, go to the [add-ons](https://www.hostedgraphite.com/app/addons/) page in your Hosted Graphite account and choose the option for **GCP**.

You will be presented with the following page; here you will be able to add, edit, and delete any GCP configurations. This page also provides options to add account names and tags.

<figure><img src="https://495119770-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZtHmoGZNsmARIViZEdbz%2Fuploads%2FNYpaZSDNiYRjgBXO7xGw%2Fgcp-accounts.png?alt=media&#x26;token=c7aeb35e-817d-4965-bae3-88c5e2bea1bf" alt=""><figcaption><p>GCP Add-on</p></figcaption></figure>

The main GCP configuration page looks like the following:

<figure><img src="https://495119770-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZtHmoGZNsmARIViZEdbz%2Fuploads%2FRW6tG4H69CJQK8vBk3v1%2Fgcp-account.png?alt=media&#x26;token=61c87c9d-9cf4-4870-a7fb-cc5293c3b1f7" alt=""><figcaption><p>GCP Config</p></figcaption></figure>

Before saving make sure to include the resource to monitor by selecting the enable checkbox along with uploading the service account key. Tagging is also a feature that can be enabled. (Google refers to them as labels but they serve identical purposes). If 'Labels' checkbox is enabled then tagging will only be applied to that specific resource. If you don't want tagging to be enabled for a resource then leave it unselected.

More information on the available metrics can be viewed [here](https://cloud.google.com/monitoring/api/metrics_gcp). If you require a specific GCP service that is not listed, please don't hesitate to email us and we'll work swiftly to add it.

### [Additional Configs](#additional-configs)

#### [Tags](#tags)

If you click **GCP Labels** you will be presented with the following screen which allows you to edit labels. Each label has a unique name (shown on the left) and one or more values. Values are separated by a comma.&#x20;

**Example**: Entering “Tag\_Next”: “hello, world” will configure the Add-On to only pull metrics from resources that have the label “Tag\_Next” and at least one of the matching values of "hello" or "world" for that label.

If labels are not selected for any services, but labels are configured for the Add-On, it will act as if labeling is enabled for all services.

<figure><img src="https://495119770-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZtHmoGZNsmARIViZEdbz%2Fuploads%2FHyKRxOTaBJI2wMWf84EE%2Fgcp-labels.png?alt=media&#x26;token=28f1d568-8e5f-4978-8a6a-19b238e3b64d" alt=""><figcaption><p>GCP Labels</p></figcaption></figure>

#### [Enabling Account Naming](#enabling-account-naming)

If you use multiple GCP auth keys on your Hosted Graphite account for different GCP projects, you can keep the metrics separated by assigning **Account Names** to your Client IDs.

Under the list of Client IDs on your HG account, there’s a button to access the Account Names interface. There you can assign names to your Client IDs, which will then become part of the metric name for all metrics retrieved using that ID.&#x20;

<figure><img src="https://495119770-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZtHmoGZNsmARIViZEdbz%2Fuploads%2FilLybhUsoxj9oim6lc0F%2Fgcp-account-name.png?alt=media&#x26;token=afe6e266-854e-4119-83b2-d4c13c848795" alt=""><figcaption><p>GCP Account Name</p></figcaption></figure>

### [Metric Name Mapping](#metric-name-mapping)

The Google metrics for each service are mapped to Hosted Graphite metric names as follows:

```bash
gcp.{client_id}.{service}.{project_id}.{location/zone}.({label1}.{label2}...).{metric_name}
```

If AccountName is enabled then the client\_id will be replaced by the account name provided. The labels are determined by the resource type and the metric, causing some metrics to have more than one label per metric. For more information regarding resource type label please refer to the GCP [documentation](https://cloud.google.com/monitoring/api/resources).

### [GCP Overview Dashboard](#gcp-overview-dashboard)

This can be found and generated from within the [Dashboard Library](https://docs.hostedgraphite.com/dashboard-and-graphs/dashboard-library), and offers a great starting point for monitoring your Google Cloud services!

<figure><img src="https://495119770-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZtHmoGZNsmARIViZEdbz%2Fuploads%2FCTGmBkqyxEhQG8KJg00w%2Fgcp-overview-dashboard.png?alt=media&#x26;token=80c638c9-832a-4603-90c1-e0536919f27a" alt=""><figcaption><p>GCP Overview Dashboard</p></figcaption></figure>

### [Disabling The GCP Add-On](#disabling-the-gcp-add-on)

Go to the [add-ons](https://www.hostedgraphite.com/app/addons/) page in your Hosted Graphite account, and choose the option for **GCP**.

Click the **Delete** button and the GCP add-on will be disabled for that account.

### [Disclaimer](#disclaimer)

While we attempt to minimize the number of API calls that may incur Google Cloud Platform charges, Hosted Graphite disclaims responsibility for potential costs incurred by the use of this add-on. For more information please review GCP's API [cost](https://console.cloud.google.com/marketplace/product/google/monitoring.googleapis.com) and [rate-limiting](https://cloud.google.com/monitoring/quotas#more-quota) information.

Our add-on performs read-only requests to the Google Cloud API. Should the provided [GCP Service Account Key](#create-a-service-account-key) grant greater privileges than what is specified in [Roles](#roles), responsibility for any activity performed using those keys lies with the customer.
