The inject
plugin helper injects values into events according to the configuration.
Here is an example:
require 'fluent/plugin/filter'​module Fluent::Pluginclass ExampleFilter < FilterFluent::Plugin.register_filter('example', self)​# 1. Load inject helperhelpers :inject​# Omit `configure`, `shutdown` and other plugin APIs​def filter(tag, time, record)# 2. Inject values into `record`new_record = inject_values_to_record(tag, time, record)# edit new_record ...new_recordendendend
For more details, see Inject section.
This method injects values to the given record and returns the new record.
tag
: the tag of the event
time
: event timestamp
record
: event record
Example:
def filter(tag, time, record)new_record = inject_values_to_record(tag, time, record)# edit new_record ...new_recordend
This method injects values into the given event stream and returns the new event stream.
tag
: the tag of the event
es
: event stream
Example:
def process(tag, es)new_es = inject_values_to_event_stream(tag, es)# do something using new_esend
​filter_stdout
​
​out_exec
​
​out_exec_filter
​
​out_file
​
​out_stdout
​
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.