# Watcher aggregrations compare bucket keys

**URL:** <https://discuss.elastic.co/t/watcher-aggregrations-compare-bucket-keys/218854>\
**Category:** Elasticsearch\
**Created:** [February 11, 2020, 7:45pm UTC](https://discuss.elastic.co/t/watcher-aggregrations-compare-bucket-keys/218854 "2020-02-11T19:45:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![probson](https://avatars.discourse-cdn.com/v4/letter/p/e47c2d/32.png) [@probson](https://discuss.elastic.co/u/probson)\
**Post date:** [February 11, 2020, 7:45pm UTC](https://discuss.elastic.co/t/watcher-aggregrations-compare-bucket-keys/218854/1 "2020-02-11T19:45:57Z")

</div>

Hi,

I have a watcher with chained input. 2 searches, each searching for a different process that has been executed within the time period. I have an terms aggregation in each search for host.name

My aim is to trigger an alert of a host.name triggers both processes within the time period.

Am I going about this the right way or is there a better way?

If this is the correct way are there any good examples for the compare of the bucket keys to alert when theres a match for the same host.name in both?

Thanks

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 12, 2020, 4:10pm UTC](https://discuss.elastic.co/t/watcher-aggregrations-compare-bucket-keys/218854/2 "2020-02-12T16:10:45Z")

</div>

hey,

that sounds about right. You might want to check out the [Alerting examples](https://github.com/elastic/examples/tree/master/Alerting/Sample%20Watches) for some inspirations regarding scripting. You will need a script condition to properly check for this. My take would be to collect all the host names from each search response aggregation and then check if those differ.

--Alex

---

<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 11, 2020, 4:10pm UTC](https://discuss.elastic.co/t/watcher-aggregrations-compare-bucket-keys/218854/3 "2020-03-11T16:10:52Z")

</div>

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