[英]DataDog docker agent doesn't recieve logs from application container
我有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代理可以查看應用程序容器的起伏變化,但未收到任何日志
在我看來,您似乎在datadog
-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尋求幫助。 他們很快就會回復。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.