mirror of https://github.com/grafana/grafana.git
Added override default recipient functionality
This commit is contained in:
parent
658fc1a67a
commit
80fdd830de
|
|
@ -22,9 +22,12 @@ func NewSlackNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
|
||||||
return nil, alerting.ValidationError{Reason: "Could not find url property in settings"}
|
return nil, alerting.ValidationError{Reason: "Could not find url property in settings"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recipient := model.Settings.Get("recipient").MustString()
|
||||||
|
|
||||||
return &SlackNotifier{
|
return &SlackNotifier{
|
||||||
NotifierBase: NewNotifierBase(model.Id, model.IsDefault, model.Name, model.Type, model.Settings),
|
NotifierBase: NewNotifierBase(model.Id, model.IsDefault, model.Name, model.Type, model.Settings),
|
||||||
Url: url,
|
Url: url,
|
||||||
|
Recipient: recipient,
|
||||||
log: log.New("alerting.notifier.slack"),
|
log: log.New("alerting.notifier.slack"),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
@ -32,6 +35,7 @@ func NewSlackNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
|
||||||
type SlackNotifier struct {
|
type SlackNotifier struct {
|
||||||
NotifierBase
|
NotifierBase
|
||||||
Url string
|
Url string
|
||||||
|
Recipient string
|
||||||
log log.Logger
|
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)
|
data, _ := json.Marshal(&body)
|
||||||
cmd := &m.SendWebhookSync{Url: this.Url, Body: string(data)}
|
cmd := &m.SendWebhookSync{Url: this.Url, Body: string(data)}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,13 @@
|
||||||
<span class="gf-form-label width-6">Url</span>
|
<span class="gf-form-label width-6">Url</span>
|
||||||
<input type="text" required class="gf-form-input max-width-30" ng-model="ctrl.model.settings.url" placeholder="Slack incoming webhook url"></input>
|
<input type="text" required class="gf-form-input max-width-30" ng-model="ctrl.model.settings.url" placeholder="Slack incoming webhook url"></input>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="gf-form">
|
||||||
|
<span class="gf-form-label width-6">Recipient</span>
|
||||||
|
<input type="text" class="gf-form-input max-width-30"
|
||||||
|
ng-model="ctrl.model.settings.recipient"
|
||||||
|
placeholder="Override default channel or user, use #channel-name or @username">
|
||||||
|
</input>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="gf-form-group section" ng-if="ctrl.model.type === 'email'">
|
<div class="gf-form-group section" ng-if="ctrl.model.type === 'email'">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue