From d553a016cce2262898806a11e95400bee1dea315 Mon Sep 17 00:00:00 2001 From: Ghazanfar Date: Sat, 14 Jan 2023 04:15:43 +0530 Subject: [PATCH] Alerting: UI changes required to support v3 and Auth in Kafka Contact Point (#61123) --- .../channels_config/available_channels.go | 48 +++++++++++++++++++ .../notifier/channels_config/plugin.go | 2 + 2 files changed, 50 insertions(+) diff --git a/pkg/services/ngalert/notifier/channels_config/available_channels.go b/pkg/services/ngalert/notifier/channels_config/available_channels.go index 9cd228a5f55..82d1a68df98 100644 --- a/pkg/services/ngalert/notifier/channels_config/available_channels.go +++ b/pkg/services/ngalert/notifier/channels_config/available_channels.go @@ -163,6 +163,7 @@ func GetAvailableNotifiers() []*NotifierPlugin { Label: "Kafka REST Proxy", Element: ElementTypeInput, InputType: InputTypeText, + Description: "Hint: If you are directly using v3 APIs hosted on a Confluent Kafka Server, you must append /kafka to the URL here. Example: https://localhost:8082/kafka", Placeholder: "http://localhost:8082", PropertyName: "kafkaRestProxy", Required: true, @@ -175,6 +176,53 @@ func GetAvailableNotifiers() []*NotifierPlugin { PropertyName: "kafkaTopic", Required: true, }, + { + Label: "Username", + Element: ElementTypeInput, + InputType: InputTypeText, + PropertyName: "username", + Required: false, + }, + { + Label: "Password", + Element: ElementTypeInput, + InputType: InputTypePassword, + Description: "The password to use when making a call to the Kafka REST Proxy", + PropertyName: "password", + Required: false, + Secure: true, + }, + { + Label: "API version", + Element: ElementTypeSelect, + InputType: InputTypeText, + Description: "The API version to use when contacting the Kafka REST Server. By default v2 will be used.", + PropertyName: "apiVersion", + Required: false, + SelectOptions: []SelectOption{ + { + Value: "v2", + Label: "v2", + }, + { + Value: "v3", + Label: "v3", + }, + }, + }, + { + Label: "Cluster ID", + Element: ElementTypeInput, + InputType: InputTypeText, + Description: "v3 APIs require a clusterID to be specified.", + Placeholder: "lkc-abcde", + PropertyName: "kafkaClusterId", + Required: true, + ShowWhen: ShowWhen{ + Field: "apiVersion", + Is: "v3", + }, + }, { Label: "Description", Element: ElementTypeInput, diff --git a/pkg/services/ngalert/notifier/channels_config/plugin.go b/pkg/services/ngalert/notifier/channels_config/plugin.go index a53b7b2b818..aa770e0c49a 100644 --- a/pkg/services/ngalert/notifier/channels_config/plugin.go +++ b/pkg/services/ngalert/notifier/channels_config/plugin.go @@ -57,6 +57,8 @@ type SelectOption struct { } // ShowWhen holds information about when options are dependant on other options. +// Should be used when Element is ElementTypeSelect. +// Does not work for ElementTypeCheckbox. type ShowWhen struct { Field string `json:"field"` Is string `json:"is"`