How can I convert a given array structure?


#1

Hi,

I'm still in the beginning of understanding how to use logstash.

I have this structure in my event's JSON.

"testDetails":[
    {
        "placeholder":"NO_SECURE_FLAG_SET",
        "values":{…some more stuff…}
    },
    {
        "placeholder":"NO_HTTPONLY_FLAG_SET",
        "values":{…some more stuff…}
    },
    …maybe more placeholders…
]

Is there any filter which will allow me to convert this to

"testdetails":[ "NO_SECURE_FLAG_SET", "NO_HTTPONLY_FLAG_SET", …the other "placeholder" values. ]

#2

You could do that using a ruby filter

    ruby {
        code => '
            td = event.get("testDetails")
            if td
                a = []
                td.each { |x|
                    a << x["placeholder"]
                }
                event.set("placeholders", a)
            end
        '
    }

#3

Thanks a lot @Badger it works.


(system) closed #4

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