Skip to content

Commit

Permalink
feat(fluentd): support containerd log format
Browse files Browse the repository at this point in the history
Signed-off-by: Cryptophobia <aouzounov@gmail.com>
  • Loading branch information
Cryptophobia committed Nov 8, 2020
1 parent a17a8b0 commit e68c723
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -13,6 +13,12 @@ This work is based on the [docker-fluentd](https://github.com/fabric8io/docker-f

## Configuration

### Support containerd log format
By default, fluent parses logs in docker json format. If you use containerd, you only need to set the following environment variables

* `CONTAINER_TAIL_PARSER_TYPE="/^(?<time>.+) (?<stream>stdout|stderr)( (?<tags>.))? (?<log>.*)$/"`


### Enable more verbose logging
By default we do not capture kubernetes system logs. However, it is possible to tell fluentd to capture those logs just by specifying a few new environment variables.

Expand Down
9 changes: 6 additions & 3 deletions rootfs/fluentd/sbin/sources
@@ -1,16 +1,19 @@
#!/bin/bash
if [ -e "/var/log/containers" ]
then

cat << EOF >> $FLUENTD_CONF
<source>
@type tail
path /var/log/containers/*.log
pos_file /var/log/containers.log.pos
time_key time
time_format %Y-%m-%dT%H:%M:%S.%L%z
tag kubernetes.*
format json
read_from_head true
<parse>
@type "#{ENV['CONTAINER_TAIL_PARSER_TYPE'] || 'json'}"
time_key time
time_format %Y-%m-%dT%H:%M:%S.%L%z
</parse>
</source>
EOF

Expand Down

0 comments on commit e68c723

Please sign in to comment.