# Best way to maintain total count for rollup documents?

**URL:** <https://discuss.elastic.co/t/best-way-to-maintain-total-count-for-rollup-documents/269109>\
**Category:** Logstash\
**Created:** [April 2, 2021, 1:37pm UTC](https://discuss.elastic.co/t/best-way-to-maintain-total-count-for-rollup-documents/269109 "2021-04-02T13:37:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hsalim](https://avatars.discourse-cdn.com/v4/letter/h/c67d28/32.png) [@hsalim](https://discuss.elastic.co/u/hsalim)\
**Post date:** [April 2, 2021, 1:37pm UTC](https://discuss.elastic.co/t/best-way-to-maintain-total-count-for-rollup-documents/269109/1 "2021-04-02T13:37:54Z")

</div>

Hello,  
I am performing Elastic rollups on an index with the following streaming documents and fields. Rollup is on Field 1:  
Field1 Field2  
doc1 1200 a  
doc2 1200 b  
doc3 1200 c  
doc4 1100 d  
doc5 1100 e  
doc6 1100 f

after rollup I get:  
1200 3  
1100 3

I am trying to figure out a best way to maintain a running count of all documents in a new field called 'Total', so my result should look something like:  
Field1 count  
1200 3  
1100 3  
'Total' 6

I know there are several possibilities to accomplish this, including using logstash, elasticsearch, kibana, but what would be the best simple approach?

Can I maintain a counter in logstash pipeline for streaming data that arrives a minute apart? any other ideas?

Thank you for any insights!

---

<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:** [April 30, 2021, 1:38pm UTC](https://discuss.elastic.co/t/best-way-to-maintain-total-count-for-rollup-documents/269109/2 "2021-04-30T13:38:52Z")

</div>

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