# Rename variable field in json file using logstash

**URL:** <https://discuss.elastic.co/t/rename-variable-field-in-json-file-using-logstash/234003>\
**Category:** Logstash\
**Created:** [May 23, 2020, 3:31pm UTC](https://discuss.elastic.co/t/rename-variable-field-in-json-file-using-logstash/234003 "2020-05-23T15:31:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kush\_Wadhwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kush_wadhwa/32/44101_2.png) [@Kush\_Wadhwa](https://discuss.elastic.co/u/Kush_Wadhwa)\
**Post date:** [May 23, 2020, 3:31pm UTC](https://discuss.elastic.co/t/rename-variable-field-in-json-file-using-logstash/234003/1 "2020-05-23T15:31:04Z")

</div>

Hi,

I have a jason file which has event0,event1, event2......event50000. I would like to rename all of it to event in Logstash so that the field name is event and corresponding value of event0, event 1 are stored under event field.

I understand that there is no wild card which works in Logstash and ruby filter is one that we can use. Need help to write ruby code to rename it.

---

<div class="post-metadata">

**Author:** ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)\
**Post date:** [May 25, 2020, 11:27am UTC](https://discuss.elastic.co/t/rename-variable-field-in-json-file-using-logstash/234003/2 "2020-05-25T11:27:48Z")

</div>

Hello.  
Please work a bit harder on the question formulation and give proper input and expected output.  
I can only guess that you want to produce from:

{"event1":"value1", "event2":"value2"}

the structure:

{"event":{"event1":"value1", "event2":"value2"}}  
?

---

<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:** [June 22, 2020, 11:28am UTC](https://discuss.elastic.co/t/rename-variable-field-in-json-file-using-logstash/234003/3 "2020-06-22T11:28:00Z")

</div>

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