Class: Fluent::RetagOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::RetagOutput
- Defined in:
- lib/fluent/plugin/out_retag.rb
Instance Method Summary collapse
Instance Method Details
#configure(conf) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fluent/plugin/out_retag.rb', line 8 def configure(conf) super if not @tag and not @remove_prefix and not @add_prefix raise Fluent::ConfigError, "missing both of remove_prefix and add_prefix" end if @tag and (@remove_prefix or @add_prefix) raise Fluent::ConfigError, "both of tag and remove_prefix/add_prefix must not be specified" end if @remove_prefix @removed_prefix_string = @remove_prefix + '.' @removed_length = @removed_prefix_string.length end if @add_prefix @added_prefix_string = @add_prefix + '.' end end |
#emit(tag, es, chain) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fluent/plugin/out_retag.rb', line 25 def emit(tag, es, chain) tag = if @tag @tag else if @remove_prefix and ( (tag.start_with?(@removed_prefix_string) and tag.length > @removed_length) or tag == @remove_prefix) tag = tag[@removed_length..-1] end if @add_prefix tag = if tag and tag.length > 0 @added_prefix_string + tag else @add_prefix end end tag end es.each do |time,record| Fluent::Engine.emit(tag, time, record) end chain.next end |