Skip to content

Instantly share code, notes, and snippets.

@mikeda
Created May 13, 2012 15:07
Show Gist options
  • Save mikeda/2688861 to your computer and use it in GitHub Desktop.
Save mikeda/2688861 to your computer and use it in GitHub Desktop.
fluentdのin_tailで特定フィールドを数値型に変換する拡張クラス
#@config
#<source>
# type mytail
# format apache
# path /var/log/httpd/access_log
# tag apache.access
# to_i size,code
#</source>
module Fluent
class MyTail < TailInput
Fluent::Plugin.register_input('mytail', self)
config_param :to_i, :string
def configure(conf)
super
@to_i = @to_i.split(',').map {|path| path.strip }
end
def parse_line(line)
time, record = @parser.parse(line)
@to_i.each {|key|
record[key] = record[key].to_i
}
return time, record
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment