Class: Fluent::AddFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/fluent/plugin/filter_add.rb

Instance Method Summary collapse

Constructor Details

#initializeAddFilter

Returns a new instance of AddFilter.



4
5
6
# File 'lib/fluent/plugin/filter_add.rb', line 4

def initialize
  super
end

Instance Method Details

#configure(conf) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fluent/plugin/filter_add.rb', line 8

def configure(conf)
  super

  @add_hash = Hash.new

  conf.elements.select {|element|
    element.name == 'pair'
  }.each do |pair|
    pair.each do | k,v|
     @add_hash[k] = v
    end
  end
end

#filter(tag, time, record) ⇒ Object



22
23
24
25
26
27
# File 'lib/fluent/plugin/filter_add.rb', line 22

def filter(tag, time, record)
  @add_hash.each do |k,v|
    record[k] = v
  end
  record
end