class Fluent::NorikraPlugin::ConfigSection
Attributes
auto_field[RW]
escape_fieldname[RW]
field_definitions[RW]
filter_params[RW]
query_generators[RW]
target[RW]
target_matcher[RW]
time_key[RW]
Public Class Methods
new(section, enable_auto_query=true)
click to toggle source
# File lib/fluent/plugin/norikra/config_section.rb, line 7 def initialize(section, enable_auto_query=true) @target = nil @target_matcher = nil if section.name == 'default' # nil elsif section.name == 'target' # unescaped target name (tag style with dots) @target = section.arg @target_matcher = Fluent::GlobMatchPattern.new(section.arg) else raise ArgumentError, "invalid section for this class, #{section.name}: ConfigSection" end @auto_field = Fluent::Config.bool_value(section['auto_field']) @time_key = section['time_key'] @escape_fieldname = Fluent::Config.bool_value(section['escape_fieldname']) @filter_params = { :include => section['include'], :include_regexp => section['include_regexp'], :exclude => section['exclude'], :exclude_regexp => section['exclude_regexp'] } @field_definitions = { :string => (section['field_string'] || '').split(','), :boolean => (section['field_boolean'] || '').split(','), :integer => (section['field_integer'] || '').split(','), :float => (section['field_float'] || '').split(','), } @query_generators = [] section.elements.each do |element| if element.name == 'query' && enable_auto_query opt = {} if element.has_key?('fetch_interval') opt['fetch_interval'] = Fluent::Config.time_value(element['fetch_interval']) end @query_generators.push(QueryGenerator.new(element['name'], element['group'], element['expression'], element['tag'], opt)) end end end
Public Instance Methods
+(other)
click to toggle source
# File lib/fluent/plugin/norikra/config_section.rb, line 49 def +(other) if other.nil? other = self.class.new(Fluent::Config::Element.new('target', 'dummy', {}, [])) end r = self.class.new(Fluent::Config::Element.new('target', (other.target ? other.target : self.target), {}, [])) r.auto_field = (other.auto_field.nil? ? self.auto_field : other.auto_field) r.time_key = other.time_key || self.time_key others_filter = {} other.filter_params.keys.each do |k| others_filter[k] = other.filter_params[k] if other.filter_params[k] end r.filter_params = self.filter_params.merge(others_filter) r.field_definitions = { :string => self.field_definitions[:string] + other.field_definitions[:string], :boolean => self.field_definitions[:boolean] + other.field_definitions[:boolean], :integer => self.field_definitions[:integer] + other.field_definitions[:integer], :float => self.field_definitions[:float] + other.field_definitions[:float], } r.query_generators = self.query_generators + other.query_generators r end