Hi im getting the following error in an external ruby code:
Could not process event: undefined method `[]' for nil
not every key in this hash, exist on the data being consumed by logstash, so I added a conditional that check if the "nodo" is empty, if it is empty do nothing, else get the values , but still is not working
def register(params)
end
def filter(event)
grp = {
"b_518" => ["Switch", "XVI", "CHI", "518_CHI","noaplica", "en produccion"],
...(more hashes)....
"b_520" => ["Switch", "XVI", "CHI", "520_CHI","noaplica", "en produccion"],
};
nodo = event.get("node\sname")
if nodo.nil? || nodo.empty?
else
tci = grp[nodo][0]
reg = grp[nodo][1]
comu = grp[nodo][2]
suc = grp[nodo][3]
pro = grp[nodo][4]
sta = grp[nodo][5]
event.set('tipo_ci', tci)
event.set('region', reg)
event.set('comuna', comu)
event.set('sucursal', suc)
event.set('proveedor', pro)
event.set('status', sta)
return [event]
end
end
what Im doing wrong?