The Simplest Way to Make Cloud Run and Datadog Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

You pair cloud run and datadog by running a collector agent beside your app container. This setup sends live traces, metrics, and logs from serverless workloads to one central dashboard. Teams use this workflow to watch short-lived containers as traffic spikes and drops. Without direct collection, serverless instances spin down before your monitoring tool reads their final state. A good setup captures every event, protects secret keys, and keeps personal data safe. How cloud run and datadog s

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You pair cloud run and datadog by running a collector agent beside your app container. This setup sends live traces, metrics, and logs from serverless workloads to one central dashboard.

Teams use this workflow to watch short-lived containers as traffic spikes and drops. Without direct collection, serverless instances spin down before your monitoring tool reads their final state. A good setup captures every event, protects secret keys, and keeps personal data safe.

How cloud run and datadog share data and permissions

Cloud Run runs stateless containers that start and stop in seconds based on web requests. Datadog needs a steady stream of metrics, traces, and logs from those fast-moving containers. You bridge the two tools with a sidecar agent or a cloud log sink.

In the sidecar pattern, a small agent container runs next to your main app container. Both containers share a local network space inside the same serverless instance. Your app sends traces and custom metrics to the local agent over that private path. The agent then batches the data and sends it out to the monitoring intake.

To log in to the intake service, the agent needs a valid API key. You should store this key in a managed secret store instead of plain text variables. The serverless service account needs a role that can only read that single secret. For platform metrics, you also link your cloud project to the monitoring account. You grant a read-only viewer role to the monitoring service account on the cloud side. This role lets the platform pull billing, scaling, and cold start data on a schedule.

Common failure modes and how to scope roles

Many teams make mistakes when they rush the initial setup between these two platforms. The biggest risk comes from shared service accounts with broad project permissions. If an app uses the default compute account, a leaked token exposes the whole project. A second failure happens when teams paste the same master API key across every service. If one test container leaks that key, attackers can flood your account with fake logs. That flood hides real alerts and drives up your monthly ingestion bill.

You can fix this by giving each serverless service its own dedicated identity. Grant that identity the smallest role needed to read its own secret key. Create separate monitoring API keys for each team or stage, and rotate them often.

End-to-End Encryption + Datadog Security Monitoring: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged database queries and leaked personal data inside app logs create another major blind spot. When an app crashes, it often prints the full user payload into standard output. The log collector grabs that text and ships it straight to the central search index. Anyone with dashboard read rights can then find raw emails, phone numbers, or card numbers. You should set up scrubbing rules in the collector agent before data leaves the container. Good scrubbing rules match patterns for national IDs and card numbers and rewrite those fields.

Securing outbound network paths and log pipelines

Network paths between serverless apps and external monitoring endpoints also need strict rules. By default, serverless containers can open outbound connections to any public address on the internet. If a bad actor compromises a container, they can send stolen data to outside servers.

To lock this down, route all outbound container traffic through a private virtual network. Set up firewall rules that only allow traffic to known monitoring intake addresses. When you use a cloud log sink instead of an agent, filter the sink first. Exclude noisy health check routes and debug lines before the sink exports the stream. This step keeps sensitive system details out of external storage and lowers your transfer costs.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Should I use a sidecar agent or a log forwarding sink?

Use a sidecar agent when you need live app traces and custom code metrics. Use a cloud log sink when you only need basic standard output logs and metrics.

How do I stop secret keys from leaking in container settings?

Never put plain API keys in your container build files or plain text settings. Mount the key from a cloud secret manager using a tightly scoped service role.

How can I keep sensitive customer fields out of my log index?

Configure redaction rules in your agent or log pipeline before data leaves your cloud network. Set the rules to rewrite emails, phone numbers, and card numbers in all log lines.

The query runs. The emails stay hidden.