Standard input
The Standard input plugin supports retrieving a message stream from the standard input interface (stdin) of the Fluent Bit process. To use it, specify the plugin name as the input. For example:
fluent-bit -i stdin -o stdoutIf the stdin stream is closed (end-of-file), the plugin instructs Fluent Bit to exit with success (0) after flushing any pending output.
Configuration parameters
The plugin supports the following configuration parameters:
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 Fluent Bit Event format, which can be:
[TIMESTAMP, { "key": "value" }]where TIMESTAMP is a floating point value representing a timestamp in seconds.From Fluent Bit v2.1.0,
[[TIMESTAMP, METADATA], { "key": "value" }]whereTIMESTAMPhas the same meaning as previous andMETADATAis a JSON object.
Multi-line input JSON is supported.
Any input data which isn't in one of the supported 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 Fluent Bit event timestamp will be set from the input record if the two-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
To demonstrate how the plugin works, you can use a bash script that generates messages and writes them to Fluent Bit.
Write the following content in a file named
test.sh:Start the script and Fluent Bit:
The command should return output like the following:
JSON input with timestamp
An input event timestamp can also be supplied. Replace
test.shwith:Re-run the sample command. Timestamps output by Fluent Bit are now one day old because Fluent Bit used the input message timestamp.
Which returns the following:
JSON input with metadata
Additional metadata is supported in Fluent Bit v2.1.0 and later by replacing the timestamp with a two-element object. For example:
Run test using the command:
Which returns results like the following:
On older Fluent Bit versions records in this format will be discarded. If the log level permits, Fluent Bit will log:
Parser input
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 separate parsers file that captures the whole message line:
You can then use the parsers file in a stdin plugin in the main Fluent Bit configuration file as follows:
Fluent Bit will now read each line and emit a single message for each input line, using the following command:
Which returns output similar to:
In production deployments it's best to use a parser that splits messages into real fields and adds appropriate tags.
Last updated
Was this helpful?