Fix alert_endpoints/{syslog.lua,slack.lua} error 'attempt to index a nil value'

This commit is contained in:
Alfredo Cardigliano 2019-09-04 12:57:57 +02:00
parent 14c0338b64
commit 40bf86a81d
2 changed files with 11 additions and 9 deletions

View file

@ -26,11 +26,12 @@ function syslog.dequeueAlerts(queue)
local alerts_by_types = {}
for _, json_message in ipairs(notifications) do
local notif = json.decode(json_message)
alerts_by_types[notif.alert_entity] = alerts_by_types[notif.alert_entity] or {}
alerts_by_types[notif.alert_entity][notif.alert_severity] = alerts_by_types[notif.alert_entity][notif.alert_severity] or {}
table.insert(alerts_by_types[notif.alert_entity][notif.alert_severity], notif)
local notif = json.decode(json_message)
if notif.alert_entity then
alerts_by_types[notif.alert_entity] = alerts_by_types[notif.alert_entity] or {}
alerts_by_types[notif.alert_entity][notif.alert_severity] = alerts_by_types[notif.alert_entity][notif.alert_severity] or {}
table.insert(alerts_by_types[notif.alert_entity][notif.alert_severity], notif)
end
end
for _, by_severity in pairs(alerts_by_types) do