# Renaming dynamic nested json message fields

**URL:** https://discuss.elastic.co/t/renaming-dynamic-nested-json-message-fields/75799
**Category:** Logstash
**Created:** [February 20, 2017, 10:27pm UTC](https://discuss.elastic.co/t/renaming-dynamic-nested-json-message-fields/75799 "2017-02-20T22:27:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pbData](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@pbData](https://discuss.elastic.co/u/pbData)
#### Post date: [February 20, 2017, 10:27pm UTC](https://discuss.elastic.co/t/renaming-dynamic-nested-json-message-fields/75799/1 "2017-02-20T22:27:08Z")

</div>

I have the following json data

{  
"parent" : {  
" **child\_1**" : {  
"field\_1":123,  
"field\_2":" **my\_child\_1\_string**"  
},  
" **child\_2**" : {  
"field\_1":456,  
"field\_2":" **my\_child\_2\_string**"  
}  
}  
}

I need to be able to find all fields that are under a parent and rename that child with a field under the child. For example for the above it should look like

{  
"parent" : {  
" **my\_child\_1\_string**" : {  
"field\_1":123,  
"field\_2":" **my\_child\_1\_string**"  
},  
" **my\_child\_2\_string**" : {  
"field\_1":456,  
"field\_2":" **my\_child\_2\_string**"  
}  
}  
}

I think I need to possibly use a mutate filter for this or maybe something else. Not sure.

Hope you can help out.

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [February 23, 2017, 6:39am UTC](https://discuss.elastic.co/t/renaming-dynamic-nested-json-message-fields/75799/2 "2017-02-23T06:39:24Z")

</div>

The mutate filter won't be enough. You'll have to write a snippet of Ruby code in a ruby filter. I'm afraid I don't have an example of exactly what you need.

---

<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 23, 2017, 6:39am UTC](https://discuss.elastic.co/t/renaming-dynamic-nested-json-message-fields/75799/3 "2017-03-23T06:39:29Z")

</div>

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