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.



6
7
8
# File 'lib/fluent/plugin/out_split.rb', line 6

def initialize
  super
end

Instance Method Details

#configure(conf) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fluent/plugin/out_split.rb', line 21

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



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fluent/plugin/out_split.rb', line 35

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
  chain.next
rescue => e
  $log.warn e.message
  $log.warn e.backtrace.join(', ')
end