How to rename dynamical fields

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"

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]")
            }
        '
    }

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