I have a setup as below
source for kvpair: Duration: {2297} | Kernel: {171} | User: {1218}
KVblock is as below
kv {
trim_value => " {}\r\n"
trim_key => " \r\n"
value_split => ":"
field_split => "|"
target => "perf"
source => "kvpairs"
}
I get all required fields to Kibana as below
perf.Duration 2297
perf.Kernel 171
perf.User 1218
perf.type PerfExe
But all these fields are Strings.
Im specifically interested to convert "perf.Duration" to an integer
I learned from Google that below thing is not gonna work
mutate {
convert => {
"perf.Duration" => "integer"
#"Duration" => "integer" <-- Earlier tried this to make sure i dont miss the correct field
}
}
Then I tried few ruby filters as below
ruby {
code => 'event.set("perf.Duration", event.get("perf.Duration").to_i)'
}
Then this
ruby {
code => "
hash = event.to_hash
hash.each { |key,value|
if key == 'Duration'
event.set(value, value.to_i)
end
}
"
}
They didn't work as well.
Can someone help me to get this fixed please.