Record Accessor
A full feature set to access content of your records.
Fluent Bit works internally with structured records and it can be composed of an unlimited number of keys and values. Values can be anything like a number, string, array, or a map.
Having a way to select a specific part of the record is critical for certain core functionalities or plugins, this feature is called Record Accessor.
Consider record accessor to be a basic grammar to specify record content and other miscellaneous values.
Format
A record accessor rule starts with the character $
. Use the structured content as an example. The following table describes how to access a record:
The following table describes some accessing rules and the expected returned value:
$log
some message
$labels['color']
blue
$labels['project']['env']
production
$labels['unset']
null
$labels['undefined']
If the accessor key doesn't exist in the record like the last example $labels['undefined']
, the operation is omitted, and no exception will occur.
Usage
The file content to process in test.log
is the following:
When running Fluent Bit with the previous configuration, the output is:
Limitations of record_accessor
templating
record_accessor
templatingThe Fluent Bit record_accessor
library has a limitation in the characters that can separate template variables. Only dots and commas (.
and ,
) can come after a template variable. This is because the templating library must parse the template and determine the end of a variable.
The following templates are invalid because the template variables aren't separated by commas or dots:
$TaskID-$ECSContainerName
$TaskID/$ECSContainerName
$TaskID_$ECSContainerName
$TaskIDfooo$ECSContainerName
However, the following are valid:
$TaskID.$ECSContainerName
$TaskID.ecs_resource.$ECSContainerName
$TaskID.fooo.$ECSContainerName
And the following are valid since they only contain one template variable with nothing after it:
fooo$TaskID
fooo____$TaskID
fooo/bar$TaskID
Last updated
Was this helpful?