# How i can rename dynamical fields

**URL:** https://discuss.elastic.co/t/how-i-can-rename-dynamical-fields/323321
**Category:** Logstash
**Created:** [January 17, 2023, 12:37pm UTC](https://discuss.elastic.co/t/how-i-can-rename-dynamical-fields/323321 "2023-01-17T12:37:12Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Glad](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@Glad](https://discuss.elastic.co/u/Glad)
#### Post date: [January 17, 2023, 12:37pm UTC](https://discuss.elastic.co/t/how-i-can-rename-dynamical-fields/323321/1 "2023-01-17T12:37:12Z")

</div>

Hello, I would like some help with my little problem. I would like to be able to automatically rename fields that I get with my snmp plugin in input.

I obtain this result:

```auto
"host" => [ 
[1] {
      "iso...hrProcessorLoad" => 10
},
[2] {
      "iso...hrProcessorLoad" => 9
}
],

```

At the moment I use this:

```auto
mutate {
                   rename => { "[host][1][iso...hrProcessorLoad]" => ProcessorLoad1
}

```

But I would like to automate this function.

I thank you in advance for your answers

---

<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: [January 18, 2023, 9:47pm UTC](https://discuss.elastic.co/t/how-i-can-rename-dynamical-fields/323321/2 "2023-01-18T21:47:39Z")

</div>

You must use ruby. Check [here](https://discuss.elastic.co/t/how-to-rename-dynamical-fields/207245).

---

<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: [January 19, 2023, 4:13am UTC](https://discuss.elastic.co/t/how-i-can-rename-dynamical-fields/323321/3 "2023-01-19T04:13:37Z")

</div>

If you are not adept at writing ruby you could start with something like

```
    ruby {
        code => '
            h = event.get("host")
            if h and h.respond_to? "each_index"
                h.each_index { |i| event.set("hrProcessorLoad#{i}", h[i]["iso...hrProcessorLoad"]) }
            end
        '
    }

```

---

<div class="post-metadata">

### Author: ![Glad](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@Glad](https://discuss.elastic.co/u/Glad)
#### Post date: [January 19, 2023, 1:55pm UTC](https://discuss.elastic.co/t/how-i-can-rename-dynamical-fields/323321/4 "2023-01-19T13:55:46Z")

</div>

Thank's it works good

---

<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: [February 16, 2023, 1:56pm UTC](https://discuss.elastic.co/t/how-i-can-rename-dynamical-fields/323321/5 "2023-02-16T13:56:16Z")

</div>

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