LoginSignup
4
4

More than 5 years have passed since last update.

fluentd (+ output mongodb) install & setup

Last updated at Posted at 2013-03-01

ruby, rubygems, mongodbのセットアップは省略。

Ubuntu 12.04ですが他の環境でも基本的には変わらないと思われます。

Install

sudo gem install fluentd
sudo fluent-gem install fluent-plugin-mongo

Config

設定ファイルの生成
fluentd --setup ./fluent

vim fluent/fluent.conf

末尾などにコピペで追記する

fluent.conf
...
<match sample.**>
  type mongo
  host localhost
  database fluentd
  collection sample
<match sample.**>
...

Start

フォアグラウンドで起動
fluentd -c ./fluent/fluent.conf -vv

止める時はctrl+cで

Check

別のターミナルから
echo '{"json":"message"}' | fluent-cat sample.test
echo '{"json":"message 123"}' | fluent-cat sample.test
echo '{"json":"message text"}' | fluent-cat sample.test

さらに別のターミナルから
mongo
でmongoshellを起動
db.sample.find({}).sort({$natural:-1})
で挿入されたログが見れる

TODO

  • マシンの起動時に立ち上がるように設定
    • 実際の運用においてはfluentdのstable版をrmp/debパッケージ化したtd-agentを使ったほうが良い
  • apache, ruby, python, node.jsなどのログをmongodbに貯めてみる
  • 異常検知のプラグインを試したい
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4