Fluentd
Search…
Plugin Helper: Event Emitter
The event_emitter plugin helper introduces the router method to the plugin.
Here is an example:
1
require 'fluent/plugin/output'
2
3
module Fluent::Plugin
4
class RelabelOutput < Output
5
Fluent::Plugin.register_output('relabel', self)
6
helpers :event_emitter
7
8
def multi_workers_ready?
9
true
10
end
11
12
def process(tag, es)
13
router.emit_stream(tag, es)
14
end
15
end
16
end
Copied!

Methods

router

This method returns a Fluent::EventRouter instance.
Code example:
1
# emit event
2
router.emit(tag, time, record)
3
4
# emit event stream
5
router.emit_stream(tag, es)
6
7
# emit error event
8
begin
9
# do something
10
rescue => error
11
# Route event to @ERROR label or
12
# log error message when @ERROR label is not defined in configuration
13
router.emit_error_event(tag, time, record, error)
14
end
Copied!

Plugins using event_emitter

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 modified 4mo ago