Added slack mention functionality

This commit is contained in:
utkarshcmu
2016-11-04 06:05:44 -07:00
parent 6fa89456d6
commit 2f60929d1e
2 changed files with 16 additions and 2 deletions
+5 -2
View File
@@ -23,11 +23,13 @@ func NewSlackNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
}
recipient := model.Settings.Get("recipient").MustString()
mention := model.Settings.Get("mention").MustString()
return &SlackNotifier{
NotifierBase: NewNotifierBase(model.Id, model.IsDefault, model.Name, model.Type, model.Settings),
Url: url,
Recipient: recipient,
Mention: mention,
log: log.New("alerting.notifier.slack"),
}, nil
}
@@ -36,6 +38,7 @@ type SlackNotifier struct {
NotifierBase
Url string
Recipient string
Mention string
log log.Logger
}
@@ -70,9 +73,9 @@ func (this *SlackNotifier) Notify(evalContext *alerting.EvalContext) error {
})
}
message := ""
message := this.Mention
if evalContext.Rule.State != m.AlertStateOK { //dont add message when going back to alert state ok.
message = evalContext.Rule.Message
message += " " + evalContext.Rule.Message
}
body := map[string]interface{}{