i have to check the list of values h=[2,3,7,12] in below array
details { a= [1,2,3,4] , b=[5,6,7,8] , c=[9,10] , d=[11,12,13] }
and have to create a new array as below
details_new { a=[2,3] , b=[7], d=[12] }
I am using Ruby code to check
ruby { code => '
i =0
cds = event.get("details")
cds.each do |cnas|
nodel = event.get("cnas")
nodel.each do |cnd|
cnd=event.get("cnode")
if event.get(nodes).include?("cnd")
event.set("[new_cdetails][cds][i]","cnd")
end
i +=1
end
end
'
}
ButI getting this following error
[logstash.filters.ruby ] Ruby exception occurred: undefined method
each' for nil:NilClass`
Please can I any suggestions on this issue.
Thanks in advance!
Elango