Integrating Datadog with Google Cloud - Permissions and the Log Path

The Google Cloud integration connects by allowing a Datadog principal to impersonate a service account, without handing over a key file. If you connect at the organization or folder level, projects created later are discovered automatically too, and only logs travel a separate path through Pub/Sub and Dataflow.

What comes in through the integration and what stays with the Agent

When you enable the Google Cloud integration, Datadog reads metrics for each service from the Cloud Monitoring API and ingests them under names that start with gcp.. Every metric gets a project_id tag, and host labels in the <key>:<value> format, as well as custom labels on Pub/Sub, GCE, Cloud SQL, and Cloud Storage, also become tags (as of October 2026; source: Google Cloud Platform). Resource configuration information and changes detected by Cloud Asset Inventory also come in, and only logs travel a separate path. Fine-grained, low-latency metrics and traces are handled by installing the Agent on GCE or GKE.

Allow a Datadog principal to impersonate, without handing over a key file

Permissions live in a service account on the Google Cloud side. In Datadog's procedure, you create a service account in your own project, give it viewer roles, and grant the Datadog principal issued on the Datadog screen the Service Account Token Creator role on that service account. Finally, when you register the service account's email address with Datadog, Datadog impersonates this account to read data (as of October 2026; source: Google Cloud Platform).

  • 1. Google Cloud - Create a service account from IAM & Admin
  • 2. Google Cloud - Grant viewer roles at the organization, folder, or project level
  • 3. Datadog - Copy the Datadog principal from the Google Cloud Platform tile
  • 4. Google Cloud - On the service account's permissions tab, grant that principal Service Account Token Creator
  • 5. Datadog - Paste the service account's email and click Verify and Save Account
Source: Google Cloud Platform (the Installation section)

According to Google Cloud's documentation, the permission required for impersonation is iam.serviceAccounts.getAccessToken, which is included in the Service Account Token Creator role (source: Service account impersonation). The advantage over creating and handing over a key file is that no secret that could be taken out is created on your side. Google Cloud lists leakage and privilege escalation as the main threats of keys, and recommends choosing a more secure alternative to keys where possible and rotating them regularly if you do use them (source: Best practices for managing service account keys). With impersonation, there is no key to rotate, and when you want to stop access, you only need to remove the role from the principal.

Grant the four viewer roles at the organization or folder level

The roles granted to the service account are four, all read-only. In environments with multiple projects, you can optionally add Service Usage Consumer. Datadog recommends granting them at the organization or folder level, so that projects in that scope, including ones created later, are discovered automatically and become monitoring targets. However, projects whose names start with sys- are not picked up by automatic discovery (as of October 2026; source: Google Cloud Platform).

Roles granted to the service account and their purposes
RoleWhat Datadog uses it for
Compute ViewerRetrieving and listing Compute Engine resources
Monitoring ViewerReading Google Cloud monitoring data
Cloud Asset ViewerReading cloud asset metadata
BrowserTraversing the project hierarchy
Service Usage Consumer (optional)Reassigning API quota and costs to the project being queried
Source: Google Cloud Platform (the Installation section)

Separately from the roles, enable the Cloud Monitoring API, Compute Engine API, Cloud Asset API, Cloud Resource Manager API, IAM API, and Cloud Billing API in every project you monitor (including the project where you created the service account). By default, API quota and the costs of monitoring API calls are concentrated in the project that holds the service account, but enabling Enable Per Project Quota reassigns them to the project being queried, which makes the monitoring cost per project visible and also makes you less likely to hit rate limits.

Narrow metrics in three stages: namespace, region, and label

Right after you set up the integration, metrics from the target projects start being collected automatically. Narrowing is done on the Metric Collection tab of the Google Cloud Platform tile in Datadog, and the official documentation explains that narrowing lets you keep Cloud Monitoring API costs down. The first stage is the namespace: deselect the services you do not need, and for the services you keep, you can write include and exclude filters. A metric is collected only when it matches at least one include filter and none of the exclude filters (as of October 2026; source: Google Cloud Platform).

The three stages of narrowing on the Metric Collection tab
StageExample syntaxEffect
Namespace and metric namesubscription.* topic.* / !*_cost !*_countDecides inclusion and exclusion by the name under gcp.<service>
Region and globalDeselect the regions to exclude. Write values not in the list under Additional LocationsJudged by exact match against the label values Google Cloud reports. Global metrics not tied to a region can also be stopped
Host and Cloud Run labelsdatadog:monitored,env:production,!env:staging,instance-type:c1.*Only matching hosts are ingested into Datadog. The wildcards ? and * and exclusion with ! can be used
Source: Google Cloud Platform (the Metric Collection section)

The third stage, label filtering, also affects how Datadog counts. In addition to hosts running the Agent, Datadog counts GCE instances picked up by the integration as hosts for billing, and does not double-count hosts that fall into both. Labels can only exclude instances that are not running the Agent, and even after exclusion they remain in the Infrastructure List for up to 2 hours (source: Google Cloud Integration Billing). The concept of billing units is summarized in the explanation of integrations. Another quirk: for Google Cloud's cumulative metrics, a metric with a .delta suffix representing the difference from the previous value is ingested alongside it under the same name.

The path logs take through Pub/Sub and Dataflow, and the costs on the Google side

Whereas for metrics Datadog goes out to read the API, logs arrive by being pushed out from within Google Cloud. A Cloud Logging sink selects the logs to send and routes them to a Pub/Sub topic, and a Dataflow job using the Pub/Sub to Datadog template reads them from a pull subscription and sends them to Datadog's Logs API. Dataflow sits in between because it can batch and compress logs before sending them, and the official documentation describes this as the most network-efficient way to send (as of October 2026; source: Google Cloud Log Forwarding Setup).

  • 1. Cloud Logging sink - Select the logs to send with include and exclude filters (for example: severity="ERROR" AND sample(insertId, 0.1))
  • 2. Pub/Sub - A topic and pull subscription for receiving, and a separate topic for rejected logs
  • 3. Dataflow job - The Pub/Sub to Datadog template. Reading the API key from Secret Manager is recommended
  • 4. Datadog - New logs appear in the Log Explorer
Source: Google Cloud Log Forwarding Setup (the Manual section)

All components run inside your own project. What the Quick Start creates is a Pub/Sub topic and subscription, a log sink, a Secret Manager entry, a service account, a Cloud Storage bucket, and a Dataflow job, and the Dataflow workers are VMs. As a result, usage charges arise on the Google side, and the official documentation also points you to estimating them with the Google Cloud pricing calculator. Datadog's billing documentation likewise notes that non-GCE services such as Dataflow can produce billable GCE hosts (source: Google Cloud Integration Billing). Note that the earlier push subscriptions are being phased out.

In Terraform, write datadog_integration_gcp_sts and IAM as a pair

When you turn the on-screen procedure into code, the service account on the Google side and the integration definition on the Datadog side end up referencing each other. In the Datadog Terraform provider, datadog_integration_gcp_sts has only one required argument, client_email, and after creation it returns the read-only delegate_account_email (the Datadog principal). Granting that principal roles/iam.serviceAccountTokenCreator is the job of the Google provider side (as of October 2026; source: datadog_integration_gcp_sts Resource).

The three resources written in Terraform and their main arguments
ResourceRoleMain arguments
google_service_accountCreates the service account Datadog usesaccount_id, project
google_service_account_iam_memberGrants Token Creator to the Datadog principalrole = roles/iam.serviceAccountTokenCreator, delegate_account_email in member
datadog_integration_gcp_stsThe integration definition on the Datadog sideclient_email (required), metric_namespace_configs, region_filter_configs, monitored_resource_configs, automute
Source: datadog_integration_gcp_sts Resource (Example Usage and Schema)

The three stages of namespace, region, and label correspond to metric_namespace_configs, region_filter_configs, and monitored_resource_configs, respectively. The older host_filters and cloud_run_revision_filters are deprecated, so if you are writing new code, use monitored_resource_configs. Preparing the provider is covered in Setting Up the Terraform Provider. Compared with the AWS integration and the Azure integration, Google Cloud is built to concentrate trust in a single service account, so even as projects grow, you only need to widen the scope where the roles are granted.

Add one test project on the day you connect

According to the official documentation, metrics appear in Datadog about 15 minutes after setup. The place to look differs for each signal, so on the day you connect, open the following places in order (as of October 2026; source: Google Cloud Platform).

Places to open on the day you connect
What to checkWhere to look and the condition
Impersonation and rolesSearch Metrics Summary for gcp and see whether metrics tagged with your project_id are listed
Resource changesFilter the Event Explorer by source:google_cloud_asset_inventory
LogsWhether new events arrive in the Log Explorer
Blockages in the log pathMetric monitors on gcp.pubsub.subscription.num_undelivered_messages and gcp.pubsub.subscription.oldest_unacked_message_age. Place them on both the input and rejection subscriptions
Source: Google Cloud Platform, Google Cloud Log Forwarding Setup

Once all four places check out, confirm in your own environment the effect of connecting at the organization or folder level. Create one test project in that scope, enable the prerequisite APIs, and without touching anything on the Datadog side, wait to see whether that project_id appears in Metrics Summary. If it appears, monitoring will be attached automatically to the next projects your team creates as well. If it does not, first check that project's APIs and whether its name starts with sys-. How to divide Google Cloud observability between products is organized by cost item in the comparison with Cloud Monitoring.

References

Share