mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added override default recipient functionality
This commit is contained in:
@@ -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)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user