Plugin Helper: Event Emitter

event_emitter helper introduces router method to the plugin.

Here is the code example with event_emitter helper:

require 'fluent/plugin/output'
module Fluent::Plugin
class RelabelOutput < Output
Fluent::Plugin.register_output('relabel', self)
helpers :event_emitter
def multi_workers_ready?
true
end
def process(tag, es)
router.emit_stream(tag, es)
end
end
end

Methods

router

This method returns Fluent::EventRouter instance

Code example:

# emit event
router.emit(tag, time, record)
# emit event stream
router.emit_stream(tag, es)
# emit error event
begin
# do something
rescue => error
# Route event to @ERROR label or
# log error message when @ERROR label is not defined in configuration
router.emit_error_event(tag, time, record, error)
end

event_emitter used plugins

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