Datadog Troubleshooting
Quote
“You can’t fix what you can’t see. Observability is about closing the feedback loop between deploying code and understanding its impact.”
— Charity Majors, charity.wtf (2018)
Summary
This note is the operational repair manual for the Datadog stack: it covers what to check when agents do not appear, traces stop flowing, logs stay empty, Cloud Run metrics never show up, or host-specific quirks like COS filesystem rules and CRLF startup scripts break the intended monitoring path.
Agent and ingestion failures
- Starts with the basic host and agent checks for missing infrastructure presence, then moves through traces, logs, and Cloud Run metric gaps.
- Uses the real collection path of each signal so troubleshooting follows the system’s architecture instead of generic guesswork.
Host-specific edge cases
- Covers platform-specific failure modes such as COS read-only paths, Windows line endings in startup scripts, and duplicate or ghost hosts in Datadog.
- Keeps environment quirks visible because many observability issues are deployment-shape issues, not product bugs.
Command references
- Includes the management commands and config file locations needed to inspect or restart agents on both the Airflow and SQL VMs.
- Turns the note into a practical first-stop runbook rather than only a list of symptoms.
Disable and recover
- Ends with the disable path for agents and integrations when the safest move is to reset or remove part of the stack.
- When to use: one of the Datadog signal paths is broken and the operator needs a structured diagnostic sequence.
Glossary
agent not reporting
A condition where the Datadog collector is installed or expected but the host does not appear healthy in Datadog.
It matters here because most other Datadog features depend on the base agent path being alive first.
Start at the collector
If the host is absent, dashboards and monitors are downstream symptoms rather than the root problem.
APM intake
The Datadog path that receives trace payloads from an instrumented application.
It matters here because trace failures often come from transport or agent-reachability issues rather than missing instrumentation code.
Tracing needs transport
A correct tracer with no intake path behaves like tracing that was never enabled.
metadata startup script
The VM bootstrap script delivered through instance metadata and executed on startup.
It matters here because several agent installation and update issues trace back to whether this script reran correctly.
Bootstrap source of truth
When infrastructure changes do not appear on the host, inspect the metadata-driven startup path first.
COS filesystem constraint
The limited writable-path model on Container-Optimized OS.
It matters here because writing Datadog state or config to the wrong path can break the Airflow VM agent.
Host OS rules matter
Collector failures on COS are often path-assumption failures imported from more general Linux guides.
CRLF line endings
Windows-style line endings that can break shell script execution on Linux hosts.
It matters here because startup scripts with CRLF can prevent agent updates or restarts from applying.
Formatting can stop bootstrap
A script that looks right in the editor can still fail before any Datadog logic runs.
ghost host
A stale or duplicate infrastructure entry that remains in Datadog after the real host changed or disappeared.
It matters here because duplicate host identities confuse dashboards, host maps, and monitor targeting.
Identity cleanup problem
Not every infrastructure anomaly is live telemetry; some are stale inventory artifacts.
bytes-read zero
The state where a log source is configured but the agent reports no bytes consumed from it.
It matters here because empty SQL log streams usually show up here before they are noticed in Log Explorer.
Local log failure clue
This points troubleshooting toward file path, permissions, or source config rather than toward search syntax.
disable path
The controlled way to turn off Datadog agents or integrations when troubleshooting or cost control requires rollback.
It matters here because a clean shutdown path is safer than leaving half-broken collection components running.
Reset safely
Being able to disable observability cleanly is part of operating it responsibly.
Agent Not Appearing in Datadog
# SSH into VM
gcloud compute ssh data-pipeline-airflow --zone=europe-west1-b --tunnel-through-iap
# Check agent is running
docker ps | grep dd-agent
# Check agent status
docker exec dd-agent agent status
# Check agent logs for errors
docker logs dd-agent --tail 50Datadog Agent Not Appearing — common issues and fixes
- No container: API key is empty in VM metadata. Check
terraform outputand re-apply. - “Invalid API key”: Wrong key in
terraform.tfvars. API keys are 32 chars, not 40. The Application key is 40 chars — do not confuse them. - Agent unhealthy: Normal for the first ~2 minutes while checks initialize.
APM Traces Not Appearing
Step 1 — Check dd-agent is running on the Airflow VM
gcloud compute ssh data-pipeline-airflow --zone=europe-west1-b \
--tunnel-through-iap --command="sudo docker ps -a --filter name=dd-agent"Step 2 — If dd-agent is not running, the most likely cause is missing dd-api-key in VM metadata. This happened during the Cloud SQL to SQL VM migration — the key was added to the SQL VM but accidentally omitted from the Airflow VM.
Step 3 — Fix: add dd-api-key to Airflow VM metadata in infra/compute.tf:
metadata = {
startup-script = replace(file("${path.module}/scripts/airflow-startup.sh"), "\r\n", "\n")
dd-api-key = var.dd_api_key # ← THIS LINE
enable-oslogin = "TRUE"
}Step 4 — Apply and reset the VM
terraform -chdir=infra apply -target="google_compute_instance.airflow"
gcloud compute instances reset data-pipeline-airflow --zone=europe-west1-bApply does not restart the VM
terraform applyonly updates the VM’s metadata stored in GCP — it does NOT restart the VM or re-run the startup script. The startup script only executes on boot. You must manually reset the VM after applying metadata changes.
Fix: Reset the VM After Metadata Changes
After
terraform applycompletes, rungcloud compute instances reset data-pipeline-airflow --zone=europe-west1-bto trigger a reboot and re-execute the startup script. Wait 2–3 minutes, then verify all containers are running withsudo docker ps.
Step 5 — Wait 2–3 minutes, then verify
gcloud compute ssh data-pipeline-airflow --zone=europe-west1-b \
--tunnel-through-iap --command="sudo docker ps"All 5 containers (4 Airflow + dd-agent) should show status Up.
If dd-agent is running but traces still don’t appear
- Check APM status:
docker exec dd-agent agent status | grep -A 10 "APM Agent"- Expected:
Status: Running,Receiver: 0.0.0.0:8126
- Expected:
- Check firewall: verify
data-pipeline-allow-apmexists allowing TCP 8126 from10.0.0.0/24 - Check port mapping: dd-agent must have
-p 8126:8126(not just Docker network exposure) - Check
DD_APM_NON_LOCAL_TRAFFIC: must betrue - Check Cloud Run VPC: must have
egress = "PRIVATE_RANGES_ONLY" - Test connectivity from the VM:
curl -s http://localhost:8126/info | head -5
terraform apply Updated Metadata But Agent Did Not Restart
terraform apply only updates the VM’s metadata stored in GCP — it does NOT restart the VM or re-run the startup script. The startup script only executes on boot.
If you changed metadata (e.g., added dd-api-key, updated startup script), manually reset the VM:
gcloud compute instances reset data-pipeline-airflow --zone=europe-west1-bWait 2–3 minutes for the startup script to complete. Then verify:
gcloud compute ssh data-pipeline-airflow --zone=europe-west1-b \
--tunnel-through-iap --command="sudo docker ps"No Logs Appearing in Datadog Log Explorer
# Check agent log collection status
docker exec dd-agent agent status | grep -A 20 "Logs Agent"Expected: Logs: xx logs sent. If 0:
- Docker socket may not be mounted: check
-v /var/run/docker.sock:/var/run/docker.sock:ro DD_LOGS_ENABLEDnot set totrue
In Datadog, use Logs > Live Tail (not Log Explorer) to see logs in real time. New accounts may show an onboarding wizard — Live Tail bypasses it.
For SQL Server log collection issues, see datadog-sql-server-logs.
COS Read-Only Filesystem Constraints for dd-agent
Container-Optimized OS has a read-only root filesystem. Paths like /opt are not writable:
# This fails on COS:
-v /opt/datadog-agent/run:/opt/datadog-agent/run:rw
# Use /var/lib instead:
mkdir -p /var/lib/datadog-agent/run
-v /var/lib/datadog-agent/run:/opt/datadog-agent/run:rwThis is already handled correctly in the startup script’s docker run command.
Windows Line Endings (CRLF) Breaking Startup Script
If the VM shows env: 'bash\r': No such file or directory, the startup script has Windows CRLF line endings. The fix is in infra/compute.tf:
metadata = {
startup-script = replace(file("${path.module}/scripts/airflow-startup.sh"), "\r\n", "\n")
}This replace() call strips Windows CR characters before uploading the script as metadata.
Ghost Hosts Appearing in Datadog Infrastructure
When the API key is changed, the old agent may leave a ghost host entry. Ghost hosts show as INACTIVE and auto-disappear after ~2 hours. To list hosts via API:
curl -s -X GET "https://api.datadoghq.eu/api/v1/hosts?filter=data-pipeline" \
-H "DD-API-KEY: <api-key>" \
-H "DD-APPLICATION-KEY: <app-key>"The Docker-internal PostgreSQL IP (e.g., 172.18.0.3) also appears as a separate host — this is normal, caused by the Autodiscovery Postgres check resolving “ to the container’s bridge IP. It auto-resolves.
Cloud Run Metrics Not Showing in Datadog
Cloud Run jobs are ephemeral — no Datadog Agent runs inside them. Metrics come from the GCP Integration (see datadog-gcp-integration). If no Cloud Run metrics appear:
- Verify GCP Integration is set up in Datadog (Integrations > Google Cloud Platform)
- Check the Datadog SA has
monitoring.viewerrole - GCP metrics can take 5–10 minutes to appear after integration setup
- Use
job_name:data-pipeline-pipelineas the filter (notservice:data-pipeline-pipeline)
Pipeline Logs Not Appearing 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)"Agent Management Commands
Airflow VM (Docker-based agent on COS)
SSH into the VM first:
gcloud compute ssh data-pipeline-airflow --zone=europe-west1-b --tunnel-through-iap| Task | Command |
|---|---|
| View agent logs | docker logs dd-agent --tail 50 |
| Full agent status | docker exec dd-agent agent status |
| Quick health check | docker exec dd-agent agent health |
| Restart agent | docker restart dd-agent |
| Test APM port | `curl -s http://localhost:8126/info |
SQL VM (package-based agent on Ubuntu)
SSH into the VM first:
gcloud compute ssh data-pipeline-sql --zone=europe-west1-b --tunnel-through-iap| Task | Command |
|---|---|
| Full agent status | sudo datadog-agent status |
| Check SQL Server integration | sudo datadog-agent check sqlserver |
| View agent logs | sudo journalctl -u datadog-agent --no-pager -n 50 |
| Restart agent | sudo systemctl restart datadog-agent |
| Stop agent | sudo systemctl stop datadog-agent |
| Start agent | sudo systemctl start datadog-agent |
Config File Locations (SQL VM)
| File | Purpose |
|---|---|
/etc/datadog-agent/datadog.yaml | Main agent config (API key, hostname, tags) |
/etc/datadog-agent/conf.d/sqlserver.d/conf.yaml | SQL Server integration (connection, custom queries) |
/etc/datadog-agent/conf.d/sqlserver.d/logs.yaml | SQL Server log collection |
Disabling Datadog Agents and Integrations
When the trial ends or you want to remove Datadog:
- Set
dd_api_key = ""interraform.tfvars - Run
terraform apply— conditional resources are destroyed - SSH into Airflow VM and remove the agent:
docker rm -f dd-agent - SSH into SQL VM and stop the agent:
sudo systemctl disable datadog-agent && sudo systemctl stop datadog-agent - Revert Dockerfile entrypoint:
ENTRYPOINT ["python", "utils/run_pipeline.py"]- Remove
ddtrace>=2.10.0fromrequirements.txt - Rebuild and push the pipeline image
- The logger and run_pipeline trace code no-ops automatically (
ImportErrorguard)
One terraform apply + one image rebuild cleans up everything.
Related Notes
- datadog-architecture-overview — full observability architecture
- datadog-agent-airflow-vm — Airflow VM agent setup
- datadog-agent-sql-vm — SQL VM agent setup
- datadog-apm-traces — APM trace instrumentation
- datadog-sql-server-logs — SQL Server log collection
- datadog-gcp-integration — GCP Cloud Run metrics integration
- common pipeline errors — project-specific error reference including Datadog issues