Datadog GCP Integration

Quote

“When Netflix instrumented their services, they instrumented service patterns — so when you built a new service, the monitoring would already be there once you got it running.”

Adrian Cockcroft

Why the Datadog GCP Integration Is Needed

The Airflow VM agent and SQL VM agent cover the GCE VMs. But the data-pipeline-pipeline Cloud Run job has no persistent host — each execution runs in a fresh container and exits. The only way to get Cloud Run metrics is via the GCP Integration, which pulls them directly from Google Cloud Monitoring.


GCP Integration Setup Steps

  1. In Datadog, go to Integrations > Google Cloud Platform
  2. Choose Manual setup method
  3. Enter the service account email:
   data-pipeline-datadog@data-platform-prod.iam.gserviceaccount.com
  1. When prompted for “Generate Principal”, use the SA impersonation flow
  2. Enable GCE Automuting (auto-mutes monitors when VM is stopped)
  3. Enable Resource Collection (discovers GCP resources in Datadog)
  4. Save the integration

Service Account Permissions

The Datadog SA has monitoring.viewer, compute.viewer, and cloudasset.viewer roles — it can read metrics but cannot modify any GCP resources. See service-accounts-and-iam for the broader IAM model and least-privilege principles applied across the project.


Terraform Resources for GCP Integration

The service account is created conditionally in infra/iam.tf:

resource "google_service_account" "datadog" {
  count        = var.dd_api_key != "" ? 1 : 0
  account_id   = "data-pipeline-datadog"
  display_name = "Datadog Integration"
}

Verify Datadog GCP Integration

After setup, go to Infrastructure > Host Map in Datadog. You should see GCE VMs listed. Cloud Run metrics appear under Cloud > GCP > Cloud Run.


Using Cloud Run Metrics in Dashboards

Cloud Run job metrics use the gcp.run.job.* namespace. Key metric names:

MetricDescription
gcp.run.job.completed_execution_countNumber of job executions completed
gcp.run.container.cpu.utilizations.avgCPU utilization during execution
gcp.run.container.memory.usageMemory usage during execution — these same metrics are available natively in GCP Cloud Monitoring

Filter by job name: Use job_name:data-pipeline-pipeline (not service:data-pipeline-pipeline).

Query example (Pipeline Runs widget)

sum:gcp.run.job.completed_execution_count{job_name:data-pipeline-pipeline}.as_count()

Query Value vs Timeseries for Cloud Run Jobs

Cloud Run jobs are ephemeral (1-2 min runtime), so timeseries charts show tiny blips. Query Value with max aggregator is more informative for showing peak CPU and memory usage.


Datadog GCP Integration Troubleshooting

Cloud Run metrics not showing

  1. Verify GCP Integration is set up (Integrations > Google Cloud Platform)
  2. Check the Datadog SA has monitoring.viewer role
  3. GCP metrics can take 5-10 minutes to appear after integration setup
  4. Use job_name:data-pipeline-pipeline as the filter (not service:data-pipeline-pipeline)

Pipeline logs not in Datadog

Cloud Run job logs go to GCP Cloud Logging, not through dd-agent. They are not available in Datadog’s Log Explorer. View them via:

gcloud logging read "resource.type=cloud_run_job AND resource.labels.job_name=data-pipeline-pipeline" \
  --limit=50 --format="table(timestamp,textPayload)"