Class: Fluent::ExcludeFilterOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::ExcludeFilterOutput
- Defined in:
- lib/fluent/plugin/out_exclude_filter.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #emit(tag, es, chain) ⇒ Object
-
#initialize ⇒ ExcludeFilterOutput
constructor
A new instance of ExcludeFilterOutput.
- #match(k, v, record) ⇒ Object
- #yml_match(record) ⇒ Object
Constructor Details
#initialize ⇒ ExcludeFilterOutput
Returns a new instance of ExcludeFilterOutput.
11 12 13 |
# File 'lib/fluent/plugin/out_exclude_filter.rb', line 11 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fluent/plugin/out_exclude_filter.rb', line 15 def configure(conf) super @key = @key.to_s @value = @value.to_s @tag_prefix = "#{@add_tag_prefix}." @tag_proc = if @tag_prefix Proc.new {|tag| "#{@tag_prefix}#{tag}" } else Proc.new {|tag| tag } end @excludes_yml = nil if @file_path @excludes_yml = YAML.load_file(@file_path) end end |
#emit(tag, es, chain) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fluent/plugin/out_exclude_filter.rb', line 35 def emit(tag, es, chain) emit_tag = @tag_proc.call(tag) es.each do |time,record| if @key && @value next if match(@key, @value, record) end if @excludes_yml next if yml_match(record) end Fluent::Engine.emit(emit_tag, time, record) end chain.next end |
#match(k, v, record) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/fluent/plugin/out_exclude_filter.rb', line 68 def match(k, v, record) if @regexp return Regexp.compile(v.to_s).match(record[k]) else return record[k] == v.to_s end end |
#yml_match(record) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/fluent/plugin/out_exclude_filter.rb', line 52 def yml_match(record) @excludes_yml.each{|k,v| if v.kind_of?(Array) v.each{|va| if match(k, va, record) return true end } else if match(k, v, record) return true end end } return false end |