Hi experts,
Here is a xml parsed data show as below:
"parsed" => {
"PMSetup" => [
[0] {
"startTime" => "2018-03-09T08:40:00.000+01:00",
"interval" => "5",
"PMMOResult" => [
[0] {
"MO" => [
[0] {
"DN" => [
[0] "NTAS-tas01/Host-cbam-4c63de7aeae2460289cd4197dc7-amc-node-0/ContId-8ca345e0f5e4/ContType-amc"
],
"dimension" => "network_element"
}
],
"PMTarget" => [
[0] {
"M2059C3" => [
[0] "3"
],
"M2059C2" => [
[0] "163580"
],
"M2059C1" => [
[0] "4030728"
],
"measurementType" => "CTMEM",
"M2059C4" => [
[0] "3"
]
}
]
},
[1] {
"MO" => [
[0] {
"DN" => [
[0] "NTAS-tas01/Host-cbam-4c63de7aeae2460289cd4197dc7-dtd-node-0/ContId-3929221df021/ContType-dtd"
],
"dimension" => "network_element"
}
],
"PMTarget" => [
[0] {
"M2059C3" => [
[0] "10"
],
"M2059C2" => [
[0] "642744"
],
"M2059C1" => [
[0] "5648712"
],
"measurementType" => "CTMEM",
"M2059C4" => [
[0] "10"
]
}
]
},
[2] {
"MO" => [
[0] {
"DN" => [
[0] "NTAS-tas01/Host-cbam-4c63de7aeae2460289cd4197dc7-oam-node-1/ContId-07f4cdd2c44e/ContType-glsgw"
],
"dimension" => "network_element"
}
],
"PMTarget" => [
[0] {
"M2059C3" => [
[0] "1"
],
"M2059C2" => [
[0] "77263"
],
"M2059C1" => [
[0] "4117041"
],
"measurementType" => "CTMEM",
"M2059C4" => [
[0] "1"
]
}
]
},
[3] {
"MO" => [
[0] {
"DN" => [
[0] "NTAS-tas01/Host-cbam-4c63de7aeae2460289cd4197dc7-oam-node-2/ContId-1e6334140d06/ContType-glsgw"
],
"dimension" => "network_element"
}
],
"PMTarget" => [
[0] {
"M2059C3" => [
[0] "1"
],
"M2059C2" => [
[0] "80325"
],
"M2059C1" => [
[0] "4113979"
],
"measurementType" => "CTMEM",
"M2059C4" => [
[0] "1"
]
}
]
},
],
"version" => "2.3"
}
I want to use ruby code to handle every PMMOResult block, the related ruby code such like this:
if "_xmlparsefailure" not in [tags]{
ruby { code => "
pmMeasInfo = event.get(['parsed']['PMSetup'][0]['PMMOResult'])
pmMeasInfo.each do |pr|
... ...
end
... ...
"}
Then this sentence "pmMeasInfo = event.get(['parsed']['PMSetup'][0]['PMMOResult'])" make the ruby exception result.
[2018-05-14T19:08:18,912][ERROR][logstash.filters.ruby ] Ruby exception occurred: can't convert String into Integer
Experts, would you please help me check this issue? How can I get every data from "PMMOResult", then put them into an array/hash_array?
Thank you.