たごもりすメモ

コードとかその他の話とか。

fluent-plugin-sampling-filter and fluent-plugin-datacounter released! #fluentd


Fluentd  fluent-plugin-datacounter  fluent-plugin-datacounter  fluent-plugin-sampling-filter 

fluent-plugin-datacounter | RubyGems.org | your community gem host
fluent-plugin-sampling-filter | RubyGems.org | your community gem host

fluent-plugin-sampling-filter

リアルタイムに各種の統計情報を時系列で取りたいという用途はいろいろとありますが、そのような場合の多くは全メッセージを対象とする必要はありません。というかメッセージ流量が多い場合は統計処理の負荷(やそのためのノードへの転送負荷)が馬鹿にならず、適当な割合にサンプリングしたメッセージに対して処理をすればいいや、というケースが多いと思います。
これはそのためのものです。全メッセージの処理を行っている fluentd の設定のどこか(メッセージがきちんとparseされたあと)に out_copy と組合せてこれを突っ込んで、1/10 とか 1/100 とかだけを統計処理用に別タグとして出力してやるような使いかたを想定しています。

fluent-plugin-datacounter

 match match
(to_s)HTTP (2xx: ^2\d\d$ )

ということで


fluentdHTTPout_growthforecast 


(accesslog.hoge parse)
<source>
  type forward
</source>

# out_sampling_filter strongly recommended
<match accesslog.**>
  type sampling_filter
  interval 10
  remove_prefix accesslog
  add_prefix sampled
</match>

<match sampled.**>
  type datacounter
  tag httpstatus
  aggregate tag
  count_key status
  pattern1 2xx ^2\d\d$
  pattern2 3xx ^3\d\d$
  pattern3 4xx ^4\d\d$
  pattern4 5xx ^5\d\d$
</match>

<match httpstatus>
  type stdout
</match>

 GrowthForecastJSON Nagios HTTP STATUS 500 25% HTTP STATUS 4xx 90%