Standard Input
The stdin plugin supports retrieving a message stream from the standard input interface (stdin) of the Calyptia Fluent Bit process. In order to use it, specify the plugin name as the input, e.g:
If the stdin stream is closed (end-of-file), the stdin plugin will instruct Calyptia Fluent Bit to exit with success (0) after flushing any pending output.
Input formats
If no parser is configured for the stdin plugin, it expects valid JSON input data in one of the following formats:
A JSON object with one or more key-value pairs:
{ "key": "value", "key2": "value2" }
A 2-element JSON array in Calyptia Fluent Bit Event format, which may be:
[TIMESTAMP, { "key": "value" }]
where TIMESTAMP is a floating point value representing a timestamp in seconds; orfrom Calyptia Fluent Bit v22.10.1,
[[TIMESTAMP, METADATA], { "key": "value" }]
where TIMESTAMP has the same meaning as above and and METADATA is a JSON object.
Multi-line input JSON is supported.
Any input data that is not in one of the above formats will cause the plugin to log errors like:
To handle inputs in other formats, a parser must be explicitly specified in the configuration for the stdin
plugin. See parser input example for sample configuration.
Log event timestamps
The Calyptia Fluent Bit event timestamp will be set from the input record if the 2-element event input is used or a custom parser configuration supplies a timestamp. Otherwise the event timestamp will be set to the timestamp at which the record is read by the stdin plugin.
Examples
Json input example
A better example to demonstrate how it works will be through a Bash script that generates messages and writes them to Calyptia Fluent Bit. Write the following content in a file named test.sh:
Now lets start the script and Calyptia Fluent Bit:
Json input with timestamp example
An input event timestamp may also be supplied. Replace test.sh
with:
Re-run the sample command. Note that the timestamps output by Calyptia Fluent Bit are now one day old because Calyptia Fluent Bit used the input message timestamp.
Json input with metadata example
Additional metadata is also supported on Calyptia Fluent Bit v23.4.0 and above by replacing the timestamp with a 2-element object, e.g.:
On older Calyptia Fluent Bit versions, records in this format will be discarded. Calyptia Fluent Bit will log:
if the log level permits.
Parser input example
To capture inputs in other formats, specify a parser configuration for the stdin
plugin.
For example, if you want to read raw messages line-by-line and forward them you could use a parser.conf
that captures the whole message line:
then use that in the parser
clause of the stdin plugin in the calyptia-fluent-bit.conf
:
Calyptia Fluent Bit will now read each line and emit a single message for each input line:
In real-world deployments it is best to use a more realistic parser that splits messages into real fields and adds appropriate tags.
Configuration Parameters
The plugin supports the following configuration parameters:
Last updated