Skip to content

Commit 41a76ed

Browse files
committed
Add the ability to collect logs
1 parent e7aa6f0 commit 41a76ed

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ version: "3"
2121
services:
2222
web:
2323
build: web
24+
# Uncomment to enable log collection for the web container
25+
# labels:
26+
# com.datadoghq.ad.logs: '[{"source": "web"}]'
2427
command: python app.py
2528
ports:
2629
- "5000:5000"
@@ -32,20 +35,36 @@ services:
3235
- DATADOG_HOST=datadog # used by the web app to initialize the Datadog library
3336
redis:
3437
image: redis
38+
# Uncomment to enable log collection for the redis container
39+
# labels:
40+
# com.datadoghq.ad.logs: '[{"source": "redis"}]'
3541
# agent section
3642
datadog:
3743
build: datadog
44+
# Uncomment to enable log collection for the agent container
45+
# labels:
46+
# com.datadoghq.ad.logs: '[{"source": "redis"}]'
3847
links:
3948
- redis # ensures that redis is a host that the container can find
4049
- web # ensures that the web app can send metrics
4150
environment:
4251
- DD_API_KEY=__your_datadog_api_key_here__
52+
- DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
53+
# Uncomment to enable the log collection feature
54+
# - DD_LOGS_ENABLED=true
55+
# - DD_LOGS_CONFIG_DOCKER_CONTAINER_USE_FILE=true
4356
volumes:
4457
- /var/run/docker.sock:/var/run/docker.sock
4558
- /proc/:/host/proc/:ro
4659
- /sys/fs/cgroup:/host/sys/fs/cgroup:ro
60+
# Uncomment to enable the log collection feature
61+
# - /var/lib/docker/containers:/var/lib/docker/containers:ro
4762
```
4863

64+
The Datadog Agent can also optionnaly collect logs from any container, if you
65+
want to do so just uncomment the relevant lines from the `docker-compose.yml`
66+
file.
67+
4968
# Configuring the Agent
5069

5170
Because the Agent needs to monitor redis it needs:
@@ -75,4 +94,4 @@ How to test this?
7594
1. Clone this repository
7695
1. Update your `DD_API_KEY` in `docker-compose.yml`
7796
1. Run all containers with `docker-compose up`
78-
1. Verify in Datadog that your container picks up the docker and redis metrics
97+
1. Verify in Datadog that your container picks up the docker and redis metrics

datadog/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
FROM datadog/agent:latest
1+
FROM gcr.io/datadoghq/agent:latest
22
ADD conf.d/redisdb.yaml /etc/datadog-agent/conf.d/redisdb.yaml

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ version: "3"
22
services:
33
web:
44
build: web
5+
# Uncomment to enable log collection for the web container
6+
# labels:
7+
# com.datadoghq.ad.logs: '[{"source": "web"}]'
58
command: python app.py
69
ports:
710
- "5000:5000"
@@ -13,16 +16,27 @@ services:
1316
- DATADOG_HOST=datadog # used by the web app to initialize the Datadog library
1417
redis:
1518
image: redis
19+
# Uncomment to enable log collection for the redis container
20+
# labels:
21+
# com.datadoghq.ad.logs: '[{"source": "redis"}]'
1622
# agent section
1723
datadog:
1824
build: datadog
25+
# Uncomment to enable log collection for the agent container
26+
# labels:
27+
# com.datadoghq.ad.logs: '[{"source": "redis"}]'
1928
links:
2029
- redis # ensures that redis is a host that the container can find
2130
- web # ensures that the web app can send metrics
2231
environment:
2332
- DD_API_KEY=__your_datadog_api_key_here__
2433
- DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
34+
# Uncomment to enable the log collection feature
35+
# - DD_LOGS_ENABLED=true
36+
# - DD_LOGS_CONFIG_DOCKER_CONTAINER_USE_FILE=true
2537
volumes:
2638
- /var/run/docker.sock:/var/run/docker.sock
2739
- /proc/:/host/proc/:ro
2840
- /sys/fs/cgroup:/host/sys/fs/cgroup:ro
41+
# Uncomment to enable the log collection feature
42+
# - /var/lib/docker/containers:/var/lib/docker/containers:ro

0 commit comments

Comments
 (0)