# How to rename dynamical fields

**URL:** https://discuss.elastic.co/t/how-to-rename-dynamical-fields/207245
**Category:** Logstash
**Created:** [November 10, 2019, 3:11pm UTC](https://discuss.elastic.co/t/how-to-rename-dynamical-fields/207245 "2019-11-10T15:11:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ja123](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@ja123](https://discuss.elastic.co/u/ja123)
#### Post date: [November 10, 2019, 3:11pm UTC](https://discuss.elastic.co/t/how-to-rename-dynamical-fields/207245/1 "2019-11-10T15:11:39Z")

</div>

I have got the following filterd xml and I would like to rename the field `fpDate` for every single element, but I don't know how to interate through the` [parsed][Journey]`. The size of the `[Journey]` array is always 20 elements.

```
 "parsed" => {
        "Journey" => [
            [0] {
                         "delay" => "+ 89",
                        "fpDate" => "10.11.19"
            },
            [1] {
                         "delay" => "+ 45",
                        "fpDate" => "10.11.19"
            },
            [2] {
                         "delay" => "+ 30",
                        "fpDate" => "10.11.19"
```

---

<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: [November 10, 2019, 4:03pm UTC](https://discuss.elastic.co/t/how-to-rename-dynamical-fields/207245/2 "2019-11-10T16:03:29Z")

</div>

You could iterate over the array using a ruby filter.

```
    ruby {
        code => '
            event.get("[parsed][Journey]").each_index { |x|
                event.set("[parsed][Journey][#{x}][renamed]", event.get("[parsed][Journey][#{x}][fpDate]"))
                event.remove("[parsed][Journey][#{x}][fpDate]")
            }
        '
    }
```

---

<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: [December 8, 2019, 4:07pm UTC](https://discuss.elastic.co/t/how-to-rename-dynamical-fields/207245/3 "2019-12-08T16:07:39Z")

</div>

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