LoginSignup
5
4

More than 5 years have passed since last update.

fluentdを使ってpapertrailにTCP+TLS経路でログを送る

Posted at

papertrailというログ集約サービスがある。
ここはsyslogプロトコルでログを受け付けてくれて、fluent-plugin-remote_syslogというプラグインもあるのだが、素のUDPしかサポートされていなかったりする。
それがバックエンドに使っているremote_syslog_loggerというgemがあるのだが、それがUDPプロトコルを使っていて、このgemはTCP+TLSをサポートしていない。

まあ、これには理由があって過去のPRでリジェクトされている。
主な理由はloggerがブロッキングすると困るんだけど、それを真面目にハンドリングするためのコードを入れたくないので、UDPだけサポートするということらしい。
このサービスのメインのクライアントはgolangで書かれたremote_syslog2とrsyslog(syslog-ng)だと思うので、そっち使えってことなんだろうと思うけど、fluentdから送りたいものもある。

しかし、素のudpでインターネットを経由してログを送るってのはちょっと……。
それに、fluentdを使う場合、別にブロッキングしようがfluentdのbuffered output pluginの構造が面倒見てくれるはずなので、そんなの気にする必要が無い。

仕方ないので、それぞれforkしてカスタマイズした。
今はgithubから直接インストールして利用しているので、gemとしてリリースはしていない。

https://github.com/reproio/remote_syslog_logger/tree/support-tcp
https://github.com/reproio/fluent-plugin-remote_syslog/tree/use-custom-logger

<match message.warn>
  type remote_syslog
  host <%= node[:papertrail][:host] %>
  port <%= node[:papertrail][:port] %>
  severity warn
  hostname <%= node.name %>
  protocol tcp
  tls true
  ca_file /etc/papertrail-bundle.pem
</match>

こんな感じでいけるようにした。
ca_fileは、papertrailのサイトから落としてくる。でないとverifyに失敗する。

5
4
0

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
5
4