Created
May 13, 2012 15:07
-
-
Save mikeda/2688861 to your computer and use it in GitHub Desktop.
fluentdのin_tailで特定フィールドを数値型に変換する拡張クラス
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
#@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