Class: Fluent::HostnameOutput

Inherits:
Output
  • Object
show all
Includes:
SetTagKeyMixin, SetTimeKeyMixin
Defined in:
lib/fluent/plugin/out_hostname.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



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

def configure(conf)
  super

  if @key_name.empty?
    raise Fluent::ConfigError, "key_name is must not be specified"
  end

  if @add_prefix
    @added_prefix_string = @add_prefix + '.'
  end
end

#emit(tag, es, chain) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fluent/plugin/out_hostname.rb', line 28

def emit(tag, es, chain)
  if @add_prefix
    tag = if tag.length > 0
            @added_prefix_string + tag
          else
            @add_prefix
          end
  end

  es.each do |time,record|
    record[@key_name] = @host 
    Fluent::Engine.emit(tag, time, record)
  end

  chain.next
end