-
Notifications
You must be signed in to change notification settings - Fork 814
Docker Containers
If you are using Docker on one of your hosts, you will be interested in the Docker Integration. But you may also want to install the Agent or DogStatsD inside a Docker Container. This page will explain you how to do it.
To make your Agent run on a container, you will need to create a Docker image containing the Agent and your configuration. We already provide a base image containing the Agent and its dependencies so that you just have to add a layer with your configuration.
Create a Dockerfile
to set your API key.
FROM datadog/docker-dd-agent
# Set your API key
RUN sed -i -e"s/^.*api_key:.*$/api_key: YOUR_API_KEY/" /etc/dd-agent/datadog.conf
Build it.
docker build .
Then run it with the --privileged
flag. This flag allows the container to get access to the host system. It is needed to get system metrics (such as memory or CPU) from the host.
docker run -d -name dd-agent --privileged dd-agent_image_id
That's it! Now your Agent is reporting metrics about your host.
The default setup only report system metrics. You can change parameters in datadog.conf
file the same way as the API key. You can also add files to /etc/dd-agent/conf.d
and install packages/modules to enable specific integrations.
Here you can find some examples.
This container also runs DogStatsD. If you want to use it or to run DogStatsD only, give a look at docker-dogstatsd.
Basic information about the Agent execution are available through the logs
command.
docker logs dd-agent
If you want to get access to the real Agent logs, you will need to use volumes. A full documentation of volumes is available on Docker documentation. Here are two examples.
Create a volumes for the log directory when running the image.
docker run -d -name dd-agent -v /var/log/datadog --privileged dd-agent_image_id
Logs are now stored in a volume that you can access from other containers with the --volumes-from
parameter. For examples, if you want to look into it:
docker run --volumes-from dd-agent -name dd-agent-log-reader ubuntu /bin/bash
It will open a shell, then go to /var/log/datadog
to see Agent logs.
You can also use a host directory, let's say /var/docker-volumes/dd-agent/log
, as a log directory.
When you run the dd-agent container:
docker run -d -name dd-agent -v /var/docker-volumes/dd-agent/log:/var/log/datadog --privileged dd-agent_image_id
Now you should see Agent logs into /var/docker-volumes/dd-agent/log
on your host.
You can set logging to DEBUG verbosity by adding to your Dockerfile
:
RUN sed -i -e"s/^.*log_level:.*$/log_level: DEBUG/" /etc/dd-agent/datadog.conf