Hello,
I have spent all day trying to do this, but I am pretty sure that a) not knowing enough ruby and b) not being familiar enough wth logstash is killing me.
I am running logstash 6.1 on ubuntu 16.04LTS server.
I have the following json data fragment
{    "events": [{
    "attributes": [{
        "name": "messageId",
        "value": "30797758",
        "type": "number",
        "isSync": false
    }, {
        "name": "reportId",
        "value": "1142603714",
        "type": "number",
        "isSync": false
}]
}] 
}
I wish to produce something more like this:
"attributes" => {
   "messageId" => 30797758,
   "reportId" => 1142603714
}
Note how I transpose for each element of "attributes" that "name" becomes the key and "value" becomes the value of the key "name".
I am trying to do it with a ruby filter using the logstash config:
input { codec=>json } 
filter{ 
    json { source=>"message" 
    ruby {
        code=>'
            things=event.get("[events][0][attributes]")
            newhash={}
            if things.is_a?(Array)
                things.each{ |attr| newhash[attr["name"] => attr["value"]]}
            end
    event.set("[newhash]", newhash )
    '
} 
output { codec => rubydebug } 
the trouble is newhash doesn't show anything:
"newhash"  => {},
instead of the things.each line, I have tried various versions of:
	    things.each{ |attr| event.set{[attributes2][#{attr["name"]}], attr["value"]  } }
but here I just get an error.
I am not at wits end, but I thought I would give it a go before I wrote here.
Does anyone have any suggestions?
Thanks in advance...
--jason
