class Fluent::Plugin::JsonFilter

JSON Filter class to override filter method

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_json.rb, line 35
def configure(conf)
  super

  @check.each do |chk|
    begin
      Hana::Pointer.parse(chk.pointer)
    rescue Hana::Pointer::FormatError => e
      raise Fluent::ConfigError, e
    end
  end
end
filter(_tag, _time, record) click to toggle source
# File lib/fluent/plugin/filter_json.rb, line 47
def filter(_tag, _time, record)
  @check.each do |chk|
    pointer = Hana::Pointer.new(chk.pointer)
    pointee = pointer.eval(record).to_s
    matched = chk.pattern.match(pointee).nil? ? false : true
    log.debug("check: #{matched ? 'pass' : 'fail'} [#{chk.pointer} -> '#{pointee}'] (/#{chk.pattern.source}/)")
    return nil unless matched
  end
  record
end