Fluentd
Search…
Plugin Helper: Inject
The inject plugin helper injects values into events according to the configuration.
Here is an example:
1
require 'fluent/plugin/filter'
2
3
module Fluent::Plugin
4
class ExampleFilter < Filter
5
Fluent::Plugin.register_filter('example', self)
6
7
# 1. Load inject helper
8
helpers :inject
9
10
# Omit `configure`, `shutdown` and other plugin APIs
11
12
def filter(tag, time, record)
13
# 2. Inject values into `record`
14
new_record = inject_values_to_record(tag, time, record)
15
# edit new_record ...
16
new_record
17
end
18
end
19
end
Copied!
For more details, see Inject section.

Methods

inject_values_to_record(tag, time, record)

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:
1
def filter(tag, time, record)
2
new_record = inject_values_to_record(tag, time, record)
3
# edit new_record ...
4
new_record
5
end
Copied!

inject_values_to_event_stream(tag, es)

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:
1
def process(tag, es)
2
new_es = inject_values_to_event_stream(tag, es)
3
# do something using new_es
4
end
Copied!

Plugins using inject

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