Class: Fluent::Plugin::MapFilter
Constant Summary
Fluent::ParseMap::Mixin::MMAP_MAX_NUM
Instance Method Summary
collapse
#check_mmap_range, #parse_map, #parse_multimap
included
Instance Method Details
29
30
31
32
33
34
35
|
# File 'lib/fluent/plugin/filter_map.rb', line 29
def configure(conf)
super
@format = determine_format()
configure_format()
@map = create_map(conf)
@map_support = Fluent::Plugin::MapSupport.new(@map, self)
end
|
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/fluent/plugin/filter_map.rb', line 55
def configure_format()
case @format
when "map"
when "record"
raise Fluent::ConfigError, "multi and 2 parameters(time, and record) are not compatible" if @multi
when "multimap"
else
raise Fluent::ConfigError, "format #{@format} is invalid."
end
end
|
#create_map(conf) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/fluent/plugin/filter_map.rb', line 68
def create_map(conf)
case @format
when "map"
parse_map()
when "record"
"[[#{@time}, #{@record}]]"
when "multimap"
parse_multimap(conf)
end
end
|
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/fluent/plugin/filter_map.rb', line 43
def determine_format()
if @format
@format
elsif @map
"map"
elsif @time && @record
"record"
else
raise Fluent::ConfigError, "Any of map, 2 parameters(time, and record) or format is required "
end
end
|
#filter_stream(tag, es) ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/fluent/plugin/filter_map.rb', line 80
def filter_stream(tag, es)
begin
new_es = Fluent::MultiEventStream.new
tag_output_es = @map_support.do_map(tag, es)
tag_output_es.each_pair do |tag, output_es|
output_es.each{|time, record|
new_es.add(time, record)
}
end
new_es
rescue SyntaxError => e
log.error "map command is syntax error: #{@map}"
e end
end
|
#stop ⇒ Object
37
38
39
40
41
|
# File 'lib/fluent/plugin/filter_map.rb', line 37
def stop
@map_support.stop
super
end
|