Class: Fluent::Plugin::SplitEventFilter

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

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



10
11
12
# File 'lib/fluent/plugin/filter_split_event.rb', line 10

def configure(conf)
  super
end

#filter_stream(tag, es) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fluent/plugin/filter_split_event.rb', line 14

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

  es.each do |time, record|
    begin
      if record.key?(@field)
        vals = record[@field].split(@terminator)

        if vals.count > 1
          vals.each do |v|
            new_record = record.dup
            new_record[@field] = v.strip

            new_es.add(time, new_record)
          end
        else
          new_es.add(time, record)
        end
      end
    rescue => e
      router.emit_error_event(tag, time, record, e)
    end
  end

  return new_es
end