# How to get the aggregation value into a field in CSV in logstash configuration file?

**URL:** <https://discuss.elastic.co/t/how-to-get-the-aggregation-value-into-a-field-in-csv-in-logstash-configuration-file/298741>\
**Category:** Elasticsearch\
**Created:** [March 3, 2022, 12:06pm UTC](https://discuss.elastic.co/t/how-to-get-the-aggregation-value-into-a-field-in-csv-in-logstash-configuration-file/298741 "2022-03-03T12:06:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajay4998](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@Ajay4998](https://discuss.elastic.co/u/Ajay4998)\
**Post date:** [March 3, 2022, 12:06pm UTC](https://discuss.elastic.co/t/how-to-get-the-aggregation-value-into-a-field-in-csv-in-logstash-configuration-file/298741/1 "2022-03-03T12:06:11Z")

</div>

Hi All,

How to get terms aggregation key into field and value into field value in logstash for a CSV file, i have used Elasticsearch filter and also give the json file for query. can some please help on this

Elasticsearch query  
GET dump1/\_search  
{  
"size": 0,  
"query": {  
"bool": {  
"must": [  
{"term": {  
"person\_id.keyword": {  
"value": "id"  
}  
}}  
]  
}  
},  
"aggs": {  
"status": {  
"terms": {  
"field": "completion\_status.keyword",  
"size": 10  
}  
}  
}  
}

Output:  
{  
"took" : 3,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 1,  
"successful" : 1,  
"skipped" : 0,  
"failed" : 0  
},  
"hits" : {  
"total" : {  
"value" : 69,  
"relation" : "eq"  
},  
"max\_score" : null,  
"hits" :   
},  
"aggregations" : {  
"status" : {  
"doc\_count\_error\_upper\_bound" : 0,  
"sum\_other\_doc\_count" : 0,  
"buckets" : [  
{  
"key" : "In Progress",  
"doc\_count" : 58  
},  
{  
"key" : "Completed",  
"doc\_count" : 11  
}  
]  
}  
}  
}

---

<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:** [March 31, 2022, 12:06pm UTC](https://discuss.elastic.co/t/how-to-get-the-aggregation-value-into-a-field-in-csv-in-logstash-configuration-file/298741/2 "2022-03-31T12:06:57Z")

</div>

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