Fluentd not capturing docker logs

198 views
Skip to first unread message

de...@sofdesk.com

unread,
Apr 8, 2019, 6:54:20 PM4/8/19
to Fluentd Google Group
Hi all,

I'm stuck at step 3 of the docker logging guide https://www.fluentd.org/guides/recipes/docker-logging .

My setup:
I'm running the `td-agent` with systemd (as documented in the quick start guide).

- My fluentd conf (taken from the docker guide)
```
[root@ip-172-31-39-98 td-agent]# cat td_input_docker.conf 
<source>
  @type forward
  port 24224
  bind 0.0.0.0
</source>

<match *.*>
  @type stdout
</match>
```

The Problem:
The docker run command isn't being logged in the td-agent log file `docker run --log-driver=fluentd ubuntu echo 'Hello Fluentd!'`

The log file only contains error messages saying that it can't match any patterns:
```
[root@ip-172-31-39-98 td-agent]# tail -n 6 -f /var/log/td-agent/td-agent.log 
2019-04-08 20:36:51 +0000 [warn]: #0 no patterns matched tag="1f165a460ccd"
2019-04-08 20:36:51.964595043 +0000 fluent.warn: {"tag":"1f165a460ccd","message":"no patterns matched tag=\"1f165a460ccd\""}
2019-04-08 21:36:54 +0000 [warn]: #0 no patterns matched tag="5bfb2b2fd881"
2019-04-08 21:36:54.185478907 +0000 fluent.warn: {"tag":"5bfb2b2fd881","message":"no patterns matched tag=\"5bfb2b2fd881\""}
2019-04-08 21:37:26 +0000 [warn]: #0 no patterns matched tag="3f641ef36f12"
2019-04-08 21:37:26.698440917 +0000 fluent.warn: {"tag":"3f641ef36f12","message":"no patterns matched tag=\"3f641ef36f12\""}
```

Attempted solutions:

- Specifying the fluentd server `ip:port` made no difference:
```docker run --log-driver=fluentd --log-opt fluentd-address=127.0.0.1:24224 ubuntu echo "TESTLOG"```

- I tried a `tailf -f /proc/<fluentd-PID>/fd/1` then I ran
```docker run --log-driver=fluentd --log-opt fluentd-address=0.0.0.0:24224 ubuntu echo "TESTEST"```
But nothing showed up in the stdout of the process...


I pretty much followed the same steps in the tutorial, but tweaked them to use systemd instead of running the td-agent in the foreground. Any one have an idea why the `td-agent` isn't logging the docker container stdout?

Mr. Fiber

unread,
Apr 8, 2019, 10:11:51 PM4/8/19
to Fluentd Google Group
Ah, recent docker logging driver removes "docker" prefix from tag.
You need to add tag with --log-opt like below:

docker run --log-driver=fluentd --log-opt tag="docker.{{.ID}}"


We will update the article.


--
You received this message because you are subscribed to the Google Groups "Fluentd Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fluentd+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

de...@sofdesk.com

unread,
Apr 9, 2019, 12:22:13 AM4/9/19
to Fluentd Google Group
Thanks @repeatedly, that solved the issue. 
Now to test with AWS ECS to see if it still works...
To unsubscribe from this group and stop receiving emails from it, send an email to flu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages