Commit 72e68645 by Alfred Krohmer Committed by Alfred Krohmer

Add default message for Pushover notifications

If the message field is left empty for Pushover notifications, the API will return an error. This adds a default message if the message would otherwise be empty.

This fixes #8006.
parent 5d70a36a
...@@ -129,6 +129,7 @@ func (this *PushoverNotifier) Notify(evalContext *alerting.EvalContext) error { ...@@ -129,6 +129,7 @@ func (this *PushoverNotifier) Notify(evalContext *alerting.EvalContext) error {
this.log.Error("Failed get rule link", "error", err) this.log.Error("Failed get rule link", "error", err)
return err return err
} }
message := evalContext.Rule.Message message := evalContext.Rule.Message
for idx, evt := range evalContext.EvalMatches { for idx, evt := range evalContext.EvalMatches {
message += fmt.Sprintf("\n<b>%s</b>: %v", evt.Metric, evt.Value) message += fmt.Sprintf("\n<b>%s</b>: %v", evt.Metric, evt.Value)
...@@ -142,6 +143,9 @@ func (this *PushoverNotifier) Notify(evalContext *alerting.EvalContext) error { ...@@ -142,6 +143,9 @@ func (this *PushoverNotifier) Notify(evalContext *alerting.EvalContext) error {
if evalContext.ImagePublicUrl != "" { if evalContext.ImagePublicUrl != "" {
message += fmt.Sprintf("\n<a href=\"%s\">Show graph image</a>", evalContext.ImagePublicUrl) message += fmt.Sprintf("\n<a href=\"%s\">Show graph image</a>", evalContext.ImagePublicUrl)
} }
if message == "" {
message = "Nothing to see here! (Set a notification message to replace this text.)"
}
q := url.Values{} q := url.Values{}
q.Add("user", this.UserKey) q.Add("user", this.UserKey)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment