Class: Fluent::FilterKeysOutput

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

Constant Summary collapse

DISCARD_TAG =
'discarded'

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



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

def configure(conf)
  super

  if (ensure_keys && denied_keys) || (ensure_keys.nil? && denied_keys.nil?)
    raise ConfigError, "filter_keys: Either ensure_keys or denied_keys are required to be set."
  end

  @ensure_keys = ensure_keys && ensure_keys.split(/\s*,\s*/)
  @denied_keys = denied_keys && denied_keys.split(/\s*,\s*/)

end

#filter_record(tag, time, record) ⇒ Object



42
43
44
# File 'lib/fluent/plugin/out_filter_keys.rb', line 42

def filter_record(tag, time, record)
  super(tag, time, record)
end

#process(tag, es) ⇒ Object



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

def process(tag, es)
  es.each { |time, record|
    t = tag.dup
    filter_record(t, time, record)
    if ensure_keys_in?(record) || denied_keys_not_in?(record)
      router.emit(t, time, record)
    else
      router.emit("#{DISCARD_TAG}.#{t}", time, record) if @add_tag_and_reemit
    end
  }
end