Class: Fluent::Plugin::SplitMessage

Inherits:
Filter
  • Object
show all
Defined in:
lib/fluent/plugin/filter_split_message.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



12
13
14
# File 'lib/fluent/plugin/filter_split_message.rb', line 12

def configure(conf)
  super
end

#filter_stream(tag, es) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fluent/plugin/filter_split_message.rb', line 16

def filter_stream(tag, es)
  new_es = Fluent::MultiEventStream.new

  es.each do |time, record|
    begin
      unless record.key?(@field_key)
        return new_es
      end

      vals = record[@field_key].split(@delimiter)

      if vals.count > 1
        vals.each do |v|
          begin
            new_record = record.dup
            new_record[@field_key] = v.strip
            new_es.add(time, new_record)
          end
        end
      else
        new_es.add(time, record)
      end
    rescue => e
      router.emit_error_event(tag, time, record, e)
    end
  end

  return new_es
end