Tap can be used to generate events or records detailing what messages pass through Fluent Bit, at what time and what filters affect them.
First, we will make sure that the container image we are going to use actually supports Fluent Bit Tap (available in Fluent Bit 2.0+):
If the --enable-chunk-trace
option is present it means Fluent Bit has support for Fluent Bit Tap but it is disabled by default, so remember to enable it with this option.
You can start fluent-bit with tracing activated from the beginning by using the trace-input
and trace-output
properties, like so:
If you see the following warning then the -Z
or --enable-chunk-tracing
option is missing:
Properties can be set for the output using the --trace-output-property
option:
With that options set the stdout plugin is now emitting traces in json_lines
format:
All three options can also be defined using the much more flexible --trace
option:
We defined the entire tap pipeline using this configuration: input=dummy.0 output=stdout output.format=json_lines
which defines the following:
input: dummy.0 (listens to the tag and/or alias dummy.0
)
output: stdout (outputs to a stdout plugin)
output.format: json_lines (sets the stdout format o json_lines
)
Tap support can also be activated and deactivated via the embedded web server:
In another terminal we can activate Tap by either using the instance id of the input; dummy.0
or its alias.
Since the alias is more predictable that is what we will use:
This response means we have activated Tap, the terminal with Fluent Bit running should now look like this:
All the records that now appear are those emitted by the activities of the dummy plugin.
This example takes the same steps but demonstrates the same mechanism works with more complicated configurations. In this example we will follow a single input of many which passes through several filters.
To make sure the window is not cluttered by the actual records generated by the input plugins we send all of it to null
.
We activate with the following 'curl' command:
Now we should start seeing output similar to the following:
When activating Tap, any plugin parameter can be given. These can be used to modify, for example, the output format, the name of the time key, the format of the date, etc.
In the next example we will use the parameter "format": "json"
to demonstrate how in Tap, stdout can be shown in Json format.
First, run Fluent Bit enabling Tap:
Next, in another terminal, we activate Tap including the output, in this case stdout, and the parameters wanted, in this case "format": "json"
:
In the first terminal, we should be seeing the output similar to the following:
This parameter shows stdout in Json format, however, as mentioned before, parameters can be passed to any plugin.
Please visit the following link for more information on other output plugins: https://docs.fluentbit.io/manual/pipeline/outputs
Here we analyze a single record from a filter event to explain the meaning of each field in detail. We chose a filter record since it includes the most details of all the record types.
The type defines at what stage the event is generated:
type=1: input record
this is the unadulterated input record
type=2: filtered record
this is a record once it has been filtered. One record is generated per filter.
type=3: pre-output record
this is the record right before it is sent for output.
Since this is a record generated by the manipulation of a record by a filter is has the type 2
.
This records the start and end of an event, it is a bit different for each event type:
type 1: when the input is received, both the start and end time.
type 2: the time when filtering is matched until it has finished processing.
type 3: the time when the input is received and when it is finally slated for output.
This is a string composed of a prefix and a number which is incremented with each record received by the input during the Tap session.
This is the plugin instance name as it is generated by Fluent Bit at runtime.
If an alias is set this field will contain the alias set for a plugin.
This is an array of all the records being sent. Since Fluent Bit handles records in chunks of multiple records and chunks are indivisible the same is done in the Tap output. Each record consists of its timestamp followed by the actual data which is a composite type of keys and values.
Fluent Bit v1.4 introduces the Dump Internals feature that can be triggered easily from the command line triggering the CONT
Unix signal.
Run the following kill
command to signal Fluent Bit:
The command
pidof
aims to lookup the Process ID of Fluent Bit. You can replace the
Fluent Bit will dump the following information to the standard output interface (stdout):
The dump provides insights for every input instance configured.
Overall ingestion status of the plugin.
When an input plugin ingest data into the engine, a Chunk is created. A Chunk can contains multiple records. Upon flush time, the engine creates a Task that contains the routes for the Chunk associated in question.
The Task dump describes the tasks associated to the input plugin:
The Chunks dump tells more details about all the chunks that the input plugin has generated and are still being processed.
Depending of the buffering strategy and limits imposed by configuration, some Chunks might be up
(in memory) or down
(filesystem).
Fluent Bit relies on a custom storage layer interface designed for hybrid buffering. The Storage Layer
entry contains a total summary of Chunks registered by Fluent Bit: