logstash - How to split a JSON array inside an object -


i have json-message array in array. want split multiple events:

{ "type": "monitor", "server": "10.111.222.333", "host": "abc.de", "bean": [{     "name": "beanname1",     "reseted": "2015-06-05t15:10:00.192z",     "method": [{       "name": "getallxy",       "count": 5,       "min": 3,       "max": 5     },     {       "name": "getname",       "count": 4,       "min": 2,       "max": 4     }]   },   {     "name": "beanname2",     "reseted": "2015-06-05t15:10:00.231z",     "method": [{       "name": "getproperty",       "count": 4,       "min": 3,       "max": 3     }]   },   {     "name": "beanname3",     "reseted": "2015-06-05t15:10:00.231z"   }] } 

using filter split "bean":

input {   stdin {     codec => "json"   } }  filter {   split {     field => "bean"   } }  output {   stdout{codec => "json"} } 

is working well:

{"type":"monitor",  "server":"10.111.222.333",  "host":"abc.de",  "bean":{    "name":"beanname1",    "reseted":"2015-06-05t15:10:00.192z",    "method":[{      "name":"getallxy",      "count":5,      "min":3,      "max":5      },{      "name":"getname",      "count":4,      "min":2,      "max":4     }]},  "@version":"1",  "@timestamp":"2015-07-14t09:21:18.326z" }  {"type":"monitor",  "server":"10.111.222.333",  "host":"abc.de",  "bean":{    "name":"beanname2",    "reseted":"2015-06-05t15:10:00.231z",    "method":[{      "name":"getproperty",      "count":4,      "min":3,      "max":3    }]},  "@version":"1",  "@timestamp":"2015-07-14t09:21:18.326z" }      ... 

to seperate "methods", added split-filter:

  split {     field => "bean"   }   split {     field => "bean.method"   } 

but way error message:

exception in filterworker {"exception"=>#logstash::configurationerror: string , array types splittable. field:bean.method of type = nilclass

i can't access array "method" inside object "bean". tried different notations no luck. possible access array, maybe isn't supported yet?

the following code should want , return 1 event each method:

filter {     if !("splitted_beans" in [tags]) {         json {             source => "message"         }         split {              field => "bean"             add_tag => ["splitted_beans"]         }     }      if ( "splitted_beans" in [tags] , [bean][method] ) {         split {             field => "bean[method]"         }     } } 

the second condition checks if first method successful , if method exists inside bean. works beans without methods well.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -