LoginSignup
8
9

More than 5 years have passed since last update.

fluentdでクリックログ収集してます

Last updated at Posted at 2014-07-07

fluent-agent-liteでリンククリックのログ(サーバ2台)を集計サーバに送りつけて、
td-agentで、mysqlに突っ込むということをしています。

fluentd便利っすね。confファイル書くだけでログ集めてくれるんだから

業務なのであまり公開はしたくないのですが、ちょっと詰まってるところもあり、公開します
ご教示いただけますと幸いです。。

設定は以下です

tfluent.conf
<match panda.koala_startclick.**>
 type copy
<store>
  type file_alternative
  path /XXXXXXXXXXXXXXXXXXX_%Y%m%d
  compress gzip
  buffer_type file
  buffer_chunk_limit 256m
  output_include_time false
  output_include_tag false
  output_data_type attr:message
  add_newline true
</store>
<store>
 type parser
 remove_prefix panda
 add_prefix parsed
 format ltsv
 time_format %d/%b/%Y
 key_name message
</store>
</match>
<match parsed.koala_startclick.**>
 type copy
<store>
  type mysql_bulk
  host XXXXXXXXXXXXXXXXXXX
  database XXXXXXXXXXXXXXXXXXX
  username XXXXXXXXXXXXXXXXXXX
  password XXXXXXXXXXXXXXXXXXX
  column_names linkname,uniqid,datetime,useragent,useragenttype,deviceid,refererurl,serviceid,locationurl,ip
  table StartLogRawData
  on_duplicate_key_update true
  on_duplicate_update_keys linkname,uniqid,datetime
  flush_interval 60s
</store>
</match>


<match panda.koala_endpoint.**>
 type copy
<store>
  type file_alternative
  path /XXXXXXXXXXXXXXXXXXX_%Y%m%d
  compress gzip
  buffer_type file
  buffer_chunk_limit 256m
  output_include_time false
  output_include_tag false
  output_data_type attr:message
  add_newline true
</store>
<store>
   type parser
   remove_prefix panda
   add_prefix parsed
   format ltsv
   time_format %d/%b/%Y
   key_name message
</store>
</match>
<match parsed.koala_endpoint.**>
 type copy
 <store>
  type mysql_bulk
  host XXXXXXXXXXXXXXXXXXX
  database XXXXXXXXXXXXXXXXXXX
  username XXXXXXXXXXXXXXXXXXX
  password XXXXXXXXXXXXXXXXXXX
  column_names uniqid,datetime,useragent,useragenttype,deviceid,serviceid,ip,resultpoint,resultid,resultcount,resultanother1,resultanother2
  table EndPointRawData
  on_duplicate_key_update true
  on_duplicate_update_keys uniqid,datetime
  flush_interval 60s
 </store>

</match>


<match panda.koala_startclick_inner.**>
 type copy
<store>
  type file_alternative
  path /XXXXXXXXXXXXXXXXXXX_%Y%m%d
  compress gzip
  buffer_type file
  buffer_chunk_limit 256m
  output_include_time false
  output_include_tag false
  output_data_type attr:message
  add_newline true
</store>
</match>

これですが、10日ほどで、何故かtd-agentが新しいログを受け付けなくなり、td-agentの再起動で治ります。
その際に/var/log/td-agent/td-agent.logには何も吐かれておりません

いま、以下の試みをしています。
fluentdは基本メモリ上で動作します。
そのメモリがあふれてしまい、次の処理ができなくなってるのではないか??という仮説を立てました。
そのため、buffer_typeをファイルに変えました(2014/07/07)

*ちなみに、stdoutプラグインを開発環境で試してるのですが、特に処理のログも出ないです。

参考にしたのは以下
http://blog.glidenote.com/blog/2014/01/28/td-agent-queue-size-exceeds-limit/
http://docs.fluentd.org/ja/articles/out_file
http://tech-sketch.jp/2013/05/fluentd-buffer.html

これで治るのかちょっと定かではないので、様子見なのですが。。。。

色々わかったこと!

その1

まず、ログが出ないのは、in_multiprocessプラグインのバグ。外したら出ました
v11で、マルチプロセス標準搭載らしいですが、ログは出るんですかね。。。

その2

よく止まるのは、ファイルオープンの上限を超えているから。
http://docs.fluentd.org/ja/articles/before-install

こちらを実際本番かどうする前にやらないとダメです

8
9
1

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
8
9