Skip to content

Commit 618c280

Browse files
authored
Fixing input plugin exec docs to standardize layout. Fixes #1789. (#1799)
Signed-off-by: Eric D. Schabell <[email protected]>
1 parent cdeb5f6 commit 618c280

File tree

1 file changed

+39
-44
lines changed

1 file changed

+39
-44
lines changed

pipeline/inputs/exec.md

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ The _Exec_ input plugin lets you execute external programs and collects event lo
66

77
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.
88

9-
{% end hint %}
9+
{% endhint %}
1010

1111
## Container support
1212

13-
This plugin needs a functional `/bin/sh` and won't function in all the distroless production images.
13+
This plugin needs a functional `/bin/sh` and won't function in all the distro-less production images.
1414

1515
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.
1616

@@ -38,8 +38,8 @@ You can run the plugin from the command line or through the configuration file:
3838

3939
The following example will read events from the output of _ls_.
4040

41-
```bash
42-
fluent-bit -i exec -p 'command=ls /var/log' -o stdout
41+
```shell
42+
$ fluent-bit -i exec -p 'command=ls /var/log' -o stdout
4343
```
4444

4545
which should return something like the following:
@@ -63,28 +63,9 @@ Fluent Bit v1.x.x
6363

6464
### Configuration file
6565

66-
In your main configuration file append the following `Input` and `Output` sections:
66+
In your main configuration file append the following:
6767

6868
{% tabs %}
69-
{% tab title="fluent-bit.conf" %}
70-
71-
```python
72-
[INPUT]
73-
Name exec
74-
Tag exec_ls
75-
Command ls /var/log
76-
Interval_Sec 1
77-
Interval_NSec 0
78-
Buf_Size 8mb
79-
Oneshot false
80-
81-
[OUTPUT]
82-
Name stdout
83-
Match *
84-
```
85-
86-
{% endtab %}
87-
8869
{% tab title="fluent-bit.yaml" %}
8970

9071
```yaml
@@ -104,31 +85,31 @@ pipeline:
10485
```
10586
10687
{% endtab %}
107-
{% endtabs %}
108-
109-
## Use as a command wrapper
110-
111-
To use Fluent Bit with the `exec` plugin to wrap another command, use the `Exit_After_Oneshot` and `Propagate_Exit_Code` options:
112-
113-
{% tabs %}
11488
{% tab title="fluent-bit.conf" %}
11589
116-
```python
90+
```text
11791
[INPUT]
118-
Name exec
119-
Tag exec_oneshot_demo
120-
Command for s in $(seq 1 10); do echo "count: $s"; sleep 1; done; exit 1
121-
Oneshot true
122-
Exit_After_Oneshot true
123-
Propagate_Exit_Code true
92+
Name exec
93+
Tag exec_ls
94+
Command ls /var/log
95+
Interval_Sec 1
96+
Interval_NSec 0
97+
Buf_Size 8mb
98+
Oneshot false
12499

125100
[OUTPUT]
126101
Name stdout
127102
Match *
128103
```
129104

130105
{% endtab %}
106+
{% endtabs %}
107+
108+
## Use as a command wrapper
109+
110+
To use Fluent Bit with the `exec` plugin to wrap another command, use the `Exit_After_Oneshot` and `Propagate_Exit_Code` options:
131111

112+
{% tabs %}
132113
{% tab title="fluent-bit.yaml" %}
133114

134115
```yaml
@@ -146,6 +127,23 @@ pipeline:
146127
match: '*'
147128
```
148129
130+
{% endtab %}
131+
{% tab title="fluent-bit.conf" %}
132+
133+
```text
134+
[INPUT]
135+
Name exec
136+
Tag exec_oneshot_demo
137+
Command for s in $(seq 1 10); do echo "count: $s"; sleep 1; done; exit 1
138+
Oneshot true
139+
Exit_After_Oneshot true
140+
Propagate_Exit_Code true
141+
142+
[OUTPUT]
143+
Name stdout
144+
Match *
145+
```
146+
149147
{% endtab %}
150148
{% endtabs %}
151149

@@ -176,11 +174,11 @@ By default the `exec` plugin emits one message per command output line, with a s
176174

177175
{% hint style="warning" %}
178176

179-
Take great care with shell quoting and escaping when wrapping commands**.
177+
Take great care with shell quoting and escaping when wrapping commands.
180178

181179
{% endhint %}
182180

183-
A script like
181+
A script like the following can ruin your day if someone passes it the argument `$(rm -rf /my/important/files; echo "deleted your stuff!")'`
184182

185183
```bash
186184
#!/bin/bash
@@ -193,13 +191,10 @@ exec fluent-bit \
193191
-p command='myscript $*'
194192
```
195193

196-
can ruin your day if someone passes it the argument
197-
`$(rm -rf /my/important/files; echo "deleted your stuff!")'`
198-
199194
The previous script would be safer if written with:
200195

201196
```bash
202197
-p command='echo '"$(printf '%q' "$@")" \
203198
```
204199

205-
It's generally best to avoid dynamically generating the command or handling untrusted arguments.
200+
It's generally best to avoid dynamically generating the command or handling untrusted arguments.

0 commit comments

Comments
 (0)