I have Golang app, it writes logs to Stdout with Logrus. I was trying to recreate this https://github.com/DataDog/docker-compose-example scenario, and replace python app with my app. But logs aren't coming to Datadog dashboad This is docker-compose I'm trying to make work
version: "3"
services:
gos:
build: goapp
stdin_open: true
ports:
- "6000:6000"
volumes:
- /tmp/goapp:/tmp/goapp
- ./goapp:/code
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DATADOG_HOST=datadog
web:
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
redis:
image: redis
# agent section
datadog:
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:
- DD_API_KEY=34f-------63c
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /proc/:/host/proc/:ro
- /sys/fs/cgroup:/host/sys/fs/cgroup:ro
I also tried non-compose, but simple docker container installation for the agent by this https://docs.datadoghq.com/logs/log_collection/docker/?tab=containerinstallation instructions.
I run my golang app container with
docker run -v /var/run/docker.sock:/var/run/docker.sock:rw -d testgo
with Dockerfile
FROM golang:1.7.3
WORKDIR /go/src/github.com/alexellis/href-counter/
RUN go get -d -v github.com/Sirupsen/logrus
COPY app.go .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=0 /go/src/github.com/alexellis/href-counter/app .
EXPOSE 6000
LABEL "com.datadoghq.ad.logs"='[{"source": "goapp", "service": "webapp"}]'
CMD ["./app"]
and DD agent can see app container ups and downs but receive no logs
it appears to me like you're missing a couple environment vars in your docker-compose datadog
service configuration. And also the volume that adds the registry for tailing the logs from the docker socket. Maybe try something like this if you haven't?
# agent section
datadog:
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:
- DD_API_KEY=34f-------63c
- DD_LOGS_ENABLED=true
- DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true
- DD_AC_EXCLUDE="name:datadog-agent"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /proc/:/host/proc/:ro
- /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
- /opt/datadog-agent/run:/opt/datadog-agent/run:rw
from there, if you still end up with trouble, you may want to reach out to support@datadoghq.com to ask for help. They're pretty quick to reply.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.