Exec
The Exec input plugin lets you execute external programs and collects event logs.
This plugin invokes commands using a shell. Its inputs are subject to shell metacharacter substitution. Careless use of untrusted input in command arguments could lead to malicious command execution.
Container support
This plugin needs a functional /bin/sh
and won't function in all the distroless production images.
The debug images use the same binaries so even though they have a shell, there is no support for this plugin as it's compiled out.
Configuration parameters
The plugin supports the following configuration parameters:
Command
Parser
Specify the name of a parser to interpret the entry as a structured message.
Interval_Sec
Polling interval (seconds).
Interval_NSec
Polling interval (nanosecond).
Buf_Size
Oneshot
Only run once at startup. This allows collection of data precedent to Fluent Bit startup (Boolean, default: false
).
Exit_After_Oneshot
Exit as soon as the one-shot command exits. This allows the exec
plugin to be used as a wrapper for another command, sending the target command's output to any Fluent Bit sink, then exits. (Boolean, default: false
).
Propagate_Exit_Code
Threaded
Get started
You can run the plugin from the command line or through the configuration file:
Command line
The following example will read events from the output of ls.
which should return something like the following:
Configuration file
In your main configuration file append the following Input
and Output
sections:
Use as a command wrapper
To use Fluent Bit with the exec
plugin to wrap another command, use the Exit_After_Oneshot
and Propagate_Exit_Code
options:
Fluent Bit will output:
then exits with exit code 1.
Translation of command exit codes to Fluent Bit exit code follows the usual shell rules for exit code handling. Like with a shell, there is no way to differentiate between the command exiting on a signal and the shell exiting on a signal. Similarly, there is no way to differentiate between normal exits with codes greater than 125
and abnormal or signal exits reported by Fluent Bit or the shell. Wrapped commands should use exit codes between 0
and 125
inclusive to allow reliable identification of normal exit. If the command is a pipeline, the exit code will be the exit code of the last command in the pipeline unless overridden by shell options.
Parsing command output
By default the exec
plugin emits one message per command output line, with a single field exec
containing the full message. Use the Parser
directive to specify the name of a parser configuration to use to process the command input.
Security concerns
Take great care with shell quoting and escaping when wrapping commands**.
A script like
can ruin your day if someone passes it the argument$(rm -rf /my/important/files; echo "deleted your stuff!")'
The previous script would be safer if written with:
It's generally best to avoid dynamically generating the command or handling untrusted arguments.
Last updated
Was this helpful?