Skip to content

Commit fba65a1

Browse files
Update prometheus/alertmanager to version v0.25.1-0.20230203120921-7923bc5f8ec6 (#5276)
Signed-off-by: Krishna Teja Puttagunta <[email protected]> Signed-off-by: Krishna Teja Puttagunta <[email protected]>
1 parent f62815f commit fba65a1

File tree

52 files changed

+2582
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2582
-480
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22

33
## master / unreleased
4+
* [CHANGE] Updating prometheus/alertmanager from v0.25.0 to v0.25.1-0.20230505130626-263ca5c9438e. This includes the below changes. #5276
5+
- Validating new fields on the Webhook AM config, PushOver AM Config and Telegram AM Config.
6+
- filtering 5xx Errors in numTotalFailedNotifications metric.
7+
- Delete silence respond with 404 when silence is not found.
8+
- mark webhook URL as a secret.
49
* [CHANGE] Ruler: Added user label to `cortex_ruler_write_requests_total`, `cortex_ruler_write_requests_failed_total`, `cortex_ruler_queries_total`, and `cortex_ruler_queries_failed_total` metrics. #5312
510
* [CHANGE] Alertmanager: Validating new fields on the PagerDuty AM config. #5290
611
* [CHANGE] Ingester: Creating label `native-histogram-sample` on the `cortex_discarded_samples_total` to keep track of discarded native histogram samples. #5289

go.mod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ require (
4141
github.com/opentracing-contrib/go-stdlib v1.0.0
4242
github.com/opentracing/opentracing-go v1.2.0
4343
github.com/pkg/errors v0.9.1
44-
github.com/prometheus/alertmanager v0.25.0
44+
github.com/prometheus/alertmanager v0.25.1-0.20230505130626-263ca5c9438e
4545
github.com/prometheus/client_golang v1.15.1
4646
github.com/prometheus/client_model v0.3.0
4747
github.com/prometheus/common v0.42.0
@@ -104,7 +104,7 @@ require (
104104
github.com/aws/aws-sdk-go-v2/service/sso v1.11.1 // indirect
105105
github.com/aws/aws-sdk-go-v2/service/sts v1.16.1 // indirect
106106
github.com/aws/smithy-go v1.11.1 // indirect
107-
github.com/benbjohnson/clock v1.3.0 // indirect
107+
github.com/benbjohnson/clock v1.3.3 // indirect
108108
github.com/beorn7/perks v1.0.1 // indirect
109109
github.com/blang/semver/v4 v4.0.0 // indirect
110110
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
@@ -131,7 +131,7 @@ require (
131131
github.com/go-openapi/runtime v0.25.0 // indirect
132132
github.com/go-openapi/spec v0.20.8 // indirect
133133
github.com/go-openapi/validate v0.22.1 // indirect
134-
github.com/gofrs/uuid v4.3.1+incompatible // indirect
134+
github.com/gofrs/uuid v4.4.0+incompatible // indirect
135135
github.com/gogo/googleapis v1.4.0 // indirect
136136
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
137137
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
@@ -149,6 +149,7 @@ require (
149149
github.com/hashicorp/go-multierror v1.1.1 // indirect
150150
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
151151
github.com/hashicorp/golang-lru v0.6.0 // indirect
152+
github.com/hashicorp/golang-lru/v2 v2.0.2 // indirect
152153
github.com/hashicorp/serf v0.10.1 // indirect
153154
github.com/jessevdk/go-flags v1.5.0 // indirect
154155
github.com/jmespath/go-jmespath v0.4.0 // indirect
@@ -179,7 +180,7 @@ require (
179180
github.com/prometheus/exporter-toolkit v0.10.0 // indirect
180181
github.com/prometheus/procfs v0.9.0 // indirect
181182
github.com/redis/rueidis v1.0.2-go1.18 // indirect
182-
github.com/rs/cors v1.8.2 // indirect
183+
github.com/rs/cors v1.9.0 // indirect
183184
github.com/rs/xid v1.4.0 // indirect
184185
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
185186
github.com/sercand/kuberesolver v2.4.0+incompatible // indirect

go.sum

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,8 @@ github.com/aws/smithy-go v1.11.1/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnw
584584
github.com/baidubce/bce-sdk-go v0.9.111 h1:yGgtPpZYUZW4uoVorQ4xnuEgVeddACydlcJKW87MDV4=
585585
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
586586
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
587-
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
588-
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
587+
github.com/benbjohnson/clock v1.3.3 h1:g+rSsSaAzhHJYcIQE78hJ3AhyjjtQvleKDjlhdBnIhc=
588+
github.com/benbjohnson/clock v1.3.3/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
589589
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
590590
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
591591
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
@@ -1025,8 +1025,8 @@ github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x
10251025
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
10261026
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
10271027
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
1028-
github.com/gofrs/uuid v4.3.1+incompatible h1:0/KbAdpx3UXAx1kEOWHJeOkpbgRFGHVgv+CFIY7dBJI=
1029-
github.com/gofrs/uuid v4.3.1+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
1028+
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
1029+
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
10301030
github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
10311031
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
10321032
github.com/gogo/googleapis v1.2.0/go.mod h1:Njal3psf3qN6dwBtQfUmBZh2ybovJ0tlu3o/AC7HYjU=
@@ -1266,6 +1266,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
12661266
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
12671267
github.com/hashicorp/golang-lru v0.6.0 h1:uL2shRDx7RTrOrTCUZEGP/wJUFiUI8QT6E7z5o8jga4=
12681268
github.com/hashicorp/golang-lru v0.6.0/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
1269+
github.com/hashicorp/golang-lru/v2 v2.0.2 h1:Dwmkdr5Nc/oBiXgJS3CDHNhJtIHkuZ3DZF5twqnfBdU=
1270+
github.com/hashicorp/golang-lru/v2 v2.0.2/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
12691271
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
12701272
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
12711273
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
@@ -1675,8 +1677,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
16751677
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
16761678
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
16771679
github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA=
1678-
github.com/prometheus/alertmanager v0.25.0 h1:vbXKUR6PYRiZPRIKfmXaG+dmCKG52RtPL4Btl8hQGvg=
1679-
github.com/prometheus/alertmanager v0.25.0/go.mod h1:MEZ3rFVHqKZsw7IcNS/m4AWZeXThmJhumpiWR4eHU/w=
1680+
github.com/prometheus/alertmanager v0.25.1-0.20230505130626-263ca5c9438e h1:bW60vV2VM/YKsXA6dmb3z5XB9+gh/lQBDiZDVrsDhhA=
1681+
github.com/prometheus/alertmanager v0.25.1-0.20230505130626-263ca5c9438e/go.mod h1:QtbJShIif+fPgjXVPy3mEJaNebBHSU5NkoFtzsUS1c0=
16801682
github.com/prometheus/client_golang v0.0.0-20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
16811683
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
16821684
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
@@ -1753,8 +1755,8 @@ github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
17531755
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
17541756
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
17551757
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
1756-
github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U=
1757-
github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
1758+
github.com/rs/cors v1.9.0 h1:l9HGsTsHJcvW14Nk7J9KFz8bzeAWXn3CG6bgt7LsrAE=
1759+
github.com/rs/cors v1.9.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
17581760
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
17591761
github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY=
17601762
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=

pkg/alertmanager/alertmanager.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -190,22 +190,26 @@ func New(cfg *Config, reg *prometheus.Registry) (*Alertmanager, error) {
190190
am.state = &NilPeer{}
191191
}
192192

193-
am.wg.Add(1)
194193
var err error
195-
am.nflog, err = nflog.New(
196-
nflog.WithRetention(cfg.Retention),
197-
nflog.WithSnapshot(filepath.Join(cfg.TenantDataDir, notificationLogSnapshot)),
198-
nflog.WithMaintenance(maintenancePeriod, am.stop, am.wg.Done, nil),
199-
nflog.WithMetrics(am.registry),
200-
nflog.WithLogger(log.With(am.logger, "component", "nflog")),
201-
)
194+
195+
notificationFile := filepath.Join(cfg.TenantDataDir, notificationLogSnapshot)
196+
am.nflog, err = nflog.New(nflog.Options{
197+
SnapshotFile: notificationFile,
198+
Retention: cfg.Retention,
199+
Logger: log.With(am.logger, "component", "nflog"),
200+
Metrics: am.registry,
201+
})
202+
202203
if err != nil {
203204
return nil, fmt.Errorf("failed to create notification log: %v", err)
204205
}
205-
206206
c := am.state.AddState("nfl:"+cfg.UserID, am.nflog, am.registry)
207207
am.nflog.SetBroadcast(c.Broadcast)
208-
208+
am.wg.Add(1)
209+
go func() {
210+
am.nflog.Maintenance(maintenancePeriod, notificationFile, am.stop, nil)
211+
am.wg.Done()
212+
}()
209213
am.marker = types.NewMarker(am.registry)
210214

211215
silencesFile := filepath.Join(cfg.TenantDataDir, silencesSnapshot)
@@ -218,10 +222,8 @@ func New(cfg *Config, reg *prometheus.Registry) (*Alertmanager, error) {
218222
if err != nil {
219223
return nil, fmt.Errorf("failed to create silences: %v", err)
220224
}
221-
222225
c = am.state.AddState("sil:"+cfg.UserID, am.silences, am.registry)
223226
am.silences.SetBroadcast(c.Broadcast)
224-
225227
// State replication needs to be started after the state keys are defined.
226228
if service, ok := am.state.(services.Service); ok {
227229
if err := service.StartAsync(context.Background()); err != nil {
@@ -320,7 +322,7 @@ func (am *Alertmanager) ApplyConfig(userID string, conf *config.Config, rawCfg s
320322
templateFiles[i] = templateFilepath
321323
}
322324

323-
tmpl, err := template.FromGlobs(templateFiles...)
325+
tmpl, err := template.FromGlobs(templateFiles)
324326
if err != nil {
325327
return err
326328
}
@@ -461,7 +463,7 @@ func (am *Alertmanager) getFullState() (*clusterpb.FullState, error) {
461463

462464
// buildIntegrationsMap builds a map of name to the list of integration notifiers off of a
463465
// list of receiver config.
464-
func buildIntegrationsMap(nc []*config.Receiver, tmpl *template.Template, firewallDialer *util_net.FirewallDialer, logger log.Logger, notifierWrapper func(string, notify.Notifier) notify.Notifier) (map[string][]notify.Integration, error) {
466+
func buildIntegrationsMap(nc []config.Receiver, tmpl *template.Template, firewallDialer *util_net.FirewallDialer, logger log.Logger, notifierWrapper func(string, notify.Notifier) notify.Notifier) (map[string][]notify.Integration, error) {
465467
integrationsMap := make(map[string][]notify.Integration, len(nc))
466468
for _, rcv := range nc {
467469
integrations, err := buildReceiverIntegrations(rcv, tmpl, firewallDialer, logger, notifierWrapper)
@@ -476,7 +478,7 @@ func buildIntegrationsMap(nc []*config.Receiver, tmpl *template.Template, firewa
476478
// buildReceiverIntegrations builds a list of integration notifiers off of a
477479
// receiver config.
478480
// Taken from https://github.com/prometheus/alertmanager/blob/94d875f1227b29abece661db1a68c001122d1da5/cmd/alertmanager/main.go#L112-L159.
479-
func buildReceiverIntegrations(nc *config.Receiver, tmpl *template.Template, firewallDialer *util_net.FirewallDialer, logger log.Logger, wrapper func(string, notify.Notifier) notify.Notifier) ([]notify.Integration, error) {
481+
func buildReceiverIntegrations(nc config.Receiver, tmpl *template.Template, firewallDialer *util_net.FirewallDialer, logger log.Logger, wrapper func(string, notify.Notifier) notify.Notifier) ([]notify.Integration, error) {
480482
var (
481483
errs types.MultiError
482484
integrations []notify.Integration

pkg/alertmanager/api.go

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ var (
4848
errOpsGenieAPIKeyFileNotAllowed = errors.New("setting OpsGenie api_key_file is not allowed")
4949
errPagerDutyRoutingKeyFileNotAllowed = errors.New("setting PagerDuty routing_key_file is not allowed")
5050
errPagerDutyServiceKeyFileNotAllowed = errors.New("setting PagerDuty service_key_file is not allowed")
51+
errWebhookURLFileNotAllowed = errors.New("setting Webhook url_file is not allowed")
52+
errPushOverUserKeyFileNotAllowed = errors.New("setting PushOver user_key_file is not allowed")
53+
errPushOverTokenFileNotAllowed = errors.New("setting PushOver token_file is not allowed")
54+
errTelegramBotTokenFileNotAllowed = errors.New("setting Telegram bot_token_file is not allowed")
5155
)
5256

5357
// UserConfig is used to communicate a users alertmanager configs
@@ -249,7 +253,7 @@ func validateUserConfig(logger log.Logger, cfg alertspb.AlertConfigDesc, limits
249253
templateFiles[i] = filepath.Join(userTempDir, t)
250254
}
251255

252-
_, err = template.FromGlobs(templateFiles...)
256+
_, err = template.FromGlobs(templateFiles)
253257
if err != nil {
254258
return err
255259
}
@@ -363,6 +367,19 @@ func validateAlertmanagerConfig(cfg interface{}) error {
363367
if err := validatePagerdutyConfig(v.Interface().(config.PagerdutyConfig)); err != nil {
364368
return err
365369
}
370+
371+
case reflect.TypeOf(config.WebhookConfig{}):
372+
if err := validateWebhookConfig(v.Interface().(config.WebhookConfig)); err != nil {
373+
return err
374+
}
375+
case reflect.TypeOf(config.PushoverConfig{}):
376+
if err := validatePushOverConfig(v.Interface().(config.PushoverConfig)); err != nil {
377+
return err
378+
}
379+
case reflect.TypeOf(config.TelegramConfig{}):
380+
if err := validateTelegramConfig(v.Interface().(config.TelegramConfig)); err != nil {
381+
return err
382+
}
366383
}
367384

368385
// If the input config is a struct, recursively iterate on all fields.
@@ -488,3 +505,35 @@ func validatePagerdutyConfig(cfg config.PagerdutyConfig) error {
488505

489506
return nil
490507
}
508+
509+
// validateWebhookConfig validates the Webhook config and returns an error if it contains
510+
// settings not allowed by Cortex.
511+
func validateWebhookConfig(cfg config.WebhookConfig) error {
512+
if cfg.URLFile != "" {
513+
return errWebhookURLFileNotAllowed
514+
}
515+
return nil
516+
}
517+
518+
// validatePushOverConfig validates the Pushover Config and returns an error if it contains
519+
// settings not allowed by Cortex.
520+
func validatePushOverConfig(cfg config.PushoverConfig) error {
521+
if cfg.UserKeyFile != "" {
522+
return errPushOverUserKeyFileNotAllowed
523+
}
524+
525+
if cfg.TokenFile != "" {
526+
return errPushOverTokenFileNotAllowed
527+
}
528+
529+
return nil
530+
}
531+
532+
// validateTelegramConfig validates the Telegram Config and returns an error if it contains
533+
// settings not allowed by Cortex.
534+
func validateTelegramConfig(cfg config.TelegramConfig) error {
535+
if cfg.BotTokenFile != "" {
536+
return errTelegramBotTokenFileNotAllowed
537+
}
538+
return nil
539+
}

pkg/alertmanager/api_test.go

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,64 @@ alertmanager_config: |
591591
`,
592592
err: errors.Wrap(errPagerDutyServiceKeyFileNotAllowed, "error validating Alertmanager config"),
593593
},
594+
{
595+
name: "Should return error if Webhook url_file is set",
596+
cfg: `
597+
alertmanager_config: |
598+
receivers:
599+
- name: default-receiver
600+
webhook_configs:
601+
- url_file: /urlFile
602+
603+
route:
604+
receiver: 'default-receiver'
605+
`,
606+
err: errors.Wrap(errWebhookURLFileNotAllowed, "error validating Alertmanager config"),
607+
},
608+
{
609+
name: "Should return error if PushOver user_key_file is set",
610+
cfg: `
611+
alertmanager_config: |
612+
receivers:
613+
- name: default-receiver
614+
pushover_configs:
615+
- user_key_file: /secrets
616+
token: 'token'
617+
618+
route:
619+
receiver: 'default-receiver'
620+
`,
621+
err: errors.Wrap(errPushOverUserKeyFileNotAllowed, "error validating Alertmanager config"),
622+
},
623+
{
624+
name: "Should return error if PushOver token_file is set",
625+
cfg: `
626+
alertmanager_config: |
627+
receivers:
628+
- name: default-receiver
629+
pushover_configs:
630+
- token_file: /secrets
631+
user_key: 'pushover user'
632+
633+
route:
634+
receiver: 'default-receiver'
635+
`,
636+
err: errors.Wrap(errPushOverTokenFileNotAllowed, "error validating Alertmanager config"),
637+
},
638+
{
639+
name: "Should return error if Telegram bot_token_file is set",
640+
cfg: `
641+
alertmanager_config: |
642+
receivers:
643+
- name: default-receiver
644+
telegram_configs:
645+
- chat_id: 5
646+
bot_token_file: /secrets
647+
route:
648+
receiver: 'default-receiver'
649+
`,
650+
err: errors.Wrap(errTelegramBotTokenFileNotAllowed, "error validating Alertmanager config"),
651+
},
594652
}
595653

596654
limits := &mockAlertManagerLimits{}
@@ -810,7 +868,7 @@ func TestValidateAlertmanagerConfig(t *testing.T) {
810868
},
811869
"struct containing *HTTPClientConfig as nested child within a slice": {
812870
input: config.Config{
813-
Receivers: []*config.Receiver{{
871+
Receivers: []config.Receiver{{
814872
Name: "test",
815873
WebhookConfigs: []*config.WebhookConfig{{
816874
HTTPConfig: &commoncfg.HTTPClientConfig{

pkg/alertmanager/multitenant.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ func (am *MultitenantAlertmanager) setConfig(cfg alertspb.AlertConfigDesc) error
911911
return err
912912
}
913913

914-
userAmConfig.Receivers[i].WebhookConfigs[j].URL = &amconfig.URL{URL: u}
914+
userAmConfig.Receivers[i].WebhookConfigs[j].URL = &amconfig.SecretURL{URL: u}
915915
}
916916
}
917917
}

0 commit comments

Comments
 (0)