16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/fluent/plugin/out_replace.rb', line 16
def emit(tag, es, chain)
tag = @tag if @tag
es.each do |time, record|
begin
@rules.each do |key, rule|
target = record[key].to_s
rule.each do |from, to|
if match_data = from.to_s.match(/\/(?<pattern>.+)\//)
pattern = Regexp.new(match_data[:pattern])
record[key] = target.gsub(pattern, to) if target.match(pattern)
else
record[key] = to if from.to_s == target
end
end
end
rescue
raise Fluent::ConfigError, 'Invalid YAML format'
end
Fluent::Engine.emit(tag, time, record)
end
chain.next
end
|