How can I convert a given array structure?


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

I have this structure in my event's JSON.

        "values":{…some more stuff…}
        "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. ]

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)

Thanks a lot @Badger it works.

1 Like

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