You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document new options Exit_After_Oneshot and Propagate_Exit_Code for the
related core fluent-bit PR.
Add a security warning about shell metacharacter processing in commands.
Add an example about how to use the exec plugin as a command wrapper
in one-shot mode.
Signed-off-by: Craig Ringer <craig.ringer@enterprisedb.com>
Copy file name to clipboardExpand all lines: pipeline/inputs/exec.md
+87-1Lines changed: 87 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,10 @@
2
2
3
3
The **exec** input plugin, allows to execute external program and collects event logs.
4
4
5
+
**WARNING**: Because this plugin invokes commands via a shell, its inputs are
6
+
subject to shell metacharacter substitution. Careless use of untrusted input in
7
+
command arguments could lead to malicious command execution.
8
+
5
9
## Container support
6
10
7
11
This plugin will not function in the distroless production images (AMD64 currently) as it needs a functional `/bin/sh` which is not present.
@@ -13,12 +17,14 @@ The plugin supports the following configuration parameters:
13
17
14
18
| Key | Description |
15
19
| :--- | :--- |
16
-
| Command | The command to execute. |
20
+
| Command | The command to execute, passed to [popen(...)](https://man7.org/linux/man-pages/man3/popen.3.html) without any additional escaping or processing. May include pipelines, redirection, command-substitution, etc. |
17
21
| Parser | Specify the name of a parser to interpret the entry as a structured message. |
| Buf\_Size | Size of the buffer \(check [unit sizes](https://docs.fluentbit.io/manual/configuration/unit_sizes) for allowed values\)|
21
25
| Oneshot | Only run once at startup. This allows collection of data precedent to fluent-bit's startup (bool, default: false) |
26
+
| 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(s) then exiting. (bool, default: false) |
27
+
| Propagate\_Exit\_Code | When exiting due to Exit\_After\_Oneshot, cause fluent-bit to exit with the exit code of the command exited by this plugin. Follows [shell conventions for exit code propagation](https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html). (bool, default: false) |
22
28
23
29
## Getting Started
24
30
@@ -64,3 +70,83 @@ In your main configuration file append the following _Input_ & _Output_ sections
64
70
Name stdout
65
71
Match *
66
72
```
73
+
74
+
## Use as a command wrapper
75
+
76
+
To use `fluent-bit` with the `exec` plugin to wrap another command, use the
77
+
`Exit_After_Oneshot` and `Propagate_Exit_Code` options, e.g.:
78
+
79
+
```
80
+
[INPUT]
81
+
Name exec
82
+
Tag exec_oneshot_demo
83
+
Command for s in $(seq 1 10); do echo "count: $s"; sleep 1; done; exit 1
0 commit comments