Last active
December 12, 2015 00:08
-
-
Save harukasan/4681483 to your computer and use it in GitHub Desktop.
Forwardプラグインで投げるときにホスト名を追加する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Forward with hostname | |
# | |
# harukasan <harukasan@pixiv.com> | |
# | |
# == configure | |
# key (optional):: キー名(default: host) | |
# | |
class ForwardWithHostnameOutput < Fluent::ForwardOutput | |
Fluent::Plugin.register_output('forward_with_hostname', self) | |
config_param :host_key, :string, :default => 'host' | |
def start | |
@hostname = `hostname`.strip | |
super | |
end | |
def emit(tag, es, chain) | |
es.each do |time, record| | |
record[@host_key] = @hostname | |
end | |
super(tag, es, chain) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment