fluentd をmongodbでとりあえず動かしてみた
使う機会ありそうだったのでやってみる。めんどくさいんで色々デフォルト設定でやる。
$ gem install fluentd $ gem install fluent-plugin-mongo $ gem install bson_ext $ fluentd --setup ./etc/fluent $ vim etc/fluent/fluent.conf
mongoの fluent-debug に格納する
etc/fluent/fluent.conf
<source> type forward </source> <source> type http port 12000 </source> <match debug.**> type copy <store> type stdout </store> <store> type mongo host localhost database fluent collection debug </store> </match>
fluentdを起動して投げる
$ fluentd -c ./etc/fluent/fluent.conf $ curl http://localhost:12000/debug.curl -F 'json={"log":"hoge"}' # 投げる
mongo shell から確認
$ mongo > use fluent > db.debug.find() #ログ覗く
とりあえず動きました。実践的なログ解析とかはあとで。
参考: http://shinobra.com/2012/02/sawanoboly/gluent_getting_start