Datadog Agent on Docker
The Datadog Agent on Docker collects metrics, logs, events, and traces from your containerized applications and forwards them to Kloudfuse. Deploy the agent container alongside your services with minimal configuration.
Quick Start
Use the official Datadog Agent image to start collecting all signal types from your Docker host in a single docker run command:
docker run -d \
--name datadog-agent \
-e DD_API_KEY=kloudfuse \
-e DD_DD_URL=https://<kloudfuse-hostname>/ingester \
-e DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true \
-e DD_LOGS_ENABLED=true \
-e DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true \
-e DD_APM_ENABLED=true \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
--volume /proc:/host/proc:ro \
--volume /sys:/host/sys:ro \
--volume /host:/host:ro \
datadog/agent:latest
Docker Compose Deployment
For Docker Compose environments, add a datadog service to your existing docker-compose.yaml and build a custom agent image to point the agent at Kloudfuse.
Add the Agent Service
Add the following datadog service entry to your docker-compose.yaml:
services:
datadog:
build: ./datadog
container_name: datadog-agent
links:
- <your-service> # add links to services you want to monitor
environment:
- DD_API_KEY=kloudfuse
- DD_CONTAINER_EXCLUDE=name:datadog-agent # optional: exclude agent's own logs
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /proc/:/host/proc/:ro
- /sys/fs/cgroup:/host/sys/fs/cgroup:ro
- /var/lib/docker/containers:/var/lib/docker/containers:ro
Create the Agent Configuration
Create a datadog/ directory and add a datadog.yaml file to configure the agent to send all signal types to Kloudfuse:
api_key: kloudfuse
site: datadoghq.com
dd_url: "https://<kloudfuse-hostname>/ingester"
skip_ssl_validation: true # remove if you want to enforce TLS validation
logs_enabled: true
logs_config:
logs_dd_url: "<kloudfuse-hostname>:443"
use_http: true
logs_no_ssl: false
auto_multi_line_detection: false
use_v2_api: false
container_collect_all: true
apm_config:
enabled: true
apm_dd_url: "<kloudfuse-hostname>:443/ingester"
process_config:
process_dd_url: "https://<kloudfuse-hostname>/ingester"
events_dd_url: "https://<kloudfuse-hostname>/ingester"
container_collection:
enabled: false
metadata_providers:
- name: host
interval: 300
use_v2_api:
series: true
Collect Events
To enable collection of Docker container lifecycle events (start, stop, die) and system events, add DD_EVENT_COLLECTION=true to the agent’s environment:
docker run -d \
--name datadog-agent \
-e DD_API_KEY=kloudfuse \
-e DD_SITE=https://<kloudfuse-hostname>/ingester \
-e DD_EVENT_COLLECTION=true \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
datadog/agent:latest
Or in datadog.yaml:
collect_events: true
Collect Logs
Log collection is enabled by default when you set DD_LOGS_ENABLED=true and DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true.
The agent collects logs from all running containers via the Docker log driver.
To collect logs from additional services with file-based log output, mount the service log directory:
docker run -d --name nginx -v /path/to/nginx/logs:/var/log/nginx nginx
See Datadog — Custom Log Collection for file-based collection configuration.
Collect Metrics
Container metrics are collected automatically when the Docker socket is mounted. To collect additional metrics from a service, ensure the service exposes a metrics endpoint:
docker run -d \
--name nginx \
-e DD_AGENT_HOST=datadog-agent \
-e DD_DOGSTATSD_PORT=8125 \
nginx
To enable the OpenMetrics check for Prometheus-style metrics, copy the example configuration:
cp /etc/datadog-agent/conf.d/openmetrics.d/conf.yaml.example \
/etc/datadog-agent/conf.d/openmetrics.d/conf.yaml
See Datadog — OpenMetrics Integration for configuration options.
Collect Traces
APM tracing is enabled when DD_APM_ENABLED=true is set on the agent container.
Instrument your application with the appropriate Datadog tracing library and point it at the agent:
docker run -d \
--name my-app \
-e DD_AGENT_HOST=datadog-agent \
-e DD_TRACE_ENABLED=true \
-e DD_ENV=production \
-e DD_SERVICE=my-service \
-e DD_VERSION=1.0.0 \
my-app:latest