Fluent访问多个日志目录的配置方法

1、先尝试配置文件如下

<source>
 type tail
 path/home/aircom/mongodb-linux-i686-2.0.6/bin/logs/1001.log
 path /home/aircom/mongodb-linux-i686-2.0.6/bin/logs/1002.log

format /^*(?<message>.*)$/
 tag mongo.apache
</source>

2、启动:fluentd-c fluent.conf -vv &

得到提示:

2012-09-2713:00:48 +0800: plugin/in_forward.rb:60:listen: listening fluent socket on0.0.0.0:24224
2012-09-27 13:00:48 +0800: plugin/in_http.rb:74:start: listening http on0.0.0.0:8888
2012-09-27 13:00:48 +0800: plugin/in_tail.rb:262:initialize:following tail of /home/aircom/mongodb-linux-i686-2.0.6/bin/logs/1002.log

可见只生效了一个配置路径

3、更改配置文件为如下,有2段Source,分别配置不同的源日志路径。

<source>
 type tail
 path/home/aircom/mongodb-linux-i686-2.0.6/bin/logs/1001.log
format /^*(?<message>.*)$/
 tag mongo.apache
</source>
<source>
 type tail
 path/home/aircom/mongodb-linux-i686-2.0.6/bin/logs/1002.log
format /^*(?<message>.*)$/
 tag mongo.apache
</source>

4、重新启动 :fluentd-c fluent.conf -vv &

得到如下日志,2行初始化的部分,说明访问2个日志路径配置成功

012-09-2713:03:58 +0800: plugin/in_forward.rb:60:listen: listening fluent socket on0.0.0.0:24224
2012-09-27 13:03:58 +0800: plugin/in_http.rb:74:start: listening http on0.0.0.0:8888
2012-09-27 13:03:58 +0800: plugin/in_tail.rb:262:initialize:following tail of /home/aircom/mongodb-linux-i686-2.0.6/bin/logs/1001.log
2012-09-27 13:03:58 +0800: plugin/in_tail.rb:262:initialize: following tail of/home/aircom/mongodb-linux-i686-2.0.6/bin/logs/1002.log

5、结论:通过上面的测试,基本可以得出,配置多个访问路径的方法就是增加多个source段的配置来实现。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/d3183676c22c5d46f218b2eca7cc10f3.html