Plugin Helper: Inject

inject helper injects values to events according to the configuration.

For details about configuration, see Inject section.

Here is the code example with inject helper:

require 'fluent/plugin/filter'
module Fluent::Plugin
class ExampleFilter < Filter
Fluent::Plugin.register_filter('example', self)
# 1. load inject helper
helpers :inject
# omit configure, shutdown and other plugin API
def filter(tag, time, record)
# 2. inject values to record
new_record = inject_values_to_record(tag, time, record)
# edit new_record ...
new_record
end
end
end

For more details about configuration, see Inject section.

Methods

inject_values_to_recort(tag, time, record)

This method injects values to given record and returns new record

  • tag: the tag of the event

  • time: event timestamp

  • record: event record

Code example:

def filter(tag, time, record)
new_record = inject_values_to_record(tag, time, record)
# edit new_record ...
new_record
end

inject_values_to_event_stream(tag, es)

This method injects values to given event stream and returns new event stream

  • tag: the tag of the event

  • es: event stream

Code example:

def process(tag, es)
new_es = inject_values_to_event_stream(tag, es)
# do something using new_es
end

inject 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.