Store Data in a temporary Variable


(Shabinhashim) #1

HI All,

I have the below filter in logstash

if([orderstatuscode]=="1"){
        mutate{
                add_field => ["status","Accept"]
        }
}
else if([orderstatuscode]=="2"){
        mutate{
                add_field => ["status","Ready"]
        }
}
else if([orderstatuscode]=="7"){
        mutate{
                add_field => ["status","Cancel"]
        }
}

i am checking the value of a field and based on that adding an additional field. Is there a way i can store the value in a temporary field and write the mutate filter once? Something like this,

if([orderstatuscode]=="05"){
       status="Accept"
}
else if([orderstatuscode]=="10"){
     status="Ready"
}

mutate{
add_field => ["status",status]
}

Tried this,but was giving error...


(Magnus B├Ąck) #2

There are no temporary variables similar to what you describe. The closest you get is storing the value in a field under @metadata and at the end copying that value to the final field, but that's hardly very useful.


(system) #3