func (s *Schedule) groupActionNotifications(aks []models.AlertKey) (map[*conf.Notification][]*models.IncidentState, error) { groupings := make(map[*conf.Notification][]*models.IncidentState) for _, ak := range aks { alert := s.RuleConf.GetAlert(ak.Name()) status, err := s.DataAccess.State().GetLatestIncident(ak) if err != nil { return nil, err } if alert == nil || status == nil { continue } var n *conf.Notifications if status.WorstStatus == models.StWarning || alert.CritNotification == nil { n = alert.WarnNotification } else { n = alert.CritNotification } if n == nil { continue } nots := n.Get(s.RuleConf, ak.Group()) for _, not := range nots { if !not.RunOnActions { continue } groupings[not] = append(groupings[not], status) } } return groupings, nil }
func (s *Schedule) groupActionNotifications(aks []models.AlertKey) map[*conf.Notification][]*State { groupings := make(map[*conf.Notification][]*State) for _, ak := range aks { alert := s.Conf.Alerts[ak.Name()] status := s.GetStatus(ak) if alert == nil || status == nil { continue } var n *conf.Notifications if status.Status() == StWarning { n = alert.WarnNotification } else { n = alert.CritNotification } if n == nil { continue } nots := n.Get(s.Conf, ak.Group()) for _, not := range nots { if !not.RunOnActions { continue } groupings[not] = append(groupings[not], status) } } return groupings }