Unify alerts and alerts notifications format

This commit is contained in:
emanuele-f 2019-07-30 18:12:21 +02:00
parent 115378f8fc
commit ee9e5ec9de
16 changed files with 262 additions and 423 deletions

View file

@ -26,18 +26,20 @@ function syslog.dequeueAlerts(queue)
local alerts_by_types = {}
for _, json_message in ipairs(notifications) do
local notif = alertNotificationToObject(json_message)
local notif = json.decode(json_message)
alerts_by_types[notif.entity_type] = alerts_by_types[notif.entity_type] or {}
alerts_by_types[notif.entity_type][notif.severity] = alerts_by_types[notif.entity_type][notif.severity] or {}
table.insert(alerts_by_types[notif.entity_type][notif.severity], notif)
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
for entity_type, by_severity in pairs(alerts_by_types) do
for _, by_severity in pairs(alerts_by_types) do
for severity, notifications in pairs(by_severity) do
severity = alertSeverityRaw(severity)
-- Most recent notifications first
for _, notif in pairsByValues(notifications, notification_timestamp_rev) do
local syslog_severity = alertLevelToSyslogLevel(notif.severity)
local syslog_severity = alertLevelToSyslogLevel(severity)
local msg