Class: Fluent::ConditionalFilterOutput

Inherits:
Output
  • Object
show all
Includes:
ConditionalFilterRule, HandleTagNameMixin
Defined in:
lib/fluent/plugin/out_conditional_filter.rb

Instance Method Summary collapse

Methods included from ConditionalFilterRule

#filter_record

Instance Method Details

#configure(conf) ⇒ Object



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

def configure(conf)
  super

  not_configured_params = %w[key_pattern condition filter].select { |p| !send(p.to_sym) }
  if not_configured_params.any?
    raise Fluent::ConfigError(
      "[out_conditional_filter] missing mandatory parameter: #{not_configured_params.join(',')}"
    )
  end

  @key_pattern_regexp = Regexp.new(key_pattern)
end

#emit(tag, es, chain) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fluent/plugin/out_conditional_filter.rb', line 30

def emit(tag, es, chain)
  es.each do |time, record|
    t = tag.dup
    record = filter_record(t, time, record, self)

    if record.any?
      router.emit(t, time, record)
    end
  end

  chain.next
end