No commit activity in last 3 years
No release in over 3 years
to add various placeholders for plugin configurations
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 2.1.5
 Project Readme

Fluent::Mixin::ConfigPlaceholders

Fluent::Mixin::ConfigPlaceHolders provide some placeholders to fluentd plugins that includes this mix-in. Placeholders below are expanded in 'super' of including plugin's #configure method.

Placeholder patterns are ${..} and __XXX__. With optional setting in plugin code, %{...} is available.

Available placeholders are:

  • hostname (${hostname}, %{hostname} or __HOSTNAME__)
    • you can specify hostname string explicitly on 'hostname' parameter
  • random uuid (${uuid}, ${uuid:random}, %{uuid}, %{uuid:random}, __UUID__ or __UUID_RANDOM__)
  • hostname string based uuid (${uuid:hostname}, %{uuid:hostname} or __UUID_HOSTNAME__)
  • timestamp based uuid (${uuid:timestamp} %{uuid:timestamp} or __UUID_TIMESTAMP__)

Usage

In plugin (both of input and output), just include mixin.

class FooInput < Fluent::Input
  Fluent::Plugin.register_input('foo', self)

  config_param :tag, :string
  
  include Fluent::Mixin::ConfigPlaceholders

  def configure(conf)
    super # MUST call 'super' at first!
    
    @tag #=> here, you can get string replaced '${hostname}' into actual hostname
  end
  
  # ...
end

You can use this feature for tags for each fluentd node, paths for remote storage services like /root/${hostname}/access_log or non-race-condition paths like /files/${uuid:random}.

Plugin setting

Plugin can determine which placeholders are enabled in their configurations, like this:

class FooInput < Fluent::Input
  # ....
  
  # instance method #placeholders should return array of symbols
  
  def placeholders
    [:dollar, :percent, :underscore]
  end
  
  # default is [:dollar, :underscore]
  
  include Fluent::Mixin::ConfigPlaceholders
  
  # ....
end

AUTHORS

LICENSE

  • Copyright: Copyright (c) 2012- tagomoris
  • License: Apache License, Version 2.0