# How to re-name field names in logstash

**URL:** <https://discuss.elastic.co/t/how-to-re-name-field-names-in-logstash/291803>\
**Category:** Logstash\
**Created:** [December 14, 2021, 12:51pm UTC](https://discuss.elastic.co/t/how-to-re-name-field-names-in-logstash/291803 "2021-12-14T12:51:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anusha\_Kusanghi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anusha_kusanghi/32/98109_2.png) [@Anusha\_Kusanghi](https://discuss.elastic.co/u/Anusha_Kusanghi)\
**Post date:** [December 14, 2021, 12:51pm UTC](https://discuss.elastic.co/t/how-to-re-name-field-names-in-logstash/291803/1 "2021-12-14T12:51:03Z")

</div>

Hi all,  
We have field names like client.geo.name and event.category , how can we re-name the names to this client geo name and event category.  
"[event][category]" =\> "Event category"  
"[client][geo][name]" =\> "client geo location"

We want to achieve this via ruby code

TIA

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [December 14, 2021, 6:08pm UTC](https://discuss.elastic.co/t/how-to-re-name-field-names-in-logstash/291803/2 "2021-12-14T18:08:07Z")

</div>

I already answered that question when you asked it [here](https://discuss.elastic.co/t/how-to-re-name-multiple-field-names-at-once-in-logstash/291599/2).

---

<div class="post-metadata">

**Author:** ![Anusha\_Kusanghi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anusha_kusanghi/32/98109_2.png) [@Anusha\_Kusanghi](https://discuss.elastic.co/u/Anusha_Kusanghi)\
**Post date:** [December 14, 2021, 6:15pm UTC](https://discuss.elastic.co/t/how-to-re-name-field-names-in-logstash/291803/3 "2021-12-14T18:15:07Z")

</div>

but that works only on the first part of the fields (that is there are 2 words in fields[event][category] ) how about 3 words in the fields ([client][geo][name]) and so on.. ?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [December 14, 2021, 6:19pm UTC](https://discuss.elastic.co/t/how-to-re-name-field-names-in-logstash/291803/4 "2021-12-14T18:19:06Z")

</div>

You would have to write a ruby filter that recursively descends into the fields on the event. There is an example of that [here](https://discuss.elastic.co/t/how-to-exclude-xml-json-key-value-if-key-length-is-greater-than-15-char-and-value-length-is-greater-than-100-char/270248/8).

---

<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:** [January 11, 2022, 6:19pm UTC](https://discuss.elastic.co/t/how-to-re-name-field-names-in-logstash/291803/5 "2022-01-11T18:19:57Z")

</div>

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