# Aggregration buckets can access in Elasticsearch query of "Rules and Connectors"

**URL:** https://discuss.elastic.co/t/aggregration-buckets-can-access-in-elasticsearch-query-of-rules-and-connectors/306641
**Category:** Kibana
**Created:** [June 8, 2022, 7:17am UTC](https://discuss.elastic.co/t/aggregration-buckets-can-access-in-elasticsearch-query-of-rules-and-connectors/306641 "2022-06-08T07:17:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![hari\_priya1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hari_priya1/32/106753_2.png) [@hari\_priya1](https://discuss.elastic.co/u/hari_priya1)
#### Post date: [June 8, 2022, 7:17am UTC](https://discuss.elastic.co/t/aggregration-buckets-can-access-in-elasticsearch-query-of-rules-and-connectors/306641/1 "2022-06-08T07:17:58Z")

</div>

I am trying to trigger an alert if BindRequestCount is zero for the last 30 mins. So I have created a rule using the Elasticsearch query rule type.

```auto
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "consumer_status.keyword": {
              "value": "actual_consumer"
            }
          }
        }
      ],
      "must_not": [
        {
          "terms": {
            "name.keyword": [
              "jumes29pipeline"
              
            ]
          }
        }
      ]
    }
  },
"aggs": {
  "consumer": {
    "terms": {
      "field": "name.keyword",
      "size": 1000
    },
          "aggs": {
            "metricAgg": {
              "avg": {
                "field": "bindRequestCount"
              }},
            "name": {
              "bucket_selector": {
                "buckets_path": {
                  "value": "metricAgg"
                },
                "script": "params.value == 0"
      }}
    }
  }}
}

```

Testing the above query able to access hits (documents matched) only, not the aggregation bucket output. Is there a way to access aggregation buckets in Rules and Connectors?

---

<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 6, 2022, 7:18am UTC](https://discuss.elastic.co/t/aggregration-buckets-can-access-in-elasticsearch-query-of-rules-and-connectors/306641/2 "2022-07-06T07:18:43Z")

</div>

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