# Computing aggregation bucket size in actions

**URL:** <https://discuss.elastic.co/t/computing-aggregation-bucket-size-in-actions/54465>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [June 30, 2016, 7:13pm UTC](https://discuss.elastic.co/t/computing-aggregation-bucket-size-in-actions/54465 "2016-06-30T19:13:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rastro](https://avatars.discourse-cdn.com/v4/letter/r/b782af/32.png) [@rastro](https://discuss.elastic.co/u/rastro)\
**Post date:** [June 30, 2016, 7:13pm UTC](https://discuss.elastic.co/t/computing-aggregation-bucket-size-in-actions/54465/1 "2016-06-30T19:13:22Z")

</div>

I'm trying to get the number of buckets in my aggregation.

I tried {{ ctx.payload.aggregations.myAgg.buckets.size() }}, but nothing was displayed. I've seen other posts using that method in conditions, but I need it in actions.

I would also like to get the sum of each bucket's doc\_count (different than {{ ctx.payload.hits.total }} when using min\_doc\_count).

---

<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:** [July 1, 2016, 8:45am UTC](https://discuss.elastic.co/t/computing-aggregation-bucket-size-in-actions/54465/2 "2016-07-01T08:45:04Z")

</div>

Hey,

mustache requires you to use `{{ ctx.payload.aggregations.myAgg.buckets.size}}` as there is no support for calling functions...

--Alex

---

<div class="post-metadata">

**Author:** ![rastro](https://avatars.discourse-cdn.com/v4/letter/r/b782af/32.png) [@rastro](https://discuss.elastic.co/u/rastro)\
**Post date:** [July 1, 2016, 9:38pm UTC](https://discuss.elastic.co/t/computing-aggregation-bucket-size-in-actions/54465/3 "2016-07-01T21:38:00Z")

</div>

That worked; thanks.

---

<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, 2017, 1:44pm UTC](https://discuss.elastic.co/t/computing-aggregation-bucket-size-in-actions/54465/4 "2017-07-06T13:44:39Z")

</div>


