class Fluent::JsonLookupFilter
Constants
- BUILTIN_CONFIGURATIONS
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_json_lookup.rb, line 39 def configure(conf) super conf.each_pair do |k, v| unless BUILTIN_CONFIGURATIONS.include?(k) conf.key(k) log.warn "Extra key provided! Ignoring '#{k} #{v}'" end end # GC.start end
deserialize_and_lookup(content, lookup)
click to toggle source
# File lib/fluent/plugin/filter_json_lookup.rb, line 52 def deserialize_and_lookup(content, lookup) values = {} begin deserialized = Yajl.load(content) if deserialized.is_a?(Hash) && deserialized.key?(lookup) && deserialized[lookup].is_a?(Hash) values = deserialized[lookup] end rescue Yajl::ParseError log.error "Error in plugin json_lookup, error parsing json_key's value #{content}'" end values end
filter_stream(_tag, es)
click to toggle source
# File lib/fluent/plugin/filter_json_lookup.rb, line 65 def filter_stream(_tag, es) new_es = MultiEventStream.new es.each do |time, record| values = {} if record.key?(@json_key) lookup = @use_lookup_key_value ? record[@lookup_key] : @lookup_key if record[@json_key][0] == '{' values = deserialize_and_lookup(record[@json_key], lookup) end end record.merge!(values) record.delete(@json_key) if @remove_json_key && record.key?(@json_key) new_es.add(time, record) end new_es end