diff --git a/docs/sources/administration/provisioning.md b/docs/sources/administration/provisioning.md
index 7b61cd6fbb7..381247b3db6 100755
--- a/docs/sources/administration/provisioning.md
+++ b/docs/sources/administration/provisioning.md
@@ -398,6 +398,8 @@ The following sections detail the supported settings for each alert notification
| Name |
| ---- |
| url |
+| basicAuthUser |
+| basicAuthPassword |
#### Alert notification `teams`
diff --git a/pkg/services/alerting/notifiers/alertmanager.go b/pkg/services/alerting/notifiers/alertmanager.go
index 63f34f579ab..66625d06084 100644
--- a/pkg/services/alerting/notifiers/alertmanager.go
+++ b/pkg/services/alerting/notifiers/alertmanager.go
@@ -20,9 +20,18 @@ func init() {
Factory: NewAlertmanagerNotifier,
OptionsTemplate: `
Alertmanager settings
-
`,
})
@@ -34,19 +43,25 @@ func NewAlertmanagerNotifier(model *models.AlertNotification) (alerting.Notifier
if url == "" {
return nil, alerting.ValidationError{Reason: "Could not find url property in settings"}
}
+ basicAuthUser := model.Settings.Get("basicAuthUser").MustString()
+ basicAuthPassword := model.Settings.Get("basicAuthPassword").MustString()
return &AlertmanagerNotifier{
- NotifierBase: NewNotifierBase(model),
- URL: url,
- log: log.New("alerting.notifier.prometheus-alertmanager"),
+ NotifierBase: NewNotifierBase(model),
+ URL: url,
+ BasicAuthUser: basicAuthUser,
+ BasicAuthPassword: basicAuthPassword,
+ log: log.New("alerting.notifier.prometheus-alertmanager"),
}, nil
}
// AlertmanagerNotifier sends alert notifications to the alert manager
type AlertmanagerNotifier struct {
NotifierBase
- URL string
- log log.Logger
+ URL string
+ BasicAuthUser string
+ BasicAuthPassword string
+ log log.Logger
}
// ShouldNotify returns true if the notifiers should be used depending on state
@@ -140,6 +155,8 @@ func (am *AlertmanagerNotifier) Notify(evalContext *alerting.EvalContext) error
cmd := &models.SendWebhookSync{
Url: am.URL + "/api/v1/alerts",
+ User: am.BasicAuthUser,
+ Password: am.BasicAuthPassword,
HttpMethod: "POST",
Body: string(body),
}