我有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代理可以看到应用程序容器的起伏,但没有收到日志
答案 0 :(得分:0)
在我看来,您似乎在docker-compose main_container {
display: flex;
width: 100%;
height: 100%;
align-items: center;
justify-content: center;
flex-direction: row;
border: 1px solid #DDDDDD;
border-bottom: 1px solid #DDDDDD;
text-align: left;
.div_2 {
width: 90%;
}
服务配置中缺少几个环境变量。还有添加用于从Docker套接字跟踪日志的注册表的卷。如果没有,也许可以尝试这样的事情?
datadog
从那里开始,如果仍然遇到麻烦,则可能需要联系support@datadoghq.com寻求帮助。他们很快就会回复。