Class: Fluent::ResolvOutput

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

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



10
11
12
13
# File 'lib/fluent/plugin/out_resolv.rb', line 10

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

#emit(tag, es, chain) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/fluent/plugin/out_resolv.rb', line 15

def emit(tag, es, chain)
  tag = tag.sub(@remove_prefix, '') if @remove_prefix
  tag = (@add_prefix + '.' + tag) if @add_prefix
  es.each do |time,record|
    record[@key_name] = Resolv.getname(record[@key_name]) rescue record[@key_name].empty? ? 'n/a' : record[@key_name]
    Fluent::Engine.emit(tag, time, record)
  end
  chain.next
end