Class: Fluent::ResolvFilter

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

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



13
14
15
16
17
# File 'lib/fluent/plugin/filter_resolv.rb', line 13

def configure(conf)
  super
  @remove_prefix = Regexp.new("^#{Regexp.escape(remove_prefix)}\.?") unless conf['remove_prefix'].nil?
  @key_prefix    = @key_name + "_" + @key_prefix
end

#filter(tag, es) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fluent/plugin/filter_resolv.rb', line 19

def filter(tag, es)
  new_es = MultiEventStream.new
  tag = tag.sub(@remove_prefix, '') if @remove_prefix
  tag = (@add_prefix + '.' + tag) if @add_prefix

  es.each do |time,record|
    record[@key_prefix] = Resolv.getname(record[@key_name]) rescue nil
    new_es.add(time, record)
  end
  return new_es
end