Name: docker-compose-example
Owner: Datadog, Inc.
Description: A working example of using Docker Compose with Datadog
Created: 2015-05-05 17:05:52.0
Updated: 2018-02-09 11:44:05.0
Pushed: 2017-07-28 17:58:42.0
Homepage: null
Size: 5003
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Datadog offers native Docker container monitoring, either by running the Agent
on the host or running in a sidecar container. Which is the best way to run it?
It ultimately depends on the tooling you have in place to manage the Agent's
configuration. If you want to go Docker all the way, you can run the Agent as
a sidecar and control its configuration with custom Dockerfiles
.
Let's see what it looks like.
To build a meaningful setup, we start from the example that Docker put together to illustrate Compose. A simple python web application that connects to Redis to store the number of hits.
Here is the docker-compose.yml
that powers the whole setup.
ion: "2"
ices:
b:
build: web
command: python app.py
ports:
- "5000:5000"
volumes:
- ./web:/code # modified here to take into account the new app path
links:
- redis
environment:
- DATADOG_HOST=datadog # used by the web app to initialize the Datadog library
dis:
image: redis
agent section
tadog:
build: datadog
links:
- redis # ensures that redis is a host that the container can find
- web # ensures that the web app can send metrics
environment:
- API_KEY=__your_datadog_api_key_here__
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /proc/:/host/proc/:ro
- /sys/fs/cgroup:/host/sys/fs/cgroup:ro
Because the Agent needs to monitor redis it needs:
redisdb.yaml
in the container's /etc/dd-agent/conf.d
The Agent's Dockerfile
takes care of #1.
datadog/docker-dd-agent
conf.d/redisdb.yaml /etc/dd-agent/conf.d/redisdb.yaml
And the Compose yaml files creates the link to redis with:
nks:
- redis
How to test this?
API_KEY
in docker-compose.yml
docker-compose up