Open nhatfield opened 2 years ago
Hello @nhatfield,
docker logs command should not work, and logs should be getting forwarded to fluentd
Actually there's been a feature added to Docker v20.10.0 (see #40543) that duplicates logs when remote loggers are used. This is known as "dual logging". This duplication allows to always use docker logs
, no matter what logger you set. So what you see is the expected behavior :wink: However, if you don't want this behavior, you can still disable it (see Disable the dual logging cache in the doc).
docker run -d -v /opt/logs:/var/logs/app/app.log --log-driver fluentd
This command is incomplete: there's no param set to configure the fluentd driver (eg. --log-opt fluentd-address=fluentdhost:24224
) and there's no image specified. Could you provide a full command please and your daemon config if you declared fluentd params there?
Also could you answer these questions please?
Actually there's been a feature added to Docker v20.10.0 (see #40543) that duplicates logs when remote loggers are used.
Definitely did not know this! Thank you.
This command is incomplete: there's no param set to configure the fluentd driver
Sorry i didnt type the full command in. The image is one that you wouldnt have access to. I have many many services that are using this same fluentd config though. Here's the full command
docker run -d --init --log-driver fluentd \
--log-opt tag=blockchain-etl \
--log-opt fluentd-address=logs.domain.net:5007 \
--log-opt fluentd-async=true \
-v /opt/etl_data:/var/data:rw \
-v /opt/etl_data/config:/opt/etl/config:rw \
-p 2154:2154 -p 8080:8080 \
-p 44159:44159 --name etl \
-e DATABASE_URL=postgresql://etl:password@blockchain-db:5432/blockchain etl:1.1.133
Did you double-check fluentd is running and accessible?
Yes it is always running and accessible, there are many services logging through it
How did you check no logs were sent to fluentd?
Kibana!
For example:
I can find all my services except this one which is odd. So im not sure what is special about this one service. I've even tried recreating it several times... I'm also running a different container on the same host and it is logging fine
Sorry i didnt type the full command in.
Your docker run
command looks normal.
I can find all my services except this one which is odd.
Little question: what do you mean by "all my services"? Are you talking about docker-compose (or Swarm) services? If that's the case, are you sure you fluentd pipeline isn't relying on a metadata set by docker-compose?
So im not sure what is special about this one service. I've even tried recreating it several times... I'm also running a different container on the same host and it is logging fine
There're too many moving parts. As you reported logs for that container where displayed by docker logs
, we can exclude the issue coming from your app. However, there's still Docker, Fluentd, Elasticsearch and Kibana involved here.
Could you try running tcpdump in parallel of your buggy container? If you have too much containers on that host and this makes running tcpdump cumbersome, you can try to set up netcat to forward what it receives to fluentd and use tcpdump on the port netcat is listening to.
Once you confirm with tcpdump that Docker isn't sending logs to fluentd, could you try to remove all the unrelated flags from docker run
(eg. -e
, -p
, -v
, --name
), use a public image and use a dummy shell script that write debug logs to container's stdout? With this process you could either find the cause of this issue is related to some misconfiguration/problem on your side, or obtain a "minimal bug reproducer" that anyone can run on their computer to do further debug.
This is a bug from what I can tell. When sending logs within the container, to
/dev/stdout
and/dev/stderr
it logs to the console as expecteddocker logs <container>
. However when I switch to fluentd driver, I can visually see the settings in inspect, but it continues to log to the console!Expected behavior
docker logs
command should not work, and logs should be getting forwarded to fluentdActual behavior
docker logs
command continues to work and logs are sent to the console and cached under /var/lib/docker/container/Steps to reproduce the behavior
Create a container and mount a log volume:
docker run -d -v /opt/logs:/var/logs/app/app.log --log-driver fluentd
Setup symlink to
/dev/stdout
for the log fileln -s /dev/stdout /opt/logs/app/app.log
ln -s /dev/stderr /opt/logs/app/err.log
Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.) Local environment running on CentOS 7