fluentdで複数のシステムへログを転送したいときのTips。copyモジュールを使うという話。
<source> type tail path /var/log/myapp/nginx/access.log ... tag myapp.nginx.access </source> # Output <match myapp.nginx.access> type norikra norikra xxx.xxx.xxx.xxx:xxxxx ... </match> <match myapp.nginx.access> type elasticsearch host xxx.xxx.xxx.xxx port xxxx ... </match>
...が, この書き換えてしまうと, 上に書かれたtype norikraの設定は有効になるのですが, 下のtype elasticsearchの設定は一切反映されず, fluentdからElasticsearchに対してログが送られなくなってしまいます.
こういう場合は, fluentdのcopyプラグインを使って, 次のように書けば期待通りに動いてくれます.
<match myapp.nginx.access> type copy <store> type norikra norikra xxx.xxx.xxx.xxx:xxxxx ... </store> <store> type elasticsearch host xxx.xxx.xxx.xxx port xxxx ... </store> </match>