class Fluent::Plugin::DictMapFilter
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_dict_map.rb, line 14 def configure(conf) super if !@dictionary and !@dictionary_path raise Fluent::ConfigError, "dictionary or dictionary_path parameter is required" end @dict = @dictionary ? @dictionary : load_dict(@dictionary_path) @target = @destination_key_name.nil? ? @key_name : @destination_key_name end
filter(tag, time, record)
click to toggle source
# File lib/fluent/plugin/filter_dict_map.rb, line 25 def filter(tag, time, record) value = record[@key_name] return record unless value value = value.to_s if @dict.include?(value) record[@target] = @dict[value] elsif !@default_value.nil? record[@target] = @default_value end record end
Private Instance Methods
load_dict(dict_path)
click to toggle source
# File lib/fluent/plugin/filter_dict_map.rb, line 42 def load_dict(dict_path) case when dict_path.end_with?(".json") require 'json' JSON.parse(File.read(dict_path)) else raise Fluent::ConfigError, "Invalid file type. Supported type is only JSON: #{dict_path}" end end