Skip to content

Commit 5e496f4

Browse files
authored
Update alertmanager (#3903)
* Update Alertmanager dependency to master The biggest changes are time-based muting and the inclusion of interfaces for the clustering logic. The latter supports the Alertmanager replication via the ring. Signed-off-by: gotjosh <[email protected]> * Use NilPeer for the API clustering interface. We don't want to expose information about the cluster back to tenants. Signed-off-by: gotjosh <[email protected]> * gofmt fails me Signed-off-by: gotjosh <[email protected]>
1 parent f25e0b5 commit 5e496f4

File tree

33 files changed

+1459
-410
lines changed

33 files changed

+1459
-410
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## master / unreleased
44

5+
* [CHANGE] Alertmanager: Don't expose cluster information to tenants via the `/alertmanager/api/v1/status` API endpoint when operating with clustering enabled.
56
* [CHANGE] Ingester: don't update internal "last updated" timestamp of TSDB if tenant only sends invalid samples. This affects how "idle" time is computed. #3727
67
* [CHANGE] Require explicit flag `-<prefix>.tls-enabled` to enable TLS in GRPC clients. Previously it was enough to specify a TLS flag to enable TLS validation. #3156
78
* [CHANGE] Query-frontend: removed `-querier.split-queries-by-day` (deprecated in Cortex 0.4.0). You should use `-querier.split-queries-by-interval` instead. #3813

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ require (
4343
github.com/opentracing-contrib/go-stdlib v1.0.0
4444
github.com/opentracing/opentracing-go v1.2.0
4545
github.com/pkg/errors v0.9.1
46-
github.com/prometheus/alertmanager v0.21.1-0.20201106142418-c39b78780054
46+
github.com/prometheus/alertmanager v0.21.1-0.20210303154452-7866b9bb0927
4747
github.com/prometheus/client_golang v1.9.0
4848
github.com/prometheus/client_model v0.2.0
49-
github.com/prometheus/common v0.15.0
49+
github.com/prometheus/common v0.18.0
5050
github.com/prometheus/prometheus v1.8.2-0.20210215121130-6f488061dfb4
5151
github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e
5252
github.com/sony/gobreaker v0.4.1

go.sum

+5
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,8 @@ github.com/prometheus/alertmanager v0.21.0/go.mod h1:h7tJ81NA0VLWvWEayi1QltevFkL
10871087
github.com/prometheus/alertmanager v0.21.1-0.20200911160112-1fdff6b3f939/go.mod h1:imXRHOP6QTsE0fFsIsAV/cXimS32m7gVZOiUj11m6Ig=
10881088
github.com/prometheus/alertmanager v0.21.1-0.20201106142418-c39b78780054 h1:NgCRBfzDpyIhX6Pjh7XSWPHUC8T5dA1yVuK/gwXM7Jw=
10891089
github.com/prometheus/alertmanager v0.21.1-0.20201106142418-c39b78780054/go.mod h1:imXRHOP6QTsE0fFsIsAV/cXimS32m7gVZOiUj11m6Ig=
1090+
github.com/prometheus/alertmanager v0.21.1-0.20210303154452-7866b9bb0927 h1:BLdqq8kRvpCWghcXjU32mi4pzJlyo8InM5hfmIqFyoc=
1091+
github.com/prometheus/alertmanager v0.21.1-0.20210303154452-7866b9bb0927/go.mod h1:MTqVn+vIupE0dzdgo+sMcNCp37SCAi8vPrvKTTnTz9g=
10901092
github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
10911093
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
10921094
github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM=
@@ -1133,6 +1135,9 @@ github.com/prometheus/common v0.14.0 h1:RHRyE8UocrbjU+6UvRzwi6HjiDfxrrBU91TtbKzk
11331135
github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
11341136
github.com/prometheus/common v0.15.0 h1:4fgOnadei3EZvgRwxJ7RMpG1k1pOZth5Pc13tyspaKM=
11351137
github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
1138+
github.com/prometheus/common v0.18.0 h1:WCVKW7aL6LEe1uryfI9dnEc2ZqNB1Fn0ok930v0iL1Y=
1139+
github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
1140+
github.com/prometheus/exporter-toolkit v0.5.0/go.mod h1:OCkM4805mmisBhLmVFw858QYi3v0wKdY6/UxrT0pZVg=
11361141
github.com/prometheus/exporter-toolkit v0.5.1/go.mod h1:OCkM4805mmisBhLmVFw858QYi3v0wKdY6/UxrT0pZVg=
11371142
github.com/prometheus/node_exporter v1.0.0-rc.0.0.20200428091818-01054558c289 h1:dTUS1vaLWq+Y6XKOTnrFpoVsQKLCbCp1OLj24TDi7oM=
11381143
github.com/prometheus/node_exporter v1.0.0-rc.0.0.20200428091818-01054558c289/go.mod h1:FGbBv5OPKjch+jNUJmEQpMZytIdyW0NdBtWFcfSKusc=

pkg/alertmanager/alertmanager.go

+25-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/prometheus/alertmanager/provider/mem"
3333
"github.com/prometheus/alertmanager/silence"
3434
"github.com/prometheus/alertmanager/template"
35+
"github.com/prometheus/alertmanager/timeinterval"
3536
"github.com/prometheus/alertmanager/types"
3637
"github.com/prometheus/alertmanager/ui"
3738
"github.com/prometheus/client_golang/prometheus"
@@ -161,7 +162,7 @@ func New(cfg *Config, reg *prometheus.Registry) (*Alertmanager, error) {
161162
Alerts: am.alerts,
162163
Silences: am.silences,
163164
StatusFunc: am.marker.Status,
164-
Peer: cfg.Peer,
165+
Peer: &NilPeer{},
165166
Registry: am.registry,
166167
Logger: log.With(am.logger, "component", "api"),
167168
GroupFunc: func(f1 func(*dispatch.Route) bool, f2 func(*types.Alert, time.Time) bool) (dispatch.AlertGroups, map[model.Fingerprint][]string) {
@@ -242,11 +243,17 @@ func (am *Alertmanager) ApplyConfig(userID string, conf *config.Config, rawCfg s
242243
return nil
243244
}
244245

246+
muteTimes := make(map[string][]timeinterval.TimeInterval, len(conf.MuteTimeIntervals))
247+
for _, ti := range conf.MuteTimeIntervals {
248+
muteTimes[ti.Name] = ti.TimeIntervals
249+
}
250+
245251
pipeline := am.pipelineBuilder.New(
246252
integrationsMap,
247253
waitFunc,
248254
am.inhibitor,
249255
silence.NewSilencer(am.silences, am.marker, am.logger),
256+
muteTimes,
250257
am.nflog,
251258
am.cfg.Peer,
252259
)
@@ -355,3 +362,20 @@ func md5HashAsMetricValue(data []byte) float64 {
355362
copy(bytes, smallSum)
356363
return float64(binary.LittleEndian.Uint64(bytes))
357364
}
365+
366+
// NilPeer and NilChannel implements the Alertmanager clustering interface used by the API to expose cluster information.
367+
// In a multi-tenant environment, we choose not to expose these to tenants and thus are not implemented.
368+
type NilPeer struct{}
369+
370+
func (p *NilPeer) Name() string { return "" }
371+
func (p *NilPeer) Status() string { return "ready" }
372+
func (p *NilPeer) Peers() []cluster.ClusterMember { return nil }
373+
func (p *NilPeer) Position() int { return 0 }
374+
func (p *NilPeer) WaitReady() {}
375+
func (p *NilPeer) AddState(string, cluster.State, prometheus.Registerer) cluster.ClusterChannel {
376+
return &NilChannel{}
377+
}
378+
379+
type NilChannel struct{}
380+
381+
func (c *NilChannel) Broadcast([]byte) {}

vendor/github.com/prometheus/alertmanager/api/api.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/prometheus/alertmanager/api/v1/api.go

+24-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/prometheus/alertmanager/api/v2/api.go

+57-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/prometheus/alertmanager/api/v2/models/matcher.go

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/prometheus/alertmanager/api/v2/openapi.yaml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/prometheus/alertmanager/api/v2/restapi/embedded_spec.go

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/prometheus/alertmanager/asset/assets_vfsdata.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/prometheus/alertmanager/cluster/channel.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)