Module: Fluent::Mixin::RewriteTagName
- Includes:
- RecordFilterMixin
- Defined in:
- lib/fluent/mixin/rewrite_tag_name.rb
Defined Under Namespace
Classes: PlaceholderExpander
Constant Summary collapse
- DEFAULT_HOSTNAME_COMMAND =
'hostname'
Instance Attribute Summary collapse
-
#hostname_command ⇒ Object
Returns the value of attribute hostname_command.
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
Instance Attribute Details
#hostname_command ⇒ Object
Returns the value of attribute hostname_command.
5 6 7 |
# File 'lib/fluent/mixin/rewrite_tag_name.rb', line 5 def hostname_command @hostname_command end |
#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
#configure(conf) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/fluent/mixin/rewrite_tag_name.rb', line 9 def configure(conf) super @placeholder_expander = PlaceholderExpander.new hostname_command = @hostname_command || DEFAULT_HOSTNAME_COMMAND hostname = `#{hostname_command}`.chomp @placeholder_expander.set_hostname(hostname) end |
#filter_record(tag, time, record) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/fluent/mixin/rewrite_tag_name.rb', line 18 def filter_record(tag, time, record) super if @tag rewrite_tag!(tag) end end |
#rewrite_tag!(tag) ⇒ Object
25 26 27 28 29 |
# File 'lib/fluent/mixin/rewrite_tag_name.rb', line 25 def rewrite_tag!(tag) @placeholder_expander.set_tag(tag) emit_tag = @placeholder_expander.(@tag) tag.sub!(tag, emit_tag) end |