# How can I know average value of field "elapsed.time"

**URL:** <https://discuss.elastic.co/t/how-can-i-know-average-value-of-field-elapsed-time/24928>\
**Category:** Elasticsearch\
**Created:** [July 6, 2015, 9:03am UTC](https://discuss.elastic.co/t/how-can-i-know-average-value-of-field-elapsed-time/24928 "2015-07-06T09:03:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Smasell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smasell/32/43483_2.png) [@Smasell](https://discuss.elastic.co/u/Smasell)\
**Post date:** [July 6, 2015, 9:03am UTC](https://discuss.elastic.co/t/how-can-i-know-average-value-of-field-elapsed-time/24928/1 "2015-07-06T09:03:07Z")

</div>

Hi!!  
I have my document with field "elapsed.time" I have to know average value of this field.  
Many thanks for helping me!!!

---

<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:** [July 6, 2015, 9:05am UTC](https://discuss.elastic.co/t/how-can-i-know-average-value-of-field-elapsed-time/24928/2 "2015-07-06T09:05:49Z")

</div>

You can use the `avg` aggregation, see [https://www.elastic.co/guide/en/elasticsearch/reference/1.6/search-aggregations-metrics-avg-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/1.6/search-aggregations-metrics-avg-aggregation.html)

---

<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:** [July 6, 2015, 9:05am UTC](https://discuss.elastic.co/t/how-can-i-know-average-value-of-field-elapsed-time/24928/3 "2015-07-06T09:05:53Z")

</div>

have a look at [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html), this should achieve what you are after

---

<div class="post-metadata">

**Author:** ![Smasell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smasell/32/43483_2.png) [@Smasell](https://discuss.elastic.co/u/Smasell)\
**Post date:** [July 6, 2015, 9:13am UTC](https://discuss.elastic.co/t/how-can-i-know-average-value-of-field-elapsed-time/24928/4 "2015-07-06T09:13:37Z")

</div>

@colings86  
@jpountz  
When i execute this aggs:  
"aggs" : {  
"avg\_time" : {  
"avg" : {  
"field" : "elapsed.time"  
}  
}  
}  
I get answer  
"hits": {  
"total": 17776184,  
"max\_score": 1,  
"hits": [......]  
I wonder where is average value?

---

<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:** [July 6, 2015, 9:14am UTC](https://discuss.elastic.co/t/how-can-i-know-average-value-of-field-elapsed-time/24928/5 "2015-07-06T09:14:31Z")

</div>

You should have an `aggs` element in the json response, it will be there.

---

<div class="post-metadata">

**Author:** ![Smasell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smasell/32/43483_2.png) [@Smasell](https://discuss.elastic.co/u/Smasell)\
**Post date:** [July 6, 2015, 9:23am UTC](https://discuss.elastic.co/t/how-can-i-know-average-value-of-field-elapsed-time/24928/6 "2015-07-06T09:23:06Z")

</div>

@colings86  
@jpountz  
Ok, I've found it in the end of JSON response  
Many 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, 12:03am UTC](https://discuss.elastic.co/t/how-can-i-know-average-value-of-field-elapsed-time/24928/7 "2017-07-06T00:03:29Z")

</div>


