# Extract fields from a field and add the total count

**URL:** <https://discuss.elastic.co/t/extract-fields-from-a-field-and-add-the-total-count/339386>\
**Category:** Logstash\
**Created:** [July 27, 2023, 6:09am UTC](https://discuss.elastic.co/t/extract-fields-from-a-field-and-add-the-total-count/339386 "2023-07-27T06:09:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshuskarki](https://avatars.discourse-cdn.com/v4/letter/j/848f3c/32.png) [@joshuskarki](https://discuss.elastic.co/u/joshuskarki)\
**Post date:** [July 27, 2023, 6:09am UTC](https://discuss.elastic.co/t/extract-fields-from-a-field-and-add-the-total-count/339386/1 "2023-07-27T06:09:12Z")

</div>

I have this logs (json format) imported into elastic via logstash.

`"fields.models": "{'msp': '1', 'tcl': '1'}",`

with logstash, how do we extract the model name and calculate the total count  
The desired output should appear as follows:

`model_name : msp, tcl`  
`model_count: 2`

---

<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:** [August 24, 2023, 6:09am UTC](https://discuss.elastic.co/t/extract-fields-from-a-field-and-add-the-total-count/339386/2 "2023-08-24T06:09:35Z")

</div>

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