diff --git a/Documentation/api.md b/Documentation/api.md index 6d6c257307..b24e3e7190 100644 --- a/Documentation/api.md +++ b/Documentation/api.md @@ -14822,6 +14822,88 @@ int +

DiscordConfig +

+

+(Appears on:Receiver) +

+
+

DiscordConfig configures notifications via Discord. +See https://prometheus.io/docs/alerting/latest/configuration/#discord_config

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+sendResolved
+ +bool + +
+(Optional) +

Whether or not to notify about resolved alerts.

+
+apiURL
+ + +Kubernetes core/v1.SecretKeySelector + + +
+

The secret’s key that contains the Discord webhook URL. +The secret needs to be in the same namespace as the AlertmanagerConfig +object and accessible by the Prometheus Operator.

+
+title
+ +string + +
+(Optional) +
+message
+ +string + +
+(Optional) +
+httpConfig
+ + +HTTPConfig + + +
+(Optional) +

HTTP client configuration.

+

EmailConfig

@@ -15071,7 +15153,7 @@ Duration

HTTPConfig

-(Appears on:OpsGenieConfig, PagerDutyConfig, PushoverConfig, SNSConfig, SlackConfig, TelegramConfig, VictorOpsConfig, WeChatConfig, WebhookConfig) +(Appears on:DiscordConfig, OpsGenieConfig, PagerDutyConfig, PushoverConfig, SNSConfig, SlackConfig, TelegramConfig, VictorOpsConfig, WeChatConfig, WebhookConfig)

HTTPConfig defines a client HTTP configuration. @@ -17412,6 +17494,20 @@ string +discordConfigs
+ + +[]DiscordConfig + + + + +(Optional) +

List of Discord configurations.

+ + + + slackConfigs
@@ -19457,6 +19553,88 @@ int +

DiscordConfig +

+

+(Appears on:Receiver) +

+
+

DiscordConfig configures notifications via Discord. +See https://prometheus.io/docs/alerting/latest/configuration/#discord_config

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+sendResolved
+ +bool + +
+(Optional) +

Whether or not to notify about resolved alerts.

+
+apiURL
+ + +Kubernetes core/v1.SecretKeySelector + + +
+

The secret’s key that contains the Discord webhook URL. +The secret needs to be in the same namespace as the AlertmanagerConfig +object and accessible by the Prometheus Operator.

+
+title
+ +string + +
+(Optional) +
+message
+ +string + +
+(Optional) +
+httpConfig
+ + +HTTPConfig + + +
+(Optional) +

HTTP client configuration.

+

EmailConfig

@@ -19657,7 +19835,7 @@ SafeTLSConfig

HTTPConfig

-(Appears on:OpsGenieConfig, PagerDutyConfig, PushoverConfig, SNSConfig, SlackConfig, TelegramConfig, VictorOpsConfig, WeChatConfig, WebhookConfig) +(Appears on:DiscordConfig, OpsGenieConfig, PagerDutyConfig, PushoverConfig, SNSConfig, SlackConfig, TelegramConfig, VictorOpsConfig, WeChatConfig, WebhookConfig)

HTTPConfig defines a client HTTP configuration. @@ -20855,6 +21033,19 @@ string +discordConfigs
+ + +[]DiscordConfig + + + + +

List of Slack configurations.

+ + + + slackConfigs
diff --git a/pkg/alertmanager/amcfg.go b/pkg/alertmanager/amcfg.go index acd153206a..1968b63cdb 100644 --- a/pkg/alertmanager/amcfg.go +++ b/pkg/alertmanager/amcfg.go @@ -689,13 +689,11 @@ func (cb *configBuilder) convertDiscordConfig(ctx context.Context, in monitoring Message: *in.Message, } - if in.APIURL != nil { - url, err := cb.getValidURLFromSecret(ctx, crKey.Namespace, *in.APIURL) - if err != nil { - return nil, err - } - out.WebhookURL = url + url, err := cb.getValidURLFromSecret(ctx, crKey.Namespace, in.APIURL) + if err != nil { + return nil, err } + out.WebhookURL = url if in.HTTPConfig != nil { httpConfig, err := cb.convertHTTPConfig(ctx, *in.HTTPConfig, crKey) diff --git a/pkg/apis/monitoring/v1alpha1/alertmanager_config_types.go b/pkg/apis/monitoring/v1alpha1/alertmanager_config_types.go index c5d0fa13bc..ac76efc739 100644 --- a/pkg/apis/monitoring/v1alpha1/alertmanager_config_types.go +++ b/pkg/apis/monitoring/v1alpha1/alertmanager_config_types.go @@ -268,8 +268,7 @@ type DiscordConfig struct { // The secret's key that contains the Discord webhook URL. // The secret needs to be in the same namespace as the AlertmanagerConfig // object and accessible by the Prometheus Operator. - // +optional - APIURL *v1.SecretKeySelector `json:"apiURL,omitempty"` + APIURL v1.SecretKeySelector `json:"apiURL,omitempty"` // +optional Title *string `json:"title,omitempty"` // +optional diff --git a/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go index e8dd41452b..4206d07b45 100644 --- a/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go @@ -135,11 +135,7 @@ func (in *DiscordConfig) DeepCopyInto(out *DiscordConfig) { *out = new(bool) **out = **in } - if in.APIURL != nil { - in, out := &in.APIURL, &out.APIURL - *out = new(corev1.SecretKeySelector) - (*in).DeepCopyInto(*out) - } + in.APIURL.DeepCopyInto(&out.APIURL) if in.Title != nil { in, out := &in.Title, &out.Title *out = new(string) diff --git a/pkg/apis/monitoring/v1beta1/alertmanager_config_types.go b/pkg/apis/monitoring/v1beta1/alertmanager_config_types.go index 30136c5600..80db3e664c 100644 --- a/pkg/apis/monitoring/v1beta1/alertmanager_config_types.go +++ b/pkg/apis/monitoring/v1beta1/alertmanager_config_types.go @@ -266,8 +266,7 @@ type DiscordConfig struct { // The secret's key that contains the Discord webhook URL. // The secret needs to be in the same namespace as the AlertmanagerConfig // object and accessible by the Prometheus Operator. - // +optional - APIURL *v1.SecretKeySelector `json:"apiURL,omitempty"` + APIURL v1.SecretKeySelector `json:"apiURL,omitempty"` // +optional Title *string `json:"title,omitempty"` // +optional diff --git a/pkg/apis/monitoring/v1beta1/zz_generated.deepcopy.go b/pkg/apis/monitoring/v1beta1/zz_generated.deepcopy.go index 4eef3681fa..cb7dd4bc84 100644 --- a/pkg/apis/monitoring/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/monitoring/v1beta1/zz_generated.deepcopy.go @@ -21,7 +21,6 @@ package v1beta1 import ( monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" - corev1 "k8s.io/api/core/v1" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ) @@ -135,11 +134,7 @@ func (in *DiscordConfig) DeepCopyInto(out *DiscordConfig) { *out = new(bool) **out = **in } - if in.APIURL != nil { - in, out := &in.APIURL, &out.APIURL - *out = new(corev1.SecretKeySelector) - (*in).DeepCopyInto(*out) - } + in.APIURL.DeepCopyInto(&out.APIURL) if in.Title != nil { in, out := &in.Title, &out.Title *out = new(string)