From fb4ba6f89d6a0fb455680f3af012253d85a1b7c1 Mon Sep 17 00:00:00 2001 From: debadair Date: Fri, 6 Nov 2015 15:04:41 -0800 Subject: [PATCH] Watcher Docs: Edited chain input topic & added chain to customizing watches. Original commit: elastic/x-pack-elasticsearch@9e1d7f09c6249e091c71145075d5dd449e6251af --- watcher/docs/customizing-watches.asciidoc | 11 ++++++++-- watcher/docs/reference/input/chain.asciidoc | 24 ++++++++++----------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/watcher/docs/customizing-watches.asciidoc b/watcher/docs/customizing-watches.asciidoc index d343e444e23..4bd7f408049 100644 --- a/watcher/docs/customizing-watches.asciidoc +++ b/watcher/docs/customizing-watches.asciidoc @@ -9,8 +9,8 @@ you can customize a watch by modifying its <>, [[changing-inputs]] === Changing Inputs -Watcher supports three types of inputs <>, -<>, and <>. +Watcher supports four types of inputs <>, +<>, <>, and <>. [[loading-static-data]] ==== Loading Static Data with the Simple Input @@ -115,6 +115,13 @@ during the month of May, 2015 that were tagged with `elasticsearch`. included as part of the path. //////////// +[[chaining-inputs]] +==== Chaining Inputs + +You can create an <> to load data from multiple sources into a watch. +The inputs in a chain are processed in order, so the the data loaded by one input can be used +by subsequent inputs. + [[changing-conditions]] === Changing Conditions diff --git a/watcher/docs/reference/input/chain.asciidoc b/watcher/docs/reference/input/chain.asciidoc index f68035a4252..8340154d8c5 100644 --- a/watcher/docs/reference/input/chain.asciidoc +++ b/watcher/docs/reference/input/chain.asciidoc @@ -1,18 +1,22 @@ [[input-chain]] ==== Chain Input -An <> 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.. +An <> 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. -You can define the chained input as following +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..`. + +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" : [ + "inputs" : [ <1> "first" : { "simple" : { "path" : "/_search" } }, @@ -21,7 +25,7 @@ You can define the chained input as following "request" : { "host" : "localhost", "port" : 9200, - "path" : "{{ctx.payload.first.path}}" + "path" : "{{ctx.payload.first.path}}" <2> } } } @@ -31,9 +35,5 @@ You can define the chained input as following ... } -------------------------------------------------- - -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. - +<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. \ No newline at end of file