Logstash ruby json parser

Hi i am trying to parse a json string in logstash ruby filter.

My logstash ruby code is.
ruby {
code => "jsondata = event.get('[json]')
puts jsondata
jsondata.to_hash
jsondata.each { |key, value|
puts key
puts value
event.set(['json']['#{key}']['command_ip'], key)
}
"
}

and the input json to the ruby is

{
"182.1xx.xx.xx": {
"status": "Failed",
"result": "Error String"
},
"192.1xx.xx.xx": {
"status": "Success"
}
}

and i am expecting the output from this as below

{
"182.1xx.xx.xx": {
"host" : "182.1xx.xx.xx"
"status": "Failed",
"result": "Error String"
},
"192.1xx.xx.xx": {
"host" : "192.1xx.xx.xx"
"status": "Success"
}
}

but when i try to parse the above json i am getting exception saying "Ruby exception occurred: no implicit conversion of String into Integer".

Please help me out to solve this issue. Thanks..

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