24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/fluent/plugin/filter_single_key.rb', line 24
def filter_stream(tag, es)
new_es = MultiEventStream.new
es.each do |time, record|
begin
record.each do |k, v|
if k =~ @key_pattern
new_record =
if @new_key
{k.gsub(@key_pattern, @new_key) => v}
else
{k => v}
end
if @keep_key_pattern
keep_record = record.select { |k2, _| k2 =~ @keep_key_pattern }
unless keep_record.empty?
new_record = keep_record.merge(new_record)
end
end
new_es.add(time, new_record)
end
end
rescue => e
router.emit_error_event(tag, time, record, e)
end
end
new_es
end
|