# Creating new field by aggregating values from existing field values

**URL:** <https://discuss.elastic.co/t/creating-new-field-by-aggregating-values-from-existing-field-values/212498>\
**Category:** Elasticsearch\
**Created:** [December 19, 2019, 1:28pm UTC](https://discuss.elastic.co/t/creating-new-field-by-aggregating-values-from-existing-field-values/212498 "2019-12-19T13:28:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saptha\_AD](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saptha_ad/32/48651_2.png) [@Saptha\_AD](https://discuss.elastic.co/u/Saptha_AD)\
**Post date:** [December 19, 2019, 1:28pm UTC](https://discuss.elastic.co/t/creating-new-field-by-aggregating-values-from-existing-field-values/212498/1 "2019-12-19T13:28:06Z")

</div>

We want to create new field as "ProcCount3minAvg" for all the documents in Elasticsearch, "ProcTime3minAvg" is avg aggregation value of a floating point field captured from logs called "ProcCount". Avg value should be the last 3 document ProcCount field value.

Example.

Request\_\_\_\_\_\_\_\_\_\_\_\_ProcCount\_\_\_\_\_\_\_ ProcCount3minAvg

MicroserviceA\_\_\_\_\_\_\_\_\_\_ 3\_\_\_\_\_\_\_\_\_\_\_\_\_ 3 [(3+0+0)/3]  
MicroserviceB\_\_\_\_\_\_\_\_\_\_ 4\_\_\_\_\_\_\_\_\_\_\_\_\_3.5 [(3+4+0)/3]  
MicroserviceC\_\_\_\_\_\_\_\_\_\_\_3\_\_\_\_\_\_\_\_\_\_\_\_\_3.33 [(3+4+3)/3]  
MicroserviceA\_\_\_\_\_\_\_\_\_\_ 5\_\_\_\_\_\_\_\_\_\_\_\_\_ 4.0 [(5+3+4)/3]  
MicroserviceB\_\_\_\_\_\_\_\_\_\_ 2\_\_\_\_\_\_\_\_\_\_\_\_\_ 3.33 [(2+5+3)/3]  
MicroserviceC\_\_\_\_\_\_\_\_\_\_ 6\_\_\_\_\_\_\_\_\_\_\_\_\_ 4.33 [(6+2+5)/3]  
MicroserviceA\_\_\_\_\_\_\_\_\_\_ 4\_\_\_\_\_\_\_\_\_\_\_\_\_ 4.0 [(4+6+2)/3]  
MicroserviceB\_\_\_\_\_\_\_\_\_\_ 1\_\_\_\_\_\_\_\_\_\_\_\_\_ 3.66 [(1+4+6)/3]  
MicroserviceC \_\_\_\_\_\_\_\_\_ 7\_\_\_\_\_\_\_\_\_\_\_\_\_ 4.0 [(7+1+4)/3]  
MicroserviceA\_\_\_\_\_\_\_\_\_\_5\_\_\_\_\_\_\_\_\_\_\_\_\_ 4.33 [(5+7+1)/3]  
MicroserviceB\_\_\_\_\_\_\_\_\_\_7\_\_\_\_\_\_\_\_\_\_\_\_\_ 6.33 [(7+5+7)/3]

How to create this new field, Using Mutate Filter in Logstash or Kibana Scripted Field or any Elasticsearch 6.8 indexing level. This will help us to create a POC to migrate viz from Splunk to ELK

---

<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:** [January 16, 2020, 1:28pm UTC](https://discuss.elastic.co/t/creating-new-field-by-aggregating-values-from-existing-field-values/212498/2 "2020-01-16T13:28:11Z")

</div>

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