gpt4 book ai didi

docker - DataDog Docker代理未从应用程序容器接收日志

转载 作者:行者123 更新时间:2023-12-02 19:59:28 24 4
gpt4 key购买 nike

我有Golang应用程序,它使用Logrus将日志写入Stdout。
我试图重新创建这个https://github.com/DataDog/docker-compose-example场景,并用我的应用程序替换python应用程序。
但是日志并没有发送到Datadog dashboad
这是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代理可以看到应用程序容器的起伏,但没有收到任何日志

最佳答案

在我看来,您似乎在docker-compose datadog服务配置中缺少了几个环境变量。还有添加用于从Docker套接字跟踪日志的注册表的卷。如果没有,也许尝试这样的事情?

  # 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

从那里开始,如果仍然遇到麻烦,则可能需要联系support@datadoghq.com寻求帮助。他们很快就会回复。

关于docker - DataDog Docker代理未从应用程序容器接收日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55087322/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com