# What is the best query for this Watcher?

**URL:** <https://discuss.elastic.co/t/what-is-the-best-query-for-this-watcher/165078>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [January 21, 2019, 3:39pm UTC](https://discuss.elastic.co/t/what-is-the-best-query-for-this-watcher/165078 "2019-01-21T15:39:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![arisbanach](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@arisbanach](https://discuss.elastic.co/u/arisbanach)\
**Post date:** [January 21, 2019, 3:40pm UTC](https://discuss.elastic.co/t/what-is-the-best-query-for-this-watcher/165078/1 "2019-01-21T15:40:00Z")

</div>

I have multiple `term` values that are for the `customer` field. I would like to set up a Watcher to alert me when ANY of our customers have a document count less than a certain amount. I currently have one dedicated watcher for each `customer`value, but it would be nice to have one for everything. Is there a good way to do this?

Thank you.

---

<div class="post-metadata">

**Author:** ![arisbanach](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@arisbanach](https://discuss.elastic.co/u/arisbanach)\
**Post date:** [February 1, 2019, 8:47pm UTC](https://discuss.elastic.co/t/what-is-the-best-query-for-this-watcher/165078/2 "2019-02-01T20:47:50Z")

</div>

Bump

---

<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, 2019, 8:48pm UTC](https://discuss.elastic.co/t/what-is-the-best-query-for-this-watcher/165078/3 "2019-03-01T20:48:03Z")

</div>

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

---

<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:** [March 20, 2019, 9:06am UTC](https://discuss.elastic.co/t/what-is-the-best-query-for-this-watcher/165078/4 "2019-03-20T09:06:27Z")

</div>

Hey,

instead of a watch per customer, you could go with a [terms](https://www.elastic.co/guide/en/elasticsearch/reference/6.6/search-aggregations-bucket-terms-aggregation.html) aggregation. However bear in mind that counts are not accurate and this might be especially true for the data you are after.

Can you maybe explain your use-case a bit more? how many customers? what kind of minimum value? That might help to find the proper setup.

--Alex
