# How to rename a field with regex

**URL:** <https://discuss.elastic.co/t/how-to-rename-a-field-with-regex/316972>\
**Category:** Logstash\
**Created:** [October 19, 2022, 8:33am UTC](https://discuss.elastic.co/t/how-to-rename-a-field-with-regex/316972 "2022-10-19T08:33:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saeedeh\_Moghimi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saeedeh_moghimi/32/111465_2.png) [@Saeedeh\_Moghimi](https://discuss.elastic.co/u/Saeedeh_Moghimi)\
**Post date:** [October 19, 2022, 8:33am UTC](https://discuss.elastic.co/t/how-to-rename-a-field-with-regex/316972/1 "2022-10-19T08:33:08Z")

</div>

I have a log like this:

```auto
{"A.amazon.aws.requestedParameters":{"testlabel1":"testvalue1"}}
{"B.amazon.aws.requestedParameters":{"testlabel1":"testvalue1"}}
...

```

and I want to change the field name to something like this: `A-requestedParameters` , `B-requestedParameters`, ...  
I checked the mutate filter plugin but it doesn't work with regex.  
How can I do it?

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [October 19, 2022, 9:11am UTC](https://discuss.elastic.co/t/how-to-rename-a-field-with-regex/316972/2 "2022-10-19T09:11:05Z")

</div>

You have only rename to change fieldname1 to fieldname2.  
If you want to use regex, then you need ruby. Check [sample](https://stackoverflow.com/questions/31068169/how-to-remove-underscores-in-field-names-with-logstash/31120218).

---

<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:** [November 16, 2022, 9:11am UTC](https://discuss.elastic.co/t/how-to-rename-a-field-with-regex/316972/3 "2022-11-16T09:11:16Z")

</div>

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