tail
in_tail输入插件从文本文件的尾部读取事件,类似于linux中的tail -F命令。
格式如下
<source>@type tailpath /var/log/httpd-access.logpos_file /var/log/td-agent/httpd-access.log.postag apache.access<parse>@type apache2</parse></source>
eg:
在当前目录下创建etc目录和 fluent.conf配置文件
$mkdir etc$vim etc/fluent.conf
如下配置内容
<source>@type tailpath /tmp/test.logpos_file /tmp/test.log.postag test.log<parse>@type none</parse></source><match test.log>@type copy<store>@type stdout</store><store>@type filepath /tmp/test_backup/</store></match>
创建docker
$ docker run -d --name fluentd -v $(pwd)/etc:/fluentd/etc -v $(pwd)/tmp:/tmp fluent/fluentd
$ docker logs fluentd2020-08-10 17:18:31.047687752 +0000 test.log: {"message":"hell world"}
查看备份文件
$ ls -ll ./tmp/test_backup/total 16-rw-r--r-- 1 baxiang staff 60 Aug 11 01:18 buffer.b5ac8924c6a3a1895406e4b7058a1db0c.log-rw-r--r-- 1 baxiang staff 68 Aug 11 01:18 buffer.b5ac8924c6a3a1895406e4b7058a1db0c.log.meta
查看备份文件内容
$ cat ./tmp/test_backup/buffer.b5ac8924c6a3a1895406e4b7058a1db0c.log2020-08-10T17:18:31+00:00 test.log {"message":"hell world"}
in_forward
in_forward插件通常用于从其他节点接收日志事件,这些节点包括其他Fluentd实例、fluent-cat命令行或者Fluentd客户端程序。这是目前效率最高的日志事件接收方法。
in_forward插件会在本地打开一个tcp监听socket,用于接收日志事件。同时,它也会开启一个udp端口用于接收和对端的心跳保活消息。
in_forward可接收json或MessagePack格式的数据,它会自动探测源数据是哪种格式。MessagePack是Fluentd内部使用的数据封装格式,因其效率高于json。
in_forward插件内置于Fluentd,无须安装。
<source>@type forwardport 24224bind 0.0.0.0</source>
in_http
in_http插件允许使用HTTP协议来采集日志事件。这个插件会建立一个支持REST风格的HTTP端点,来接收日志事件请求。
