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.



9
10
11
# File 'lib/fluent/plugin/filter_add.rb', line 9

def initialize
  super
end

Instance Method Details

#configure(conf) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fluent/plugin/filter_add.rb', line 13

def configure(conf)
  super

  @add_hash = Hash.new

  conf.elements.select {|element|
    element.name == 'pair'
  }.each do |pair|
    pair.each do | k,v|
     pair.has_key?(k)  # suppress warnings about unused configuration
     @add_hash[k] = v
    end
  end
end

#filter(tag, time, record) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/fluent/plugin/filter_add.rb', line 28

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