【发布时间】:2019-07-31 21:49:10
【问题描述】:
我有 Golang 应用程序,它使用 Logrus 将日志写入标准输出。 我试图重新创建这个https://github.com/DataDog/docker-compose-example 场景,并用我的应用程序替换 python 应用程序。 但日志不会进入 Datadog 仪表板 这是 docker-compose 我正在努力工作
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
我还尝试通过https://docs.datadoghq.com/logs/log_collection/docker/?tab=containerinstallation 说明为代理安装非撰写但简单的 docker 容器。
我运行我的 golang 应用程序容器
docker run -v /var/run/docker.sock:/var/run/docker.sock:rw -d testgo
使用 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"]
DD 代理可以看到应用容器的起伏,但没有收到任何日志
【问题讨论】:
-
您是否在代理上启用了日志收集?请参阅此处示例中使用的环境变量。 docs.datadoghq.com/logs/log_collection/docker/…
-
是的,我做到了,我已经更新了原帖
-
你确定吗?看起来您在原始帖子或任何地方的任何地方都没有
DD_LOGS_ENABLED=true变量...
标签: docker docker-compose datadog