Created
May 1, 2012 06:00
-
-
Save kzk/2565493 to your computer and use it in GitHub Desktop.
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
# | |
# Example Input | |
# | |
# 1335851771|a|b | |
# | |
# Example Conf: | |
# | |
# <source> | |
# type tail_char_delim | |
# path /path/to/the/file1 | |
# tag filter | |
# pos_file /var/log/td-agent/file1.pos | |
# time_key time | |
# delimiter | | |
# </source> | |
# | |
class TailCharDelimInput < Fluent::TailInput | |
Fluent::Plugin.register_input('tail_char_delim', self) | |
# Override 'configure_parser(conf)' method that initializes the parser. | |
def configure_parser(conf) | |
@delim = conf['delimiter'] | |
@time_key = conf['time_key'] | |
end | |
# Override 'parse_line(line)' method that returns time and record. | |
def parse_line(line) | |
s = line.force_encoding('UTF-8') | |
a = s.split(@delim) | |
h = { | |
'time' => a[0], | |
'key0' => a[1], | |
'key2' => a[2] | |
} | |
return h[@time_key], h | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment