# Average doc\_count per hour?

**URL:** https://discuss.elastic.co/t/average-doc-count-per-hour/16995
**Category:** Elasticsearch
**Created:** [April 14, 2014, 6:41am UTC](https://discuss.elastic.co/t/average-doc-count-per-hour/16995 "2014-04-14T06:41:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Shrinath\_M](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shrinath_m/32/1640_2.png) [@Shrinath\_M](https://discuss.elastic.co/u/Shrinath_M)
#### Post date: [April 14, 2014, 6:41am UTC](https://discuss.elastic.co/t/average-doc-count-per-hour/16995/1 "2014-04-14T06:41:03Z")

</div>

Is there a way I can use "avg" aggregation to return just the "average  
documents" in an hour/min/date-range?

What I am trying to do is this -

I have fed the Nginx server logs to elasticsearch, now I want to know whats  
the average number of responses that returned 50x, 40x and 20x per hour for  
last 5 hours.  
Possible to do?

I could get the "for last 5 hours" part with date\_histogram, also, 50x, 40x  
and 20x part was easy using aggregation buckets. But couldn't find how to  
get avg of "doc\_count" ☹

Any help would be appreciated.

Regards,  
Shrinath M

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9f0d44b0-e4da-42f4-b446-d7d5a6018907%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9f0d44b0-e4da-42f4-b446-d7d5a6018907%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [April 14, 2014, 9:05am UTC](https://discuss.elastic.co/t/average-doc-count-per-hour/16995/2 "2014-04-14T09:05:11Z")

</div>

Hi Shrinath,

I think this could be done easily on client-side? For instance, you could  
compute the total number of documents over the X past hours, and then you  
would just have to divide by X to get the average per hour. Would this work  
for you?

On Mon, Apr 14, 2014 at 8:41 AM, Shrinath M [shrinath.m@webyog.com](mailto:shrinath.m@webyog.com) wrote:

> Is there a way I can use "avg" aggregation to return just the "average  
> documents" in an hour/min/date-range?
> 
> What I am trying to do is this -
> 
> I have fed the Nginx server logs to elasticsearch, now I want to know  
> whats the average number of responses that returned 50x, 40x and 20x per  
> hour for last 5 hours.  
> Possible to do?
> 
> I could get the "for last 5 hours" part with date\_histogram, also, 50x,  
> 40x and 20x part was easy using aggregation buckets. But couldn't find how  
> to get avg of "doc\_count" ☹
> 
> Any help would be appreciated.
> 
> Regards,  
> Shrinath M
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/9f0d44b0-e4da-42f4-b446-d7d5a6018907%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9f0d44b0-e4da-42f4-b446-d7d5a6018907%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/9f0d44b0-e4da-42f4-b446-d7d5a6018907%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/9f0d44b0-e4da-42f4-b446-d7d5a6018907%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6%2BmQzDZYGoZF4HURDpaXMoJP-c0j-\_Mj9epwZovo7Lgg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6%2BmQzDZYGoZF4HURDpaXMoJP-c0j-_Mj9epwZovo7Lgg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Shrinath\_M](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shrinath_m/32/1640_2.png) [@Shrinath\_M](https://discuss.elastic.co/u/Shrinath_M)
#### Post date: [April 14, 2014, 9:11am UTC](https://discuss.elastic.co/t/average-doc-count-per-hour/16995/3 "2014-04-14T09:11:03Z")

</div>

That definitely works, but since ES is already giving all the data neatly that can be directly plotted on graph without any logic or messing with keys, I thought it would be cleaner if ES had that option.

Sent using [CloudMagic](https://cloudmagic.com/k/d/mailapp?ct=pa&cv=1.0.19.7&pv=4.4.2)

On Mon, Apr 14, 2014 at 2:35 PM, Adrien Grand \<[adrien.grand@elasticsearch.com](mailto:adrien.grand@elasticsearch.com)\> wrote:

> Hi Shrinath,
> 
> I think this could be done easily on client-side? For instance, you could compute the total number of documents over the X past hours, and then you would just have to divide by X to get the average per hour. Would this work for you?
> 
> On Mon, Apr 14, 2014 at 8:41 AM, Shrinath M \<[shrinath.m@webyog.com](mailto:shrinath.m@webyog.com)\> wrote:
> 
> > Is there a way I can use "avg" aggregation to return just the "average documents" in an hour/min/date-range?
> > 
> > What I am trying to do is this -
> > 
> > I have fed the Nginx server logs to elasticsearch, now I want to know whats the average number of responses that returned 50x, 40x and 20x per hour for last 5 hours. Possible to do?
> > 
> > I could get the "for last 5 hours" part with date\_histogram, also, 50x, 40x and 20x part was easy using aggregation buckets. But couldn't find how to get avg of "doc\_count" ☹
> > 
> > Any help would be appreciated.
> > 
> > Regards, Shrinath M
> > 
> > --
> > 
> > You received this message because you are subscribed to the Google Groups "elasticsearch" group.
> > 
> > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).
> > 
> > To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9f0d44b0-e4da-42f4-b446-d7d5a6018907%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9f0d44b0-e4da-42f4-b446-d7d5a6018907%40googlegroups.com?utm_medium=email&utm_source=footer).
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --
> 
> Adrien Grand
> 
> --
> 
> You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.
> 
> To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/DdD5cXgw1PM/unsubscribe](https://groups.google.com/d/topic/elasticsearch/DdD5cXgw1PM/unsubscribe).
> 
> To unsubscribe from this group and all its topics, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).
> 
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6%2BmQzDZYGoZF4HURDpaXMoJP-c0j-\_Mj9epwZovo7Lgg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6%2BmQzDZYGoZF4HURDpaXMoJP-c0j-_Mj9epwZovo7Lgg%40mail.gmail.com?utm_medium=email&utm_source=footer).
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--

You received this message because you are subscribed to the Google Groups "elasticsearch" group.

To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).

To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/76aaed7bb8dd23662d1fdb11156b92%40ip-10-0-3-140](https://groups.google.com/d/msgid/elasticsearch/76aaed7bb8dd23662d1fdb11156b92%40ip-10-0-3-140?utm_medium=email&utm_source=footer).

For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:36am UTC](https://discuss.elastic.co/t/average-doc-count-per-hour/16995/4 "2017-07-06T01:36:03Z")

</div>


