func MakeIncidentSummary(c conf.RuleConfProvider, s SilenceTester, is *models.IncidentState) (*IncidentSummaryView, error) { alert := c.GetAlert(is.AlertKey.Name()) if alert == nil { return nil, fmt.Errorf("alert %v does not exist in the configuration", is.AlertKey.Name()) } warnNotifications := alert.WarnNotification.Get(c, is.AlertKey.Group()) critNotifications := alert.CritNotification.Get(c, is.AlertKey.Group()) eventSummaries := []EventSummary{} nonNormalNonUnknownCount := 0 for _, event := range is.Events { if event.Status > models.StNormal && event.Status < models.StUnknown { nonNormalNonUnknownCount++ } if eventSummary, unevaluated := MakeEventSummary(event); !unevaluated { eventSummaries = append(eventSummaries, eventSummary) } } actions := make([]EpochAction, len(is.Actions)) for i, action := range is.Actions { actions[i] = MakeEpochAction(action) } subject := is.Subject // There is no rendered subject when the state is unknown and // there is no other non-normal status in the history. if subject == "" && nonNormalNonUnknownCount == 0 { subject = fmt.Sprintf("%s: %v", is.CurrentStatus, is.AlertKey) } return &IncidentSummaryView{ Id: is.Id, Subject: subject, Start: is.Start.Unix(), AlertName: is.AlertKey.Name(), Tags: is.AlertKey.Group(), TagsString: is.AlertKey.Group().String(), CurrentStatus: is.CurrentStatus, WorstStatus: is.WorstStatus, LastAbnormalStatus: is.LastAbnormalStatus, LastAbnormalTime: is.LastAbnormalTime, Unevaluated: is.Unevaluated, NeedAck: is.NeedAck, Silenced: s(is.AlertKey) != nil, Actions: actions, Events: eventSummaries, WarnNotificationChains: conf.GetNotificationChains(c, warnNotifications), CritNotificationChains: conf.GetNotificationChains(c, critNotifications), }, nil }