# GCP Metrics Collection

Kloudfuse integrates with the GCP cloud service to collect metrics.

Complete these tasks to successfully collect metrics:

- [Create Credentials File](https://docs.kloudfuse.com/platform/3.3.6/cloud-service-gcp-metrics/#credentials)
- [Create Kubernetes Secret](https://docs.kloudfuse.com/platform/3.3.6/cloud-service-gcp-metrics/#secret)
- [Configure Kloudfuse to Collect Metrics](https://docs.kloudfuse.com/platform/3.3.6/cloud-service-gcp-metrics/#collect)

## Create Credentials File

1. In the **Google Cloud** console, navigate to **Menu > IAM & Admin > Service Accounts**.

2. Select your service account, or create a new one.

Ensure that the service account has **_Monitoring Viewer_** permissions to collect GCP metrics.

3. Select **Keys > Add key > Create new key**.

4. Select JSON, then click **Create**.

5. Click **Close**.

## Create Kubernetes Secret

Create a Kubernetes secret from the credentials file. Name the file `credentials.json`.

```console
kubectl create secret generic kfuse-sd-secret --from-file=<credentials json file> -n kfuse
```

## Configure Kloudfuse to Collect Metrics

1. Update the helm values using the following configuration.

```yaml
kfuse-cloud-exporter:
     Prometheus-stackdriver-exporter:
       enabled: true
       stackdriver:
         httpTimeout: 30s
         maxRetries: 3
         projectId: "YOUR PROJECT ID" (1)
         ## projectId: "<project1-id>, <project2-id>, <project3-id>" (2)
         serviceAccountSecret: kfuse-sd-secret (3)
         metrics:
           typePrefixes: "compute.googleapis.com"
```

|     |     |
| --- | --- |
| **1** | `projectId` singular: GCP project id |
| **2** | `projectId` multiple: GCP project ids when working with multiple projects |
| **3** | `serviceAccountSecret`: Create a secret with access credentials to the GCP account |

2. Update the corresponding `projectId` of the GCP account and update the `typePrefixes` to collect the metrics from relevant services of GCP; see Google Cloud documentation on [Google Cloud metrics](https://cloud.google.com/monitoring/api/metrics_gcp).
