# Chain input - get results filtered by first input

**URL:** <https://discuss.elastic.co/t/chain-input-get-results-filtered-by-first-input/73442>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [January 31, 2017, 11:23pm UTC](https://discuss.elastic.co/t/chain-input-get-results-filtered-by-first-input/73442 "2017-01-31T23:23:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![YvorL](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@YvorL](https://discuss.elastic.co/u/YvorL)\
**Post date:** [January 31, 2017, 11:23pm UTC](https://discuss.elastic.co/t/chain-input-get-results-filtered-by-first-input/73442/1 "2017-01-31T23:23:26Z")

</div>

Hi!

I'm trying to get working a watcher which would alert me when one of my sites generates some error, but I'm only interested in that data if there aren't normal response codes.  
I tried referring to the first input's data, but if I understood correctly [here](https://discuss.elastic.co/t/watcher-chain-input-example-use-case/37688/3) it's not possible. Then I thought I could compare somehow the two result set but couldn't get any result from that.  
I'd like to achieve somehow that if field equals to X then check how many times got the same pages (by referring to the first result set's other indexed field) got Y. Preferably I'd check the difference, but that's after I get this working 🙂

Thank you!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [February 1, 2017, 5:29am UTC](https://discuss.elastic.co/t/chain-input-get-results-filtered-by-first-input/73442/2 "2017-02-01T05:29:39Z")

</div>

You can have a first search/aggregation that identify all sites that have an error and then chain it to a second search/aggregation that for these sites retrieves the number of normal response codes. An example of doing something similar can be found [here](https://github.com/elastic/examples/tree/master/Alerting/new_process_started).

---

<div class="post-metadata">

**Author:** ![YvorL](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@YvorL](https://discuss.elastic.co/u/YvorL)\
**Post date:** [February 1, 2017, 10:43pm UTC](https://discuss.elastic.co/t/chain-input-get-results-filtered-by-first-input/73442/3 "2017-02-01T22:43:55Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 1, 2017, 10:44pm UTC](https://discuss.elastic.co/t/chain-input-get-results-filtered-by-first-input/73442/4 "2017-03-01T22:44:33Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
