Class: Fluent::ReplaceOutput

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_replace.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object

Raises:

  • (Fluent::ConfigError)


9
10
11
12
13
14
# File 'lib/fluent/plugin/out_replace.rb', line 9

def configure(conf)
  super

  @rules = YAML.load_file(@rules_yaml) rescue nil
  raise Fluent::ConfigError, "#{@rules_yaml} is not found" unless @rules
end

#emit(tag, es, chain) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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, array|
        array.each do |rule|
          record[key] = rule[record[key]] if rule.keys.include?(record[key])
        end
      end
    rescue
      raise Fluent::ConfigError, 'Invalid YAML format'
    end
    Fluent::Engine.emit(tag, time, record)
  end

  chain.next
end