From 80fdd830de4318c69dce0a7fc9e866cb91b9462b Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Mon, 31 Oct 2016 14:46:51 -0700 Subject: [PATCH 1/3] Added override default recipient functionality --- pkg/services/alerting/notifiers/slack.go | 9 +++++++++ .../features/alerting/partials/notification_edit.html | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/pkg/services/alerting/notifiers/slack.go b/pkg/services/alerting/notifiers/slack.go index 7238af179d7..2248c0bac63 100644 --- a/pkg/services/alerting/notifiers/slack.go +++ b/pkg/services/alerting/notifiers/slack.go @@ -22,9 +22,12 @@ func NewSlackNotifier(model *m.AlertNotification) (alerting.Notifier, error) { return nil, alerting.ValidationError{Reason: "Could not find url property in settings"} } + recipient := model.Settings.Get("recipient").MustString() + return &SlackNotifier{ NotifierBase: NewNotifierBase(model.Id, model.IsDefault, model.Name, model.Type, model.Settings), Url: url, + Recipient: recipient, log: log.New("alerting.notifier.slack"), }, nil } @@ -32,6 +35,7 @@ func NewSlackNotifier(model *m.AlertNotification) (alerting.Notifier, error) { type SlackNotifier struct { NotifierBase Url string + Recipient string log log.Logger } @@ -87,6 +91,11 @@ func (this *SlackNotifier) Notify(evalContext *alerting.EvalContext) error { }, } + //recipient override + if this.Recipient != "" { + body["channel"] = this.Recipient + } + data, _ := json.Marshal(&body) cmd := &m.SendWebhookSync{Url: this.Url, Body: string(data)} diff --git a/public/app/features/alerting/partials/notification_edit.html b/public/app/features/alerting/partials/notification_edit.html index c0bbf49f77b..6e7532a3d24 100644 --- a/public/app/features/alerting/partials/notification_edit.html +++ b/public/app/features/alerting/partials/notification_edit.html @@ -63,6 +63,13 @@ Url +
+ Recipient + + +
From 95117a0bc94568d29d10451a1fddbd19edfdfe0e Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Mon, 31 Oct 2016 14:55:21 -0700 Subject: [PATCH 2/3] Added message parsing functionality --- pkg/services/alerting/notifiers/slack.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/services/alerting/notifiers/slack.go b/pkg/services/alerting/notifiers/slack.go index 2248c0bac63..0e29af39e79 100644 --- a/pkg/services/alerting/notifiers/slack.go +++ b/pkg/services/alerting/notifiers/slack.go @@ -89,6 +89,7 @@ func (this *SlackNotifier) Notify(evalContext *alerting.EvalContext) error { "ts": time.Now().Unix(), }, }, + "parse": "full", // to linkify urls, users and channels in alert message. } //recipient override From 63e2337f6cf88430498fa7fcd4dfc0b04d817ed6 Mon Sep 17 00:00:00 2001 From: bergquist Date: Tue, 1 Nov 2016 08:46:31 +0100 Subject: [PATCH 3/3] feat(alerting): change placeholder to info-popover --- .../alerting/partials/notification_edit.html | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/public/app/features/alerting/partials/notification_edit.html b/public/app/features/alerting/partials/notification_edit.html index 6e7532a3d24..ede9cc247dd 100644 --- a/public/app/features/alerting/partials/notification_edit.html +++ b/public/app/features/alerting/partials/notification_edit.html @@ -59,16 +59,20 @@

Slack settings

-
+
Url
-
+
Recipient - + data-placement="right"> + + Override default channel or user, use #channel-name or <@username></@username> +