# Last term agg bucket size

**URL:** <https://discuss.elastic.co/t/last-term-agg-bucket-size/129408>\
**Category:** Elasticsearch\
**Created:** [April 25, 2018, 5:48am UTC](https://discuss.elastic.co/t/last-term-agg-bucket-size/129408 "2018-04-25T05:48:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![clandestino\_bgd\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/clandestino_bgd_2/32/1315_2.png) [@clandestino\_bgd\_2](https://discuss.elastic.co/u/clandestino_bgd_2)\
**Post date:** [April 25, 2018, 5:48am UTC](https://discuss.elastic.co/t/last-term-agg-bucket-size/129408/1 "2018-04-25T05:48:24Z")

</div>

Hello, I have a following problem, hope somebody can help.  
I have a total count (TC) of agents (hard limit = number of seats) and I need to display their statuses over time: AVAILABLE, BUSY, ON\_BREAK and ABSENT. FIrst three statuses should be result of the term aggregation, but the ABSENT one should be TC - (size(AVAILABLE) +size (BUSY) + size (ON\_BREAK)).

Would it be possible to cap the size of the ABSENT bucket to TC - (sum of other bucket sizes).  
My client is grafana so I guess It has to be on the ES side, if it is possible at all.

Thanks,  
Milan

---

<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:** [May 23, 2018, 5:48am UTC](https://discuss.elastic.co/t/last-term-agg-bucket-size/129408/2 "2018-05-23T05:48:39Z")

</div>

Closed on May 23, 2018, 5:48am UTC

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