Class: Fluent::Plugin::ValidateTagFilter

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

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/fluent/plugin/filter_validate_tag.rb', line 8

def configure(conf)
  super

  @regexps = []
  conf.keys.each do |key|
    if key =~ /\Aregexp[0-9]+\z/
      @regexps << Regexp.new(conf[key])
    end
  end
end

#filter(tag, time, record) ⇒ Object



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

def filter(tag, time, record)
  case
  when @max_length && tag.size > @max_length
    nil
  when !@regexps.empty? && @regexps.any? {|regexp| regexp !~ tag }
    nil
  else
    record
  end
end