Skip to main content
Version: Next

Action Inputs

Inputs can be run as actions under certain conditions. The first thing to note is that when run as actions, they may refer to the input data using Field Expansion.

For example, two numbers are passed to a HTTP server listening on port 3030. Their sum is returned by the service as {"sum":<num>}. We can poll the service with our data as follows:

name: adder

input:
text: '{"x":10,"y":20}'

actions:
- input:
http-poll:
address: http://127.0.0.1:3030
raw: true
query:
- a: ${x}
- b: ${y}

output:
write: console

# Output: {"x":10,"y":20,"sum":30}

http-poll takes an event, Field Expansion happens, and finally, merges the result of input with the event. raw: true is required since the service returns JSON.

If a simple number was returned, raw: false is required to quote the result in order to get {"x":10,"y":20,"_raw":"30"}.

note

address: 'http://127.0.0.1:3030?a=${x}&b=${y}' can be used but query makes it easier to construct a more complex URI.

These inputs may not be scheduled since they run when data arrives — they are implicitly scheduled by the event stream.

For example, interval: 2m on http-poll is an error.

danger

An input that cannot be scheduled, therefore cannot be used. Such an input is activated by ingress data, inputs such as tcp, udp and http-server, or by subscribing to data streams with amqp or redis.

Although you could use input exec as an action, rather use exec as it is easier.