default: Specifies the default value for a parameter. If omitted, the
parameter is required. On startup, Fluentd uses the default value instead if
the parameter is not configured.
NOTE: It doesn't perform type conversion such as time type, and the specified default value is used as is.
# Required parameter: The configuration must have this parameter like 'param1 10'.config_param :param1,:integer# Optional parameter: If the configuration doesn't have 'param2', 100 is used.config_param :param2,:integer,default:100
secret: If true, the parameter will be masked when Fluentd dumps its
configuration on the standard output on startup.
config_param :secret_param,:string,secret:true
deprecated: Specifies the deprecation warning message. If users use this
parameter in the configuration, they will see the deprecation warning on
startup.
obsoleted: Specifies the obsolete error message. If users use this parameter
in the configuration, Fluentd raises Fluent::ConfigError and stops.
alias: Alias for this parameter as a symbol.
skip_accessor: If true, skip adding accessor to the plugin. For internal
use only!
Data Types
:string
Defines a string parameter.
Code Example:
Configuration Example:
:regexp
Defines a regexp parameter. Since v1.2.0.
Code Example:
Configuration Example:
:integer
Defines an integer parameter.
Code Example:
Configuration Example:
:float
Defines a float parameter.
Code Example:
Configuration Example:
:size
Defines a size parameter in bytes.
Available suffixes: { k, m, g, t } (ignore case)
Code Example:
Configuration Example:
Configuration Example:
:time
Defines the length of the time parameter.
Available suffixes: { s, m, h, d } (lower case only).
If omitted, to_f is applied to the value which converts it to seconds.
Code Example:
Configuration Example:
Configuration Example:
:bool
Defines a Boolean parameter.
Code Example:
Configuration Example:
:enum
Defines an enumerated parameter.
Users can choose a value from the list. If a non-listed value is chosen, an error occurs on startup.
Available options
list: List of available values.
Code Example:
Configuration Example:
:array
Defines an array parameter.
Users can set an array value for a parameter.
Available options
value_type: Defines the type of the value.
Available types: { :string, :integer, :float, :size, :bool, :time }
config_param :pattern, :regexp, default: /^key_/
def configure(conf)
super
log.info(pattern: @pattern)
end
def filter(tag, time, record)
new_record = record.select do |k, v|
@pattern.match(k)
end
new_record
end
pattern /^name_/
pattern ^name_ # Also support pattern without slashes
config_param :num_children, :integer, default: 1
def start
super
# ...
@num_children.times do |n|
# do something...
end
end
num_children 10
helpers :timer
config_param :interval, :float, default: 0.5
def start
super
# ...
timer_execute(:in_example, @interval) do
# do something periodically
end
end
interval 1.5
config_param :limit, :size
def do_something
raise "overflow!" if @limit < current
# ...
end