How to do split into array of object

i am new to logstash

my SQL output is like below

FIRSTNAME-----LASTNAME----------PERMISSIONS
jayaraj------------jaganathan----------BLK_RTE_APPRV,PLACE_GPO,ORD_AUTH

i need to convert into

{
"firstName" : "Jayaraj",
"lastName" : "Jaganathan",
"permissionList" : [
{ "name" : "BLK_RTE_APPRV" } ,
{ "name" : "PLACE_GPO" } ,
{ "name" : "ORD_AUTH" }
]
}

i tried multiple options, i din't get desired out put

my .conf look like below

mutate {
split => {"permissions" => ","}
rename => {
"firstname" => "firstName"
"lastname" => "lastName"
}
}

need helpPreformatted text

mutate+split will get you

"permissions" => [
    [0] "BLK_RTE_APPRV",
    [1] "PLACE_GPO",
    [2] "ORD_AUTH"
],

You will have to use ruby to get the format you want.

    ruby {
        code => '
            a = []
            event.get("permissions").each { |x|
                a << { "name" => x }
            }
            event.set("permissionsList", a)
        '
    }

It works , thanks a lot

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