# Elasticsearch cumulative sum on derivative units(normalized\_value)

**URL:** <https://discuss.elastic.co/t/elasticsearch-cumulative-sum-on-derivative-units-normalized-value/205594>\
**Category:** Elasticsearch\
**Created:** [October 29, 2019, 6:10am UTC](https://discuss.elastic.co/t/elasticsearch-cumulative-sum-on-derivative-units-normalized-value/205594 "2019-10-29T06:10:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Narayana\_Pachava](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narayana_pachava/32/56640_2.png) [@Narayana\_Pachava](https://discuss.elastic.co/u/Narayana_Pachava)\
**Post date:** [October 29, 2019, 6:10am UTC](https://discuss.elastic.co/t/elasticsearch-cumulative-sum-on-derivative-units-normalized-value/205594/1 "2019-10-29T06:10:24Z")

</div>

i have running counter say port.packets and i want to calculate the cumulative sum on the buckets path of the derivates normalised value by units instead of the actual derivative value .

Usually cumulative sum is taking the name of the derivative buckets path , is there any way I can provide the buckets path as normalized value ?

example aggeration

```auto
{ 
"size":0,
 "query":{ 
   // some query 

},
"aggregations":{ 
  "termsAgg":{ 
     "terms":{ 
        "field":"portIdToClusterId",
        "size":1000,
        "order":[ 
           { 
              "_count":"desc"
           },
           { 
              "_key":"asc"
           }
        ]
     },
     "aggregations":{ 
        "dateHistogramAgg":{ 
           "date_histogram":{ 
              "field":"timestamp",
              "missing":0,
              "interval":"5m",
              "offset":0,
              "order":{ 
                 "_key":"asc"
              },
              "keyed":false,
              "min_doc_count":0
           },
           "aggregations":{ 
              "maxAggportrxpackets":{ 
                 "max":{ 
                    "field":"portpackets"
                 }
              },
              "derAggportrxpackets":{ 
                 "derivative":{ 
                    "buckets_path":[ 
                       "maxAggportrxpackets"
                    ],
                    "gap_policy":"skip",
                    "unit":"1s"
                 }
              },
              "cumSumAggportrxpackets":{ 
                 "cumulative_sum":{ 
                    "buckets_path":[ 
                       "derAggportrxpackets" // I want to take the normalized value instead of directly derivative
                    ]
                 }
              }
           }
        }
     }
   }
 }
}

Sample output :

"aggregations" : {
    "termsAgg" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [
        {
          "key" : "1_3_x8::10.115.32.163",
          "doc_count" : 12,
          "dateHistogramAgg" : {
            "buckets" : [
              {
                "key_as_string" : "2019-10-25T16:20:00.000Z",
                "key" : 1572020400000,
                "doc_count" : 1,
                "maxAggportrxpackets" : {
                  "value" : 1.86446649842E11
                },
                "cumSumAggportrxpackets" : {
                  "value" : 0.0
                }
              },
              {
                "key_as_string" : "2019-10-25T16:25:00.000Z",
                "key" : 1572020700000,
                "doc_count" : 1,
                "maxAggportrxpackets" : {
                  "value" : 1.86446649852E11
                },
                "derAggportrxpackets" : {
                  "value" : 10.0,
                  "normalized_value" : 0.03333333333333333
                },
                "cumSumAggportrxpackets" : {
                  "value" : 10.0
                }
              },
              {
                "key_as_string" : "2019-10-25T16:30:00.000Z",
                "key" : 1572021000000,
                "doc_count" : 1,
                "maxAggportrxpackets" : {
                  "value" : 1.86446649862E11
                },
                "derAggportrxpackets" : {
                  "value" : 10.0,
                  "normalized_value" : 0.03333333333333333
                },
                "cumSumAggportrxpackets" : {
                  "value" : 20.0 // Here I want the cum sum on the normalized_value of the derivative rather than actual derivative 
                }
              }
```

---

<div class="post-metadata">

**Author:** ![Narayana\_Pachava](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narayana_pachava/32/56640_2.png) [@Narayana\_Pachava](https://discuss.elastic.co/u/Narayana_Pachava)\
**Post date:** [November 19, 2019, 11:19am UTC](https://discuss.elastic.co/t/elasticsearch-cumulative-sum-on-derivative-units-normalized-value/205594/2 "2019-11-19T11:19:06Z")

</div>

Identified the solution

"cumSumAggportrxpackets":{  
"cumulative\_sum":{  
"buckets\_path":[  
"derAggportrxpackets.normalized\_value"  
]  
}  
}

derAgginlineSslMonitortcpSessions.normalized\_value

---

<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:** [December 17, 2019, 11:19am UTC](https://discuss.elastic.co/t/elasticsearch-cumulative-sum-on-derivative-units-normalized-value/205594/3 "2019-12-17T11:19:08Z")

</div>

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