Module: Fluent::Mixin::RewriteTagName
- Includes:
- RecordFilterMixin
- Defined in:
- lib/fluent/mixin/rewrite_tag_name.rb
Instance Attribute Summary collapse
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
Instance Attribute Details
#tag ⇒ Object
Returns the value of attribute tag.
5 6 7 |
# File 'lib/fluent/mixin/rewrite_tag_name.rb', line 5 def tag @tag end |
Instance Method Details
#filter_record(tag, time, record) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/fluent/mixin/rewrite_tag_name.rb', line 7 def filter_record(tag, time, record) super if @tag rewrite_tag!(tag) end end |
#rewrite_tag!(tag) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fluent/mixin/rewrite_tag_name.rb', line 14 def rewrite_tag!(tag) placeholder = { '${tag}' => tag, '__TAG__' => tag } emit_tag = @tag.gsub(/(\${[a-z_]+(\[[0-9]+\])?}|__[A-Z_]+__)/) do $log.warn "RewriteTagNameMixin: unknown placeholder found. :placeholder=>#{$1} :tag=>#{tag} :rewritetag=>#{rewritetag}" unless placeholder.include?($1) placeholder[$1] end tag.gsub!(tag, emit_tag) end |