class Fluent::Plugin::RewriteOutput
Attributes
rewrite_rule[R]
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_rewrite.rb, line 17 def configure(conf) require 'fluent/plugin/rewrite_rule' super if @remove_prefix @removed_prefix_string = @remove_prefix + '.' @removed_length = @removed_prefix_string.length end if @add_prefix @added_prefix_string = @add_prefix + '.' end @rewrite_rule = Fluent::RewriteRule.new(self, conf) end
process(tag, es)
click to toggle source
# File lib/fluent/plugin/out_rewrite.rb, line 33 def process(tag, es) _tag = tag.clone if @remove_prefix and ((tag.start_with?(@removed_prefix_string) && tag.length > @removed_length) || tag == @remove_prefix) tag = tag[@removed_length..-1] || '' end if @add_prefix tag = tag && tag.length > 0 ? @added_prefix_string + tag : @add_prefix end es.each do |time, record| filtered_tag, record = @rewrite_rule.rewrite(tag, record) if filtered_tag && record && _tag != filtered_tag router.emit(filtered_tag, time, record) else if @enable_warnings $log.warn "Can not emit message because the tag(#{tag}) has not changed. Dropped record #{record}" end end end end