---
title: Google Cloud Metric Discrepancy
description: Troubleshooting steps for the Google Cloud metric discrepancy
breadcrumbs: Docs > Integrations > Integration Guides > Google Cloud Metric Discrepancy
---

# Google Cloud Metric Discrepancy

## Overview{% #overview %}

Use this guide to troubleshoot metric discrepancies between Google Cloud and Datadog.

## Metric discrepancies{% #metric-discrepancies %}

Datadog ingests the most granular raw values from Google Cloud. All aggregation seen in Datadog happens on the Datadog side. Datadog's metrics intake imports the raw values from Google as gauges, and any further aggregation is performed within Datadog. The following steps reconcile the metric `gcp.redis.stats.cpu_utilization` between Google Cloud and Datadog.

1. Find the corresponding metric in Google Cloud.

For the Google Cloud integration, Datadog converts Google Cloud metrics into the format `gcp.Google_Cloud_SERVICE_NAME.METRIC_NAME`. For the [example metric](https://cloud.google.com/monitoring/api/metrics_gcp_p_z#gcp-redis:~:text=of%20%5Bprimary%2C%20replica%5D.-,stats/cpu_utilization,-GA%20%E2%80%83%28project%29), the Google Cloud service name is **redis**, and the metric name is **stats/cpu\_utilization**. The full metric name is `redis.googleapis.com/stats/cpu_utilization`.

1. Find the most granular dimensions.

These include all the **Resource labels**: `project_id`,`region`, `instance_id`, `node_id`, and **Metric labels**: `role`, `space`, `relationship`. Refer to the [Google Cloud documentation](https://cloud.google.com/monitoring/api/metrics_gcp) for other metrics.

   {% image
      source="https://datadog-docs.imgix.net/images/integrations/guide/gcp-metric-discrepancy/labels_definition.93642533e464cd0db7e38adf9e7522f2.png?auto=format"
      alt="labels definition in GCP documentation" /%}

Resource type is associated with each metric under a Google Cloud service. Below are the supported resource types for **redis** service. The example metric's resource type is `redis_instance`. `redis_instance` has **Resource labels**: `project_id`,`region`, `instance_id`, `node_id`.

   - [redis.googleapis.com/Cluster](https://cloud.google.com/monitoring/api/resources#tag_redis.googleapis.com/Cluster)
   - [redis_instance](https://cloud.google.com/monitoring/api/resources#tag_redis_instance)
   - [redis.googleapis.com/ClusterNode](https://cloud.google.com/monitoring/api/resources#tag_redis.googleapis.com/ClusterNode)

   {% image
      source="https://datadog-docs.imgix.net/images/integrations/guide/gcp-metric-discrepancy/redis_instance.09d3d8db38ba1d89ca211b3544e03007.png?auto=format"
      alt="redis_instance resource labels" /%}

1. Graph the metric in the Google Cloud Metrics Explorer.

Search for `redis.googleapis.com/stats/cpu_utilization`.

   - Time: 1 hour (ideally in UTC)
   - Namespace: Cloud Memorystore Redis Instance
   - Metric name: CPU Seconds
   - Filter: (most granular dimensions) project_id, region, instance_id, node_id, role, space, relationship.
   - Aggregation: Sum (should show the same values when using mean, min, max, sum, or none if using most granular dimensions)
   - Min interval: 1m

   {% image
      source="https://datadog-docs.imgix.net/images/integrations/guide/gcp-metric-discrepancy/gcp_metric_explorer.4214305328a139e41a228fc6a6a7942a.png?auto=format"
      alt="gcp metric explorer" /%}

1. Graph the metric in the Datadog Metrics Explorer.

   {% image
      source="https://datadog-docs.imgix.net/images/integrations/guide/gcp-metric-discrepancy/datadog_metric_explorer.65971ba7202e8e19e02e0994d6415000.png?auto=format"
      alt="datadog metric explorer" /%}

In most cases, after completing steps 1–4, you see the exact same values in both Google Cloud and Datadog. However, in our example, a discrepancy appears at 01:40:00 PM.

   - **Datadog**: 108.71ms
   - **Google Cloud**: 0.0018119s

   {% image
      source="https://datadog-docs.imgix.net/images/integrations/guide/gcp-metric-discrepancy/gcp_value.0810f85727627b95d459fbc8e94f1d7f.png?auto=format"
      alt="gcp value" /%}

   {% image
      source="https://datadog-docs.imgix.net/images/integrations/guide/gcp-metric-discrepancy/datadog_value.226528dca29b808b2799c9629db185fe.png?auto=format"
      alt="datadog value" /%}

1. Understand Google Cloud alignment functions.

This discrepancy occurs because by default, Google Cloud applies a rate alignment for this metric. For details, see the Google cloud [alignment function](https://cloud.google.com/monitoring/api/v3/aggregation#alignment-intro) documentation. Click on `configure aligner` to see that the alignment function is automatically set to **rate** (0.108711 / 60 ≃ 0.0018119).

   {% image
      source="https://datadog-docs.imgix.net/images/integrations/guide/gcp-metric-discrepancy/gcp_aligner.51e5d67d3c109d75ae73dc5cf7bf32cb.png?auto=format"
      alt="gcp aligner" /%}

   {% image
      source="https://datadog-docs.imgix.net/images/integrations/guide/gcp-metric-discrepancy/gcp_rate.82b8703ed563afd51697ed2961651013.png?auto=format"
      alt="gcp rate" /%}

1. Adjust the alignment function in Google Cloud.

Change the alignment function to `delta`, `min`, `max`, `sum`, or `mean`. Assuming you are using the most granular dimensions, the value in Google Cloud should match the value in Datadog.

   {% image
      source="https://datadog-docs.imgix.net/images/integrations/guide/gcp-metric-discrepancy/gcp_delta.029e7a7ec9b7c3f4c2e99169b9edc41d.png?auto=format"
      alt="gcp delta" /%}

## Further reading{% #further-reading %}

- [Google Cloud Integration](https://docs.datadoghq.com/integrations/google-cloud-platform/)
