exec
Execute arbitrary commands
One thing to take note of:
- Any linefeeds will be removed from the command, so this works fine:
exec:
command: |
docker ps
-all
--no-trunc
--quiet
--size
Note: This invokes the system shell
Field Name | Description | Type | Default |
---|---|---|---|
condition | Only run this action if the condition the specified condition is met | expression | - |
input-field | Pass the data in this field through the command | field | - |
command | A shell command to be executed | string | - |
result | Offers a way to collect the full output of a command: stdout, stdin, and exit status | ExecResult | - |
warning | Convert errors into warnings | bool | false |
condition
Only run this action if the condition the specified condition is met
Type: expression
input-field
Pass the data in this field through the command
Otherwise all of the input is passed. This also happens if the field exists but is not text.
Type: field
Example: pass value of _raw
through the tr
command and store in out
input:
{"_raw":"hello dolly"}
action:
exec:
command: tr 'h' 'H'
input-field: _raw
result:
stdout-field: out
output:
{"_raw":"hello dolly","out":"Hello dolly"}
command
A shell command to be executed
Without 'result' all output will be discarded; the command is just run for its side effects
Type: string
Example: append value of msg
to a log file
input:
{"msg":"hello dolly"}
action:
exec:
command: cat ${msg} >> log.txt
result
Offers a way to collect the full output of a command: stdout, stdin, and exit status
These generated fields are merged with the existing fields
Type: ExecResult
Field Name | Description | Type | Default |
---|---|---|---|
status-field | Field where exit status of command will be stored | field | - |
stderr-field | Field where stderr of command will be stored | field | - |
stdout-field | Field where stdout of command will be stored | field | _raw |
status-field
Field where exit status of command will be stored
Type: field
Example
action:
exec:
command: echo foo
result:
status-field: status
output:
{"_raw":"foo\n","status":0}
stderr-field
Field where stderr of command will be stored
Type: field
Example
input:
{"one":1,"two":2}
action:
exec:
command: "echo \"this will return with an error\" 1>&2 && false"
result:
stderr-field: stderr
output:
{"one":1,"two":2,"stderr":"this will return with an error"}
stdout-field
Field where stdout of command will be stored
The output will be discarded if this field is not specified
Type: field
Example
action:
exec:
command: echo foo
result:
stdout-field: stdout
interval: 1m
output:
{"stdout":"foo\n"}
warning
Convert errors into warnings
Type: bool