# Google Cloud Managed Service for Prometheus

[Google Cloud Managed Service for Prometheus](https://cloud.google.com/stackdriver/docs/managed-prometheus) is Google Cloud's fully managed, multi-cloud, cross-project solution for [Prometheus](https://prometheus.io/) metrics.

### Supported Types

| Metrics | Logs | Traces |
| ------- | ---- | ------ |
| ✓       |      |        |

### Prerequisites

#### Network Requirements

The following Google Cloud APIs must be enabled

* Cloud Monitoring

The following network access is required between the Bindplane Collector and the following Google API endpoint URLs.

**Metrics**\
Google Cloud Monitoring API v3: `monitoring.googleapis.com:443`

{% hint style="success" %}
**TIP**

👍 Typically, when sent telemetry from a GCP hosted system, these URLs are part of default network access.
{% endhint %}

#### Authentication

The Google Managed Prometheus destination supports two forms of authentication.

* Access Scopes
* Service Account

**Google Cloud Access Scopes**

When running within Google Cloud, you can configure your Compute Engine instances with the following access scopes, allowing the Google Managed Prometheus destination to configure authentication automatically.

* monitoring.write

You can read more about access scopes [here](https://cloud.google.com/compute/docs/access/service-accounts?&_ga=2.22740927.-507322852.1681826195#accesscopesiam).

**Service Account**

If running outside of Google Cloud, or within Google Compute Engine without access scopes, you can create a service account for authentication.

1. Create a Google service account following [this documentation](https://cloud.google.com/iam/docs/service-accounts-create.).
2. Assign your service account the following roles
   1. Monitoring Metric Writer
3. Create and download a Service Account Access Key following [this documentation](https://cloud.google.com/iam/docs/keys-create-delete.).

The downloaded access key will be used when configuring the Google Cloud destination.

### Configuration Table

<table><thead><tr><th width="145.56640625">Parameter</th><th width="108.1171875">Type</th><th width="91.7421875">Default</th><th>Description</th></tr></thead><tbody><tr><td>project</td><td><code>string</code></td><td></td><td>The Google Cloud Project ID to send logs, metrics, and traces to.</td></tr><tr><td>auth_type</td><td><code>enum</code></td><td>auto</td><td>The method used for authenticating to Google Cloud. 'auto' will attempt to use the collector's environment, useful when running on Google Cloud or when you have set GOOGLE_APPLICATION_CREDENTIALS in the collector's environment. 'json' takes the JSON contents of a Google Service Account's credentials file. 'file' is the file path to a Google Service Account credential file.</td></tr><tr><td>credentials</td><td><code>string</code></td><td></td><td>JSON value from a Google Service Account credential file.</td></tr><tr><td>credentials_file</td><td><code>string</code></td><td></td><td>Path to a Google Service Account credential file on the collector system. The collector's runtime user must have permission to read this file.</td></tr><tr><td>default_location</td><td><code>enum</code></td><td>us-central1</td><td>Google Managed Prometheus requires a "location" resource attribute. This parameter inserts the resource attribute if it does not already exist.</td></tr></tbody></table>

### Supported Retry and Queuing Settings

This destination supports the [retry settings](https://docs.bindplane.com/configuration/bindplane-otel-collector/retry-on-failure), the [sending queue settings](https://docs.bindplane.com/configuration/bindplane-otel-collector/sending-queue), and the [persistent queue settings.](https://docs.bindplane.com/configuration/bindplane-otel-collector/persistent-queue)

| Sending Queue | Persistent Queue | Retry on Failure |
| ------------- | ---------------- | ---------------- |
| ✓             | ✓                | ✓                |

### Example Configurations

#### Automatic Authentication

This example uses the `auto` Authentication Method. When running within Google Cloud with the correct access scopes, the destination will perform automatic authentication and send metrics, traces, and logs to the project `bindplane-gcp`.

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-edbe718898dce861e6d3c10686c7afbc87863b8b%2Fintegrations-destinations-google-cloud-managed-service-for-prometheus-image-1.png?alt=media" alt="Bindplane docs - Google Cloud Managed Service for Prometheus - image 1"><figcaption></figcaption></figure>

#### Service Account Credentials (JSON)

Bindplane can embed credentials into the collector configuration when the authentication method `json` is selected.

When using the `json` option, paste the service account JSON key into the text box. This method is convenient as it does not require copying the service account key on the collector system.

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-78bae3b08816108dd05a9bf44474e68cc962a802%2Fintegrations-destinations-google-cloud-managed-service-for-prometheus-image-2.png?alt=media" alt="Bindplane docs - Google Cloud Managed Service for Prometheus - image 2"><figcaption></figcaption></figure>

#### Service Account Credentials (File)

If you would prefer to copy the service account key to the collector system instead of having Bindplane handle it, you can select the `file` option. In this example, the service account access key file is located at `/opt/observiq-otel-collector/service_account.json.`

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-d73f4ed2f94f1891b52198386561166d52869626%2Fintegrations-destinations-google-cloud-managed-service-for-prometheus-image-3.png?alt=media" alt="Bindplane docs - Google Cloud Managed Service for Prometheus - image 3"><figcaption></figcaption></figure>

### Usage

Create a configuration with the Prometheus source and Google Managed Prometheus destination.

As an example, you can target the collector's metrics port, `8888`.

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-57e389f4e967bf260a57ba15a867bd5eebc24cf3%2Fintegrations-destinations-google-cloud-managed-service-for-prometheus-image-4.png?alt=media" alt="Bindplane docs - Google Cloud Managed Service for Prometheus - image 4"><figcaption></figcaption></figure>

Configure the destination to point to your Google Cloud project, and add your service account credentials.

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2FJzz6BP2DosK8OVD0vrTO%2Fxnapper-gmp-dest-2.png?alt=media&#x26;token=950cf404-221a-4380-8672-01108653f203" alt="Bindplane  docs - Google Cloud Managed Service for Prometheus - Configure Destination"><figcaption></figcaption></figure>

The finished configuration will have a Prometheus source, and Google Managed Prometheus destination. You can add processors to add, remove, and modify metrics. Next, add at least one collector and rollout the configuration.

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-813f147fddb12d11c6bf4201f627bb6e2ea77746%2Fintegrations-destinations-google-cloud-managed-service-for-prometheus-image-5.png?alt=media" alt="Bindplane docs - Google Cloud Managed Service for Prometheus - image 5"><figcaption></figcaption></figure>

```
{
"url": "",
"provider": "",
"href": "",
"typeOfEmbed": "iframe"
}
```

In Cloud Monitoring, search for "Prometheus Target" using the metrics explorer.

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-9a4eff7b4cf33365544d88730459daa3d3c54444%2Fintegrations-destinations-google-cloud-managed-service-for-prometheus-image-6.png?alt=media" alt="Bindplane docs - Google Cloud Managed Service for Prometheus - image 6"><figcaption></figcaption></figure>

Select a metric and note that the `job`, `service_instance_id`and `service_name` metric labels can be used to identify which collector the metric originates from.

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-01412fdea0057584fd085d5a2c1ffb16f70a4118%2Fintegrations-destinations-google-cloud-managed-service-for-prometheus-image-7.png?alt=media" alt="Bindplane docs - Google Cloud Managed Service for Prometheus - image 7"><figcaption></figcaption></figure>
