Class: Fluent::Plugin::RewriteOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::RewriteOutput
- Defined in:
- lib/fluent/plugin/out_rewrite.rb
Instance Attribute Summary collapse
-
#rewrite_rule ⇒ Object
readonly
Returns the value of attribute rewrite_rule.
Instance Method Summary collapse
Instance Attribute Details
#rewrite_rule ⇒ Object (readonly)
Returns the value of attribute rewrite_rule.
15 16 17 |
# File 'lib/fluent/plugin/out_rewrite.rb', line 15 def rewrite_rule @rewrite_rule end |
Instance Method Details
#configure(conf) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# 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 |