# How to check bucket size condition and change email action in watcher?

**URL:** https://discuss.elastic.co/t/how-to-check-bucket-size-condition-and-change-email-action-in-watcher/347183
**Category:** Elasticsearch
**Created:** [November 15, 2023, 3:27am UTC](https://discuss.elastic.co/t/how-to-check-bucket-size-condition-and-change-email-action-in-watcher/347183 "2023-11-15T03:27:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![helloworld3112](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/helloworld3112/32/127579_2.png) [@helloworld3112](https://discuss.elastic.co/u/helloworld3112)
#### Post date: [November 15, 2023, 3:27am UTC](https://discuss.elastic.co/t/how-to-check-bucket-size-condition-and-change-email-action-in-watcher/347183/1 "2023-11-15T03:27:06Z")

</div>

Hello everyone,

I have a watcher:

```auto
{
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "index-*"
        ],
        "body": {
          "query": {"match_all": {}},
          "aggs": {
            "group_a": {},
            "group_b": {},
            "group_c": {}
          }
        }
      }
    }
  }
}

```

With the watcher action, how can I check whether the groups have data or not? For example:  
If ctx.payload.aggregations.group\_a.buckets.size() = 0 --\> Email:

```auto
Group B:
LIST GROUP A {{key}} and {{doc_count}}
Group C:
LIST GROUP C {{key}} and {{doc_count}}

```

Similar to other groups, if the group has no data, it will be removed from the warning email

---

<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: [December 13, 2023, 3:27am UTC](https://discuss.elastic.co/t/how-to-check-bucket-size-condition-and-change-email-action-in-watcher/347183/2 "2023-12-13T03:27:30Z")

</div>

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