Alexander Reelsen 04a8fb3202 Watcher: Add chained input
```
Chained input for now works like this
{
"chain" : [
  { "first" : { "simple" : { "foo" : "bar" } } },
  { "second" : { "simple" : { "spam" : "eggs" } } }
]
```

This allows to access the payload via ctx.payload.first.foo for example

The array notation is needed to guarantee order, as JSON itself does not guarantee
order of objects.

Closes elastic/elasticsearch#353

Original commit: elastic/x-pack-elasticsearch@7ab32c43a8
2015-10-30 10:22:26 +01:00

40 lines
1.2 KiB
Plaintext

[[input-chain]]
==== Chain Input
An <<input, input>> that enables you to chain several inputs one after the other and have each input populating the execution context.
The `chain` input is useful when the output of one input should change the input of another or you need several inputs to gather all the
information needed for an action..
You can define the chained input as following
[source,json]
--------------------------------------------------
{
"input" : {
"chain" : {
"inputs" : [
"first" : {
"simple" : { "path" : "/_search" }
},
"second" : {
"http" : {
"request" : {
"host" : "localhost",
"port" : 9200,
"path" : "{{ctx.payload.first.path}}"
}
}
}
]
}
}
...
}
--------------------------------------------------
As you can see, the name of the input (`first` and `second` in this example) can be used to access values from the context in consecutive inputs.
In case you are wondering about the structure of this input. The `inputs` must be an array, because JSON does not guarantee the order of arbitrary
objects, one has to use a list.