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.



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

def initialize
  super
end

Instance Method Details

#configure(conf) ⇒ Object



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

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



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

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