Plugin Helper: Compat Parameters

compat_parameters helper convert parameters from v0.12 to v1.0 style.

Here is an example:

require 'fluent/plugin/output'

module Fluent::Plugin
  class ExampleOutput < Output
    Fluent::Plugin.register_output('example', self)

    # 1. Load `compat_parameters` helper
    helpers :compat_parameters

    # Omit `start`, `shutdown` and other plugin APIs

    def configure(conf)
      compat_parameters_convert(conf, :buffer, :inject, default_chunk_key: 'time')
      super

      # ...
    end
  end
end

Methods

compat_parameters_convert(conf, *types, **kwargs)

  • conf: Fluent::Configuration instance

  • types: Following types are supported:

    • :buffer

    • :inject

    • :extract

    • :parser

    • :formatter

  • kwargs:

IMPORTANT: You cannot mix v1.0 and v0.12 styles in one plugin directive. If you mix v1.0 and v0.12 styles, v1.0 style is used and v0.12 style is ignored.

Here is an example:

<match pattern>
  @type foo
  # This flush_interval is ignored because <buffer> exist. No conversion.
  flush_interval 30s
  # This <buffer> parameters are used
  <buffer>
    @type file
    path /path/to/buffer
    retry_max_times 10
    queue_limit_length 256
  </buffer>
</match>

buffer

This flat configuration:

buffer_type file
buffer_path /path/to/buffer
retry_limit 10
flush_interval 30s
buffer_queue_limit 256

converts to:

<buffer>
  @type file
  path /path/to/buffer
  retry_max_times 10
  flush_interval 30s
  queue_limit_length 256
</buffer>

For more details, see Buffer Section Configuration.

inject

This flat configuration:

include_time_key
time_key event_time
utc

converts to:

<inject>
  time_key event_time
  localtime false
</inject>

For more details, see Inject Plugin Helper API.

extract

This flat configuration:

include_time_key
time_key event_time
utc

converts to:

<extract>
  time_key event_time
  localtime false
</extract>

For more details, see Extract Plugin Helper API

parser

This flat configuration:

format /^(?<log_time>[^ ]*) (?<message>)+*/
time_key log_time
time_format %Y%m%d%H%M%S
keep_time_key

converts into:

<parse>
  @type regexp
  pattern /^(?<log_time>[^ ]*) (?<message>)+*/
  time_key log_time
  time_format %Y%m%d%H%M%S
  keep_time_key
</parse>

For more details, see Parser Plugin Overview and Writing Parser Plugins.

formatter

This flat configuration:

format json

converts to:

<format>
  @type json
</format>

For more details, see Formatter Plugin Overview and Writing Formatter Plugins.

Plugins using compat_parameters

If this article is incorrect or outdated, or omits critical information, please let us know. Fluentd is an open-source project under Cloud Native Computing Foundation (CNCF). All components are available under the Apache 2 License.

Last updated