nginx
创建nginx docker
docker run -d --name nginx -p 80:80 -v $PWD/log/nginx:/var/log/nginx nginx
在当前目录创建 vim ./etc/fluent.conf 配置文件
<source>
@type tail
path /var/log/nginx/access.log
pos_file /tmp/nginx.access.pos
tag nginx.access.log
<parse>
@type nginx
</parse>
</source>
<match nginx.access.log>
@type copy
<store>
@type stdout
</store>
</match>
启动fluentd
docker run -d --name fluentd -v $(pwd)/etc:/fluentd/etc -v $(pwd)/log:/var/log fluent/fluentd
读取到的信息如下
2020-08-10 17:39:20.000000000 +0000 nginx.access.log: {"remote":"172.17.0.1","host":"-","user":"-","method":"GET","path":"/","code":"200","size":"612","referer":"-","agent":"curl/7.54.0","http_x_forwarded_for":"-"}