mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-08 03:49:38 +00:00
43 lines
1.4 KiB
Plaintext
43 lines
1.4 KiB
Plaintext
[[input-chain]]
|
|
==== Chain Input
|
|
|
|
An <<input, input>> that enables you to string together multiple inputs to load data into the watch execution
|
|
context. Each input loads data into the execution context and that data is available to subsequent inputs in the chain.
|
|
|
|
The `chain` input is useful when you want to perform an action based on data from multiple sources.
|
|
You can also use the data collected by one input to load data from another source.
|
|
|
|
To reference data loaded by a particular input, you use the input's name, `ctx.payload.<input-name>.<value>`.
|
|
|
|
For example, the following chain input loads data from an HTTP server using the path set by a `simple` input.
|
|
|
|
[source,json]
|
|
--------------------------------------------------
|
|
{
|
|
"input" : {
|
|
"chain" : {
|
|
"inputs" : [ <1>
|
|
{
|
|
"first" : {
|
|
"simple" : { "path" : "/_search" }
|
|
}
|
|
},
|
|
{
|
|
"second" : {
|
|
"http" : {
|
|
"request" : {
|
|
"host" : "localhost",
|
|
"port" : 9200,
|
|
"path" : "{{ctx.payload.first.path}}" <2>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
...
|
|
}
|
|
--------------------------------------------------
|
|
<1> The inputs in a chain are specified as an array to guarantee the order in which the inputs are processed. (JSON does not guarantee the order of arbitrary objects.)
|
|
<2> Loads the `path` set by the `first` input. |