# How to compare two aggregations buckets in watcher

**URL:** https://discuss.elastic.co/t/how-to-compare-two-aggregations-buckets-in-watcher/135640
**Category:** Elasticsearch
**Tags:** elastic-stack-alerting
**Created:** [June 13, 2018, 6:58am UTC](https://discuss.elastic.co/t/how-to-compare-two-aggregations-buckets-in-watcher/135640 "2018-06-13T06:58:18Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![addanuj](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@addanuj](https://discuss.elastic.co/u/addanuj)
#### Post date: [June 13, 2018, 6:58am UTC](https://discuss.elastic.co/t/how-to-compare-two-aggregations-buckets-in-watcher/135640/1 "2018-06-13T06:58:18Z")

</div>

Hi

Please let me know how i can compare two different aggregations buckets, i am only able to compare one bucket with one static value but i need to compare all values of two different aggregations buckets.

which should i use: array\_compare or only compare?

---

<div class="post-metadata">

### Author: ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)
#### Post date: [June 13, 2018, 3:06pm UTC](https://discuss.elastic.co/t/how-to-compare-two-aggregations-buckets-in-watcher/135640/2 "2018-06-13T15:06:38Z")

</div>

Anuj,

I've already recommended in [a different thread](https://discuss.elastic.co/t/how-to-compare-two-different-fields-value-of-two-different-index/132533/11) that you should look at this post for ideas:

> [@Comparing values from 2 ML Jobs in watcher](https://discuss.elastic.co/t/comparing-values-from-2-ml-jobs-in-watcher/118882):
>
> Hi, I have 2 different ML jobs. Identifies the anomaly in the users unusual login time. IE if users regularly logs in between 11:00 AM - 6:00 PM and one day he/she logs in @ 12:00 AM. this will be detected as a anomaly. Detect longitude-latitude usually used by a person, if a person usually logs in fro 11.222, -11.33 (example) and suddenly logs in from 13.22, -34,55. this will be detected as anomaly. This 2 job independently works fine. I need to write a watcher over these 2 job which …

Why do you keep on asking? I'm confused...

---

<div class="post-metadata">

### Author: ![addanuj](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@addanuj](https://discuss.elastic.co/u/addanuj)
#### Post date: [June 13, 2018, 3:08pm UTC](https://discuss.elastic.co/t/how-to-compare-two-aggregations-buckets-in-watcher/135640/3 "2018-06-13T15:08:58Z")

</div>

ohh my bad. i haven't saw that thread.

thank you so much Rich,

---

<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: [July 11, 2018, 3:09pm UTC](https://discuss.elastic.co/t/how-to-compare-two-aggregations-buckets-in-watcher/135640/4 "2018-07-11T15:09:00Z")

</div>

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