func (s *Schedule) notify(st *models.IncidentState, n *conf.Notification) { if len(st.EmailSubject) == 0 { st.EmailSubject = []byte(st.Subject) } if len(st.EmailBody) == 0 { st.EmailBody = []byte(st.Body) } n.Notify(st.Subject, st.Body, st.EmailSubject, st.EmailBody, s.SystemConf, string(st.AlertKey), st.Attachments...) }
// utnotify is single notification for N unknown groups into a single notification func (s *Schedule) utnotify(groups map[string]models.AlertKeys, n *conf.Notification) { var total int now := utcNow() for _, group := range groups { // Don't know what the following line does, just copied from unotify s.Group[now] = group total += len(group) } subject := fmt.Sprintf("%v unknown alert instances suppressed", total) body := new(bytes.Buffer) if err := unknownMultiGroup.Execute(body, struct { Groups map[string]models.AlertKeys Threshold int }{ groups, s.SystemConf.GetUnknownThreshold(), }); err != nil { slog.Errorln(err) } n.Notify(subject, body.String(), []byte(subject), body.Bytes(), s.SystemConf, "unknown_treshold") }
func (s *Schedule) unotify(name string, group models.AlertKeys, n *conf.Notification) { subject := new(bytes.Buffer) body := new(bytes.Buffer) now := utcNow() s.Group[now] = group t := s.RuleConf.GetUnknownTemplate() if t == nil { t = defaultUnknownTemplate } data := s.unknownData(now, name, group) if t.Body != nil { if err := t.Body.Execute(body, &data); err != nil { slog.Infoln("unknown template error:", err) } } if t.Subject != nil { if err := t.Subject.Execute(subject, &data); err != nil { slog.Infoln("unknown template error:", err) } } n.Notify(subject.String(), body.String(), subject.Bytes(), body.Bytes(), s.SystemConf, name) }
func (s *Schedule) unotify(name string, group expr.AlertKeys, n *conf.Notification) { subject := new(bytes.Buffer) body := new(bytes.Buffer) now := time.Now().UTC() s.Group[now] = group t := s.Conf.UnknownTemplate if t == nil { t = defaultUnknownTemplate } data := s.unknownData(now, name, group) if t.Body != nil { if err := t.Body.Execute(body, &data); err != nil { log.Println("unknown template error:", err) } } if t.Subject != nil { if err := t.Subject.Execute(subject, &data); err != nil { log.Println("unknown template error:", err) } } n.Notify(subject.String(), body.String(), subject.Bytes(), body.Bytes(), s.Conf, name) }
func (s *Schedule) notify(st *State, n *conf.Notification) { n.Notify(st.Subject, st.Body, st.EmailSubject, st.EmailBody, s.Conf, string(st.AlertKey()), st.Attachments...) }