How to Write Base Plugin
All plugin types are subclasses of
Fluent::Plugin::Base
in Fluentd v1 or later. The Base
class has some features and methods that provide the basic mechanism as plugins. This page shows these methods provided by Fluent::Plugin::Base
, and other methods provided commonly in some type of plugins.The methods listed below are considered as public methods, and will be maintained not to break compatibility. Other methods may be changed without compatibility consideration.
require 'fluent/plugin/input' # This may be input, filter, output, parser, formatter, storage or buffer.
module Fluent::Plugin
class MyExampleInput < Input
# Plugins should be registered by calling `Fluent::Plugin.register_TYPE` method with name and `self`.
# The first argument String is to identify the plugin in the configuration file.
# The second argument is class of the plugin itself, `self` in most cases.
Fluent::Plugin.register_input('my_example', self)
desc 'The port number'
# `config_param` Defines a parameter. You can refer the following parameter via @port instance variable.
# Without `:default`, a parameter is required.
config_param :port, :integer