Class: Fluent::SplitOutput

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

Instance Method Summary collapse

Constructor Details

#initializeSplitOutput

Returns a new instance of SplitOutput.



15
16
17
# File 'lib/fluent/plugin/out_split.rb', line 15

def initialize
  super
end

Instance Method Details

#configure(conf) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fluent/plugin/out_split.rb', line 25

def configure(conf)
  super
  @keep_keys_array = @keep_keys.split(',')
  if @format == 'csv'
    @separator = ','
  elsif @format == 'tsv'
    @separator = '\t'
  elsif @format == 'space'
    @separator = /[\s ]/
  else
    @separator = @format
  end
end

#emit(tag, es, chain) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fluent/plugin/out_split.rb', line 39

def emit(tag, es, chain)
  es.each do |time, record|
    next if record[@key_name].nil?
    record[@key_name].split(@separator).each do|item|
      result = { @output_key => item }
      record.each do|key, value|
        result[key] = value if @keep_keys_array.include?(key)
      end
      router.emit(output_tag, time, result)
    end
  end
rescue => e
  log.warn e.message
  log.warn e.backtrace.join(', ')
ensure
  chain.next
end