From b1c84c795fd9e195b01ff1d8246fdca1cadd9fe1 Mon Sep 17 00:00:00 2001 From: Ganesh Vernekar <15064823+codesome@users.noreply.github.com> Date: Thu, 8 Apr 2021 22:01:23 +0530 Subject: [PATCH] AlertingNG: Add a global registry for notification channels (#32781) Signed-off-by: Ganesh Vernekar --- pkg/services/ngalert/notifier/alertmanager.go | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pkg/services/ngalert/notifier/alertmanager.go b/pkg/services/ngalert/notifier/alertmanager.go index 95161cb40e5..458c7024d7d 100644 --- a/pkg/services/ngalert/notifier/alertmanager.go +++ b/pkg/services/ngalert/notifier/alertmanager.go @@ -25,6 +25,7 @@ import ( "github.com/grafana/grafana/pkg/infra/log" "github.com/grafana/grafana/pkg/registry" + "github.com/grafana/grafana/pkg/services/alerting" ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models" "github.com/grafana/grafana/pkg/services/ngalert/notifier/channels" "github.com/grafana/grafana/pkg/services/ngalert/store" @@ -305,3 +306,29 @@ func timeoutFunc(d time.Duration) time.Duration { } return d + waitFunc() } + +// GetAvailableNotifiers returns the metadata of all the notification channels that can be configured. +func (am *Alertmanager) GetAvailableNotifiers() []*alerting.NotifierPlugin { + return []*alerting.NotifierPlugin{ + { + Type: "email", + Name: "Email", + Description: "Sends notifications using Grafana server configured SMTP settings", + Heading: "Email settings", + Options: []alerting.NotifierOption{ + { + Label: "Single email", + Description: "Send a single email to all recipients", + Element: alerting.ElementTypeCheckbox, + PropertyName: "singleEmail", + }, { + Label: "Addresses", + Description: "You can enter multiple email addresses using a \";\" separator", + Element: alerting.ElementTypeTextArea, + PropertyName: "addresses", + Required: true, + }, + }, + }, + } +}