Y-Ken Studio

新しもの好きのデータエンジニアが四方山話をお届けします。

安定性を強化した fluent-plugin-munin v0.3.2をリリースしました #fluentd

ログ収集ツールFluentdで、リソース監視データも収集可能となる fluent-plugin-munin v3.0.2をリリースしました。
多数のMunin向けプラグインで採取できるデータを、お好みの間隔でFluentdに流すことが出来ます。

今回は不具合修正が主となるリリースです。

今回の主な修正事項

修正履歴より紹介します。

  • [Bug] munin-nodeへの接続が起動時に失敗すると、繋がるまでリトライを続け、Fluentdが起ち上がらなくなる不具合を修正
  • [Bug] munin-nodeへの接続が起動後の定期取得時に失敗すると、再度繋がるまで無限リトライとなる不具合を修正

新しいリトライ動作

リトライ機構を作り直したので、ログ出力メッセージと共に、その挙動を紹介します。
以下では分かりやすくするため、タグの接頭辞にdebug.を入れてログ出力が行われるようにしています。

設定サンプル

<source>
  type munin
  host localhost
  port 4949
  interval 10s
  tag_prefix debug.rewrite.munin
  record_hostname yes
  convert_type    yes
  service         cpu
</source>

まず、munin-nodeを停止した状態でFluentdを起動したときの出力はこうなります。
起動時にはまだ何もせず、起動完了後に接続処理を始めます。
インターバルは等比数列としており、初回接続エラーの後は30秒、その次は60秒、120秒、240秒・・・最大3840秒間隔での接続再試行を行います。

2013-07-13 16:36:00 +0900 [info]: adding source type="munin"
2013-07-13 16:36:00 +0900 [warn]: munin: connect failed  error_class=Munin::ConnectionError error="Connection refused - connect(2)" retry_interval=30

muninを起ち上げると、次のリトライで初期化処理が成功し、定期的なメトリクス取得が始まります。

2013-07-13 16:36:30 +0900 [info]: munin: munin-node ready  hostname="fluentd.example.com" service_list=["cpu", "df", "df_inode", "entropy", "forks", "fw_packets", "if_err_eth0", "if_eth0", "interrupts", "irqstats", "load", "memory", "netstat", "ntp_kernel_err", "ntp_kernel_pll_freq", "ntp_kernel_pll_off", "ntp_offset", "ntp_states", "open_files", "open_inodes", "proc_pri", "processes", "sendmail_mailqueue", "sendmail_mailstats", "sendmail_mailtraffic", "swap", "threads", "uptime", "users", "vmstat"]
2013-07-13 16:36:30 +0900 [info]: munin: activating service  service=["cpu"]
2013-07-13 16:36:30 +0900 debug.rewrite.munin.cpu: {"hostname":"fluentd.example.com","service":"cpu","user":6528636,"nice":28785,"system":5998305,"idle":2335182456,"iowait":1627270,"irq":144,"softirq":306041,"steal":0,"guest":0}

途中でMuninへの疎通が出来なくなると、リトライせずにログにエラーを記録します。

2013-07-13 16:36:40 +0900 [warn]: munin: fetch failed  error_class=Munin::ConnectionError error="Connection refused - connect(2)"

Muninへの疎通が出来るようになると、再び定期的なメトリクス取得が始まります。

2013-07-13 16:36:50 +0900 debug.rewrite.munin.cpu: {"hostname":"fluentd.example.com","service":"cpu","user":6528688,"nice":28785,"system":5998338,"idle":2335184372,"iowait":1627273,"irq":144,"softirq":306042,"steal":0,"guest":0}

トラブルシューティング

Munin::AccessDeniedというエラーでメトリクス情報を取得出来ない場合は、munin-node本体の設定を見直しましょう。
/etc/munin/munin-node.confallowもしくはcidr_allowにて、Fluentd側のIPからの接続を許可する設定にしてください。

謝辞

さいないぷ (@cynipe) さんにより、この不具合報告を頂きました。
ありがとうございます。 https://github.com/y-ken/fluent-plugin-munin/issues/1