Fluentd不写apache访问日志到mongodb

我按照这个链接的指示写入Apache访问日志到mongo db- http://docs.fluentd.org/articles/apache-to-mongodb

但是没有任何东西正在写入Mongo DB。 我正在使用db["access"].findOne();检查db["access"].findOne();

我的td-agent.conf文件的内容如下 –

 <source> type tail format apache2 path /var/log/httpd/access_log pos_file /var/log/td-agent/apache2.access_log.pos 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 flush_interval 10s # make sure to include the time key include_time_key true </match> 

我知道td-agent正在查看这个configuration文件,因为如果conf文件中有错误,/ /etc/init.d/td-agent start td-agent /etc/init.d/td-agent start失败。

上述pos_file的内容如下 –

 /var/log/httpd/access_log 0000000000000000 00000000 

我在寻找帮助,为什么这可能不工作。 有什么我失踪?

更新1:如果我添加一个匹配上面的源(Apache访问日志)写入到标准输出,我能够看到事件被logging到TD代理的日志。 所以这似乎是一个问题写给MongoDB。 我可以使用mongo命令从命令行连接到mongo。

更新2:突然之间,这已经开始工作,我不能解释为什么。 我只是改变了td-agentconfiguration,以匹配输出到标准输出和返回。 现在我不知道什么是错的,为什么它开始工作。 🙁

谢谢,

原来是一个许可问题。 之后工作的原因是我改变了td-agent init.d脚本以root身份运行进程。 默认情况下,它以用户td-agent身份运行,在这种情况下,它会抱怨说,即使认为日志文件具有权限666,它也没有权限访问apache访问日志文件。