这篇文章给大家介绍如何使用Fluentd+MongoDB采集Apache日志,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
我们今天介绍一个组合:Fluentd+MongoDB,用以实时收集半结构化数据。
fluent-gem install fluent-plugin-mongo
接下来就是配置的事了。
<source> @type tail path /var/log/apache2/access_log pos_file /var/log/td-agent/apache2.access_log.pos <parse> @type apache2 </parse> tag mongo.apache.access</source>
<match mongo.**> # plugin type @type mongo # mongodb db + collection database apache collection access # mongodb host + port host localhost port 27017 # interval <buffer> flush_interval 10s </buffer> # make sure to include the time key <inject> time_key time </inject></match>
$ ab -n 100 -c 10 http://localhost/
$ mongo> use apache> db["access"].findOne();{ "_id" : ObjectId("4ed1ed3a340765ce73000001"), "host" : "127.0.0.1", "user" : "-", "method" : "GET", "path" : "/", "code" : "200", "size" : "44", "time" : ISODate("2011-11-27T07:56:27Z") }{ "_id" : ObjectId("4ed1ed3a340765ce73000002"), "host" : "127.0.0.1", "user" : "-", "method" : "GET", "path" : "/", "code" : "200", "size" : "44", "time" : ISODate("2011-11-27T07:56:34Z") }{ "_id" : ObjectId("4ed1ed3a340765ce73000003"), "host" : "127.0.0.1", "user" : "-", "method" : "GET", "path" : "/", "code" : "200", "size" : "44", "time" : ISODate("2011-11-27T07:56:34Z") }
关于如何使用Fluentd+MongoDB采集Apache日志就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
原文链接:https://my.oschina.net/fluentd/blog/4354290