module Fluent::Mixin::RewriteTagName

Constants

DEFAULT_HOSTNAME_COMMAND

Attributes

hostname_command[RW]
tag[RW]

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# 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) click to toggle source
Calls superclass method
# 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) click to toggle source
# File lib/fluent/mixin/rewrite_tag_name.rb, line 25
def rewrite_tag!(tag)
  @placeholder_expander.set_tag(tag)
  emit_tag = @placeholder_expander.expand(@tag)
  tag.sub!(tag, emit_tag)
end