Event get method does not return a json array

I'm using the event api to filter the data collected from various beats.

response

object:

 {
   "a" : "random",
   "b": [
               { 
                  "a1" : "aone"
               }
                ,
               {
                  "a2": "atwo"
                }
          ]
}

when i run some thing like

 filter{
   ruby{
     code => "puts(event.get('[response][b]'))"
       
   }
 
 
 }
it returns {"a1":"aone"}{"a2":"atwo"}
instead of  [{"a1":"aone"},{"a2":"atwo"}]

It does return an array, but puts of an Array does not do what you expect

    ruby {
        code => '
            b = event.get("[response][b]")
            if b.kind_of? Array
                puts "b is an Array"
            end
            puts "puts of b -- "
            puts b
            puts "puts of b.to_s -- "
            puts b.to_s
        '
    }

produces

b is an Array
puts of b --
{"a1"=>"aone"}
{"a2"=>"atwo"}
puts of b.to_s --
[{"a1"=>"aone"}, {"a2"=>"atwo"}]

Oh!, It works!
Thank you!

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