Skip to main content
Version: Next

Action: 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

Field Summary

Field NameTypeDescriptionDefault
conditionexpressionOnly run this action if the condition the specified condition is met-
input-fieldfieldPass the data in this field through the command-
commandstringA shell command to be executed-
resultExecResultOffers a way to collect the full output of a command: stdout, stdin, and exit status-
warningboolConvert errors into warningsfalse

Fields

condition

Type: expression

Only run this action if the condition the specified condition is met

input-field

Type: 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.

Example: pass value of _raw through the tr command and store in out

Input:

{"_raw":"hello dolly"}

Pipe Language Snippet:

exec:
command: tr 'h' 'H'
input-field: _raw
result:
stdout-field: out

Output:

{"_raw":"hello dolly","out":"Hello dolly"}

command

Type: string

A shell command to be executed

Without 'result' all output will be discarded; the command is just run for its side effects

Example: append value of msg to a log file

Input:

{"msg":"hello dolly"}

Pipe Language Snippet:

exec:
command: cat ${msg} >> log.txt

result

Type: ExecResult

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

Field NameTypeDescriptionDefault
status-fieldfieldField where exit status of command will be stored-
stderr-fieldfieldField where stderr of command will be stored-
stdout-fieldfieldField where stdout of command will be stored_raw

  status-field

Type: field

Field where exit status of command will be stored

Example

Pipe Language Snippet:

exec:
command: echo foo
result:
status-field: status

Output:

{"_raw":"foo\n","status":0}

  stderr-field

Type: field

Field where stderr of command will be stored

Example

Input:

{"one":1,"two":2}

Pipe Language Snippet:

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

Type: field

Default: _raw

Field where stdout of command will be stored

The output will be discarded if this field is not specified

Example

Pipe Language Snippet:

exec:
command: echo foo
result:
stdout-field: stdout
interval: 1m

Output:

{"stdout":"foo\n"}

warning

Type: bool

Default: false

Convert errors into warnings