Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Showing posts with label fluentd. Show all posts
Showing posts with label fluentd. Show all posts

August 23, 2013

FluentdでMySQLのスロークエリログをMongoDBに保存してみる

1. スロークエリの設定を済ませます。

MySQLのスロークエリログの設定メモ
http://madroom-project.blogspot.jp/2013/08/mysql.html

2. fluent-plugin-mysqlslowquery をインストールします。
$ sudo fluent-gem install fluent-plugin-mysqlslowquery
3. /etc/fluent/fluent.conf を編集します。
<source>
  type mysql_slow_query
  path /var/log/mysql/mysql-slow.log
  tag mongo.mysql.slow
</source>
<match mongo.mysql.slow>
  type mongo
  database fluent
  collection mysql.slow
</match>
3. fluentdを起動します。
$ sudo fluentd
4. 適当にクエリを発行します。
$ mysql -u root -p[パスワード] mysql
mysql> select * from db where 1 = 1;
5. MongoDB側を確認します。(反映まで少しラグがあるかも)

FluentdでApacheのアクセスログをMongoDBに保存するメモ(Ubuntu13.04)

メモです。

FluentdとMongoDBのインストールは済ませてある前提です。

1. fluent-plugin-mongoをインストール
sudo fluent-gem install fluent-plugin-mongo

2. /var/log/fluent ディレクトリを作成

3. /etc/fluent/fluent.conf を作成
<source>
  type tail
  format apache2
  path /var/log/apache2/access.log
  pos_file /var/log/fluent/apache2.access_log.pos
  tag mongo.apache.access
</source>
<match mongo.apache.access>
  type mongo
  database fluent
  collection apache.access
</match>
4. 確認
$ sudo fluentd
ブラウザから適当にアクセスして DB => fluent, コレクション => apache.access を確認。

5. 備考
まだあまり調べていないんですが、見た感じ、sourceでpath値のログファイルをtailしつつ、pos_file値の名前で保存。tag値でタグを付けておく。matchでタグ名(ワイルドカードも可)を指定して、設定の通りに処理をする。みたいな感じですかね。

次はMySQLのスロークエリをやってみよう。

--

追記:
"pos_file"について参考 http://colopl.co.jp/tech/blog/2012/05/1808/