# Sum up Aggregation values?

**URL:** <https://discuss.elastic.co/t/sum-up-aggregation-values/20807>\
**Category:** Elasticsearch\
**Created:** [November 18, 2014, 10:41am UTC](https://discuss.elastic.co/t/sum-up-aggregation-values/20807 "2014-11-18T10:41:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grauen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grauen/32/88529_2.png) [@Grauen](https://discuss.elastic.co/u/Grauen)\
**Post date:** [November 18, 2014, 10:41am UTC](https://discuss.elastic.co/t/sum-up-aggregation-values/20807/1 "2014-11-18T10:41:34Z")

</div>

I calculate the duration of my service-processes using the  
SUM-Aggregation. Each step of the executed process will be saved in  
Elasticsearch under a calling Id.

This is what I monitor:

Duration of Request-Processing for ID #123 (calling service #1)  
Duration of Server-Response for ID #123 (calling service #1)  
**Complete Duration for ID #123**

Duration of Request-Processing for ID #124 (calling service #1)  
Duration of Server-Response for ID #124 (calling service #1)  
**Complete duration for ID #124**

Filter:

{  
"from" : 0, "size" :0,

```
"query" : {
    "filtered" : {
        "query" : { "match_all" : {}},
        "filter" : {
            "term" : { 
                "callingId" : "123",
            }
        }
    }
},
"aggs" : {
    "total_duration" : { "sum" : { "field" : "duration" } },
    "max_duration":{"max": {"field":"duration"}},   
    "min_duration":{"min":{"field":"duration"}}
    }
}
}

```

This returns the complete duration of the process and also tells me which  
part of the process was the fastest ans which part was the slowest.

Next I want to calculate the average _duration of all finished processes_  
by serviceId. In this case I only care about the total duration for each  
service, so I can comepare them.

Is it possible to create a average, maximum and minimum from all  
total\_durations?

--  
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/c20c4d79-cab0-4086-bcdd-574b4d102567%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c20c4d79-cab0-4086-bcdd-574b4d102567%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:** [November 18, 2014, 11:26am UTC](https://discuss.elastic.co/t/sum-up-aggregation-values/20807/2 "2014-11-18T11:26:57Z")

</div>

I believe this would be addressed through  
[Reducers - Post processing of aggregation results · Issue #8110 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/8110).

Another option would be to adopt a more entity-centric way of indexing your  
documents by having one document per callingId and updating it every time  
that you get a new event (so that your index contains only one document per  
callingId).

On Tue, Nov 18, 2014 at 11:41 AM, Grauen [allmightygoot@googlemail.com](mailto:allmightygoot@googlemail.com)  
wrote:

> I calculate the duration of my service-processes using the  
> SUM-Aggregation. Each step of the executed process will be saved in  
> Elasticsearch under a calling Id.
> 
> This is what I monitor:
> 
> Duration of Request-Processing for ID #123 (calling service #1)  
> Duration of Server-Response for ID #123 (calling service #1)  
> **Complete Duration for ID #123**
> 
> Duration of Request-Processing for ID #124 (calling service #1)  
> Duration of Server-Response for ID #124 (calling service #1)  
> **Complete duration for ID #124**
> 
> Filter:
> 
> {  
> "from" : 0, "size" :0,
> 
> ```
> "query" : {
> "filtered" : {
> "query" : { "match_all" : {}},
> "filter" : {
> "term" : {
> "callingId" : "123",
> }
> }
> }
> },
> "aggs" : {
> "total_duration" : { "sum" : { "field" : "duration" } },
> "max_duration":{"max": {"field":"duration"}},
> "min_duration":{"min":{"field":"duration"}}
> }
> }
> }
> 
> ```
> 
> This returns the complete duration of the process and also tells me  
> which part of the process was the fastest ans which part was the slowest.
> 
> Next I want to calculate the average _duration of all finished processes_  
> by serviceId. In this case I only care about the total duration for each  
> service, so I can comepare them.
> 
> Is it possible to create a average, maximum and minimum from all  
> total\_durations?
> 
> --  
> 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/c20c4d79-cab0-4086-bcdd-574b4d102567%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c20c4d79-cab0-4086-bcdd-574b4d102567%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/c20c4d79-cab0-4086-bcdd-574b4d102567%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c20c4d79-cab0-4086-bcdd-574b4d102567%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/CAL6Z4j7a3bCko0%3DUx%3DupzOD74SBrtfKJ4Tr%2B6584YJcht4Aynw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7a3bCko0%3DUx%3DupzOD74SBrtfKJ4Tr%2B6584YJcht4Aynw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Grauen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grauen/32/88529_2.png) [@Grauen](https://discuss.elastic.co/u/Grauen)\
**Post date:** [November 18, 2014, 11:54am UTC](https://discuss.elastic.co/t/sum-up-aggregation-values/20807/3 "2014-11-18T11:54:48Z")

</div>

Thanks for Your answer. Do you have any clue when 2.0 will be released?

Sincerly

Grauen

Am Dienstag, 18. November 2014 12:27:05 UTC+1 schrieb Adrien Grand:

> I believe this would be addressed through  
> [Reducers - Post processing of aggregation results · Issue #8110 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/8110).
> 
> Another option would be to adopt a more entity-centric way of indexing  
> your documents by having one document per callingId and updating it every  
> time that you get a new event (so that your index contains only one  
> document per callingId).
> 
> On Tue, Nov 18, 2014 at 11:41 AM, Grauen \<[allmig...@googlemail.com](mailto:allmig...@googlemail.com)  
> \<javascript:\>\> wrote:
> 
> > I calculate the duration of my service-processes using the  
> > SUM-Aggregation. Each step of the executed process will be saved in  
> > Elasticsearch under a calling Id.
> > 
> > This is what I monitor:
> > 
> > Duration of Request-Processing for ID #123 (calling service #1)  
> > Duration of Server-Response for ID #123 (calling service #1)  
> > **Complete Duration for ID #123**
> > 
> > Duration of Request-Processing for ID #124 (calling service #1)  
> > Duration of Server-Response for ID #124 (calling service #1)  
> > **Complete duration for ID #124**
> > 
> > Filter:
> > 
> > {  
> > "from" : 0, "size" :0,
> > 
> > ```
> > "query" : {
> > "filtered" : {
> > "query" : { "match_all" : {}},
> > "filter" : {
> > "term" : { 
> > "callingId" : "123",
> > }
> > }
> > }
> > },
> > "aggs" : {
> > "total_duration" : { "sum" : { "field" : "duration" } },
> > "max_duration":{"max": {"field":"duration"}},   
> > "min_duration":{"min":{"field":"duration"}}
> > }
> > }
> > }
> > 
> > ```
> > 
> > This returns the complete duration of the process and also tells me  
> > which part of the process was the fastest ans which part was the slowest.
> > 
> > Next I want to calculate the average _duration of all finished processes_  
> > by serviceId. In this case I only care about the total duration for each  
> > service, so I can comepare them.
> > 
> > Is it possible to create a average, maximum and minimum from all  
> > total\_durations?
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/c20c4d79-cab0-4086-bcdd-574b4d102567%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c20c4d79-cab0-4086-bcdd-574b4d102567%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/c20c4d79-cab0-4086-bcdd-574b4d102567%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c20c4d79-cab0-4086-bcdd-574b4d102567%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/aad9c8d7-43f6-4d82-986c-d0afe60cf46c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/aad9c8d7-43f6-4d82-986c-d0afe60cf46c%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:** [November 18, 2014, 12:49pm UTC](https://discuss.elastic.co/t/sum-up-aggregation-values/20807/4 "2014-11-18T12:49:08Z")

</div>

Hard to tell. There are lots of things we would like to clean up for 2.0  
and we only started efforts towards that direction (that is why you see  
more 2.0-only issues on Github these days than in the last months), so it  
will certainly take time.

On Tue, Nov 18, 2014 at 12:54 PM, Grauen [allmightygoot@googlemail.com](mailto:allmightygoot@googlemail.com)  
wrote:

> Thanks for Your answer. Do you have any clue when 2.0 will be released?
> 
> Sincerly
> 
> Grauen
> 
> Am Dienstag, 18. November 2014 12:27:05 UTC+1 schrieb Adrien Grand:
> 
> > I believe this would be addressed through [https://github.com/](https://github.com/)  
> > elasticsearch/elasticsearch/issues/8110.
> > 
> > Another option would be to adopt a more entity-centric way of indexing  
> > your documents by having one document per callingId and updating it every  
> > time that you get a new event (so that your index contains only one  
> > document per callingId).
> > 
> > On Tue, Nov 18, 2014 at 11:41 AM, Grauen [allmig...@googlemail.com](mailto:allmig...@googlemail.com)  
> > wrote:
> > 
> > > I calculate the duration of my service-processes using the  
> > > SUM-Aggregation. Each step of the executed process will be saved in  
> > > Elasticsearch under a calling Id.
> > > 
> > > This is what I monitor:
> > > 
> > > Duration of Request-Processing for ID #123 (calling service #1)  
> > > Duration of Server-Response for ID #123 (calling service #1)  
> > > **Complete Duration for ID #123**
> > > 
> > > Duration of Request-Processing for ID #124 (calling service #1)  
> > > Duration of Server-Response for ID #124 (calling service #1)  
> > > **Complete duration for ID #124**
> > > 
> > > Filter:
> > > 
> > > {  
> > > "from" : 0, "size" :0,
> > > 
> > > ```
> > > "query" : {
> > > "filtered" : {
> > > "query" : { "match_all" : {}},
> > > "filter" : {
> > > "term" : {
> > > "callingId" : "123",
> > > }
> > > }
> > > }
> > > },
> > > "aggs" : {
> > > "total_duration" : { "sum" : { "field" : "duration" } },
> > > "max_duration":{"max": {"field":"duration"}},
> > > "min_duration":{"min":{"field":"duration"}}
> > > }
> > > }
> > > }
> > > 
> > > ```
> > > 
> > > This returns the complete duration of the process and also tells me  
> > > which part of the process was the fastest ans which part was the slowest.
> > > 
> > > Next I want to calculate the average _duration of all finished  
> > > processes_ by serviceId. In this case I only care about the total  
> > > duration for each service, so I can comepare them.
> > > 
> > > Is it possible to create a average, maximum and minimum from all  
> > > total\_durations?
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/c20c4d79-cab0-4086-bcdd-574b4d102567%  
> > > [40googlegroups.com](http://40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/c20c4d79-cab0-4086-bcdd-574b4d102567%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c20c4d79-cab0-4086-bcdd-574b4d102567%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/aad9c8d7-43f6-4d82-986c-d0afe60cf46c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/aad9c8d7-43f6-4d82-986c-d0afe60cf46c%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/aad9c8d7-43f6-4d82-986c-d0afe60cf46c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/aad9c8d7-43f6-4d82-986c-d0afe60cf46c%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/CAL6Z4j5Pj99\_t4wsb0137ZP90mJ7Au50%3DCakim3ZV-xbMSuJHw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5Pj99_t4wsb0137ZP90mJ7Au50%3DCakim3ZV-xbMSuJHw%40mail.gmail.com).  
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, 12:49am UTC](https://discuss.elastic.co/t/sum-up-aggregation-values/20807/5 "2017-07-06T00:49:14Z")

</div>


