# Calc average doc count per hour

**URL:** <https://discuss.elastic.co/t/calc-average-doc-count-per-hour/32012>\
**Category:** Elasticsearch\
**Created:** [October 12, 2015, 2:26pm UTC](https://discuss.elastic.co/t/calc-average-doc-count-per-hour/32012 "2015-10-12T14:26:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexbourne](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@alexbourne](https://discuss.elastic.co/u/alexbourne)\
**Post date:** [October 12, 2015, 2:26pm UTC](https://discuss.elastic.co/t/calc-average-doc-count-per-hour/32012/1 "2015-10-12T14:26:11Z")

</div>

Hi Guys, my index is a set of messages that have a timestamp. I want to calculate the average number of messages each hour for the past month. So the output would be something like:  
1 50  
2 75  
3 68  
...  
23 100  
24 98

It looks as if some of the new features in ES 2.0 might enable this, but while I can get a doc count of the number of messages each hour using a date histogram, I just cannot work out how to then summarise it by hour essentially ignoring the date.

Any suggestions???  
Thanks,  
Alex

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 13, 2015, 11:21pm UTC](https://discuss.elastic.co/t/calc-average-doc-count-per-hour/32012/2 "2015-10-13T23:21:44Z")

</div>

> [@alexbourne](#):
>
> It looks as if some of the new features in ES 2.0 might enable this

That's correct, you will need to wait for that to arrive.

---

<div class="post-metadata">

**Author:** ![alexbourne](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@alexbourne](https://discuss.elastic.co/u/alexbourne)\
**Post date:** [October 14, 2015, 7:25am UTC](https://discuss.elastic.co/t/calc-average-doc-count-per-hour/32012/3 "2015-10-14T07:25:54Z")

</div>

OK. Is it possible to do this using 2.0 RC1? I've installed it bit I still can't get my head around how to set up the aggregations. Any suggestions as to how to structure them would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [October 14, 2015, 7:46am UTC](https://discuss.elastic.co/t/calc-average-doc-count-per-hour/32012/4 "2015-10-14T07:46:57Z")

</div>

Whilst this is something that will be possible with a Pipeline Aggregation, unfortunately there is not currently one written that will do what you are after. Essentially you would need a pipeline aggregation which uses a date histogram as an input and outputs a new aggregation which has a bucket for each hour in the day. The aggregation would then re-bucket the data from the histogram aggregation into this new aggregation.

---

<div class="post-metadata">

**Author:** ![crickes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/crickes/32/18009_2.png) [@crickes](https://discuss.elastic.co/u/crickes)\
**Post date:** [June 13, 2016, 9:20pm UTC](https://discuss.elastic.co/t/calc-average-doc-count-per-hour/32012/5 "2016-06-13T21:20:49Z")

</div>

Just stumbled across this post as I'm trying to do something very similar. I have used a date histogram with a script in order to to get a per second hit count for log entries. There is one bucket per second for 24 hours, 86400 buckets! What I want to do now is produce a reduced histogram from this parent histogram, where each bucket represents 5 minutes and will contain the average or max value of doc\_count from corresponding the parent buckets. Is there any way to achieve this yet?

---

<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 5, 2017, 10:44pm UTC](https://discuss.elastic.co/t/calc-average-doc-count-per-hour/32012/6 "2017-07-05T22:44:13Z")

</div>


