# How to re-name multiple field names at once in logstash

**URL:** <https://discuss.elastic.co/t/how-to-re-name-multiple-field-names-at-once-in-logstash/291599>\
**Category:** Logstash\
**Created:** [December 13, 2021, 7:41am UTC](https://discuss.elastic.co/t/how-to-re-name-multiple-field-names-at-once-in-logstash/291599 "2021-12-13T07:41:52Z")\
**Posts on this page:** 3\
**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 13, 2021, 7:41am UTC](https://discuss.elastic.co/t/how-to-re-name-multiple-field-names-at-once-in-logstash/291599/1 "2021-12-13T07:41:52Z")

</div>

Hie All,  
I want to rename fields names from this : "[url][path]" =\> to "url path" and "[server][domain]" =\> "Server domain"  
We can use mutate filter plugin (as mutate uses lot of cpu) ,but I have nearly 50 fields names to be renames is their any other alternative to achieve this ?

mutate {  
rename ["[url][path]" =\> "url path",  
"[server][domain]" =\> "Server domain"]  
}

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 13, 2021, 5:45pm UTC](https://discuss.elastic.co/t/how-to-re-name-multiple-field-names-at-once-in-logstash/291599/2 "2021-12-13T17:45:14Z")

</div>

You could do that in a ruby filter

```
    ruby {
        code => '
            event.to_hash.each { |k1, v1|
                if v1.is_a? Hash
                    v1.each { |k2, v2|
                        event.set("#{k1} #{k2}", v2)
                    }
                    event.remove(k1)
                end
            }
        '
    }
```

---

<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 10, 2022, 5:45pm UTC](https://discuss.elastic.co/t/how-to-re-name-multiple-field-names-at-once-in-logstash/291599/3 "2022-01-10T17:45:32Z")

</div>

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