diff --git a/go.mod b/go.mod index 4132199f1eb..35d86dc4984 100644 --- a/go.mod +++ b/go.mod @@ -309,7 +309,7 @@ replace github.com/opentracing-contrib/go-stdlib => github.com/grafana/opentraci replace github.com/opentracing-contrib/go-grpc => github.com/charleskorn/go-grpc v0.0.0-20231024023642-e9298576254f // Replacing prometheus/alertmanager with our fork. -replace github.com/prometheus/alertmanager => github.com/grafana/prometheus-alertmanager v0.25.1-0.20240924175849-b8b7c2c74eb6 +replace github.com/prometheus/alertmanager => github.com/grafana/prometheus-alertmanager v0.25.1-0.20240930132144-b5e64e81e8d3 // Replacing with a fork commit based on v1.17.1 having cherry-picked the following PRs: // - https://github.com/grafana/franz-go/pull/1 diff --git a/go.sum b/go.sum index 1618943aa99..ed243096666 100644 --- a/go.sum +++ b/go.sum @@ -1272,8 +1272,8 @@ github.com/grafana/mimir-prometheus v0.0.0-20241003114040-35ec40c3b27a h1:Thi1mh github.com/grafana/mimir-prometheus v0.0.0-20241003114040-35ec40c3b27a/go.mod h1:oyDm7JaLUh+QGuGkC7iXC8IyTUq5rlh1ba2CRm9DlVg= github.com/grafana/opentracing-contrib-go-stdlib v0.0.0-20230509071955-f410e79da956 h1:em1oddjXL8c1tL0iFdtVtPloq2hRPen2MJQKoAWpxu0= github.com/grafana/opentracing-contrib-go-stdlib v0.0.0-20230509071955-f410e79da956/go.mod h1:qtI1ogk+2JhVPIXVc6q+NHziSmy2W5GbdQZFUHADCBU= -github.com/grafana/prometheus-alertmanager v0.25.1-0.20240924175849-b8b7c2c74eb6 h1:nT8QXdJo6wHMBcF0xEoXxEWkoUZOyzV/jyi/u9l7YEk= -github.com/grafana/prometheus-alertmanager v0.25.1-0.20240924175849-b8b7c2c74eb6/go.mod h1:YeND+6FDA7OuFgDzYODN8kfPhXLCehcpxe4T9mdnpCY= +github.com/grafana/prometheus-alertmanager v0.25.1-0.20240930132144-b5e64e81e8d3 h1:6D2gGAwyQBElSrp3E+9lSr7k8gLuP3Aiy20rweLWeBw= +github.com/grafana/prometheus-alertmanager v0.25.1-0.20240930132144-b5e64e81e8d3/go.mod h1:YeND+6FDA7OuFgDzYODN8kfPhXLCehcpxe4T9mdnpCY= github.com/grafana/pyroscope-go/godeltaprof v0.1.8 h1:iwOtYXeeVSAeYefJNaxDytgjKtUuKQbJqgAIjlnicKg= github.com/grafana/pyroscope-go/godeltaprof v0.1.8/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU= github.com/grafana/regexp v0.0.0-20240531075221-3685f1377d7b h1:oMAq12GxTpwo9jxbnG/M4F/HdpwbibTaVoxNA0NZprY= diff --git a/vendor/github.com/prometheus/alertmanager/api/metrics/metrics.go b/vendor/github.com/prometheus/alertmanager/api/metrics/metrics.go index ea45acc2ee1..2a91911c3d7 100644 --- a/vendor/github.com/prometheus/alertmanager/api/metrics/metrics.go +++ b/vendor/github.com/prometheus/alertmanager/api/metrics/metrics.go @@ -13,7 +13,12 @@ package metrics -import "github.com/prometheus/client_golang/prometheus" +import ( + "github.com/go-kit/log" + "github.com/go-kit/log/level" + + "github.com/prometheus/client_golang/prometheus" +) // Alerts stores metrics for alerts. type Alerts struct { @@ -24,7 +29,7 @@ type Alerts struct { // NewAlerts returns an *Alerts struct for the given API version. // Since v1 was deprecated in 0.28, v2 is now hardcoded. -func NewAlerts(r prometheus.Registerer) *Alerts { +func NewAlerts(r prometheus.Registerer, l log.Logger) *Alerts { numReceivedAlerts := prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "alertmanager_alerts_received_total", Help: "The total number of received alerts.", @@ -36,7 +41,12 @@ func NewAlerts(r prometheus.Registerer) *Alerts { ConstLabels: prometheus.Labels{"version": "v2"}, }) if r != nil { - r.MustRegister(numReceivedAlerts, numInvalidAlerts) + for _, c := range []prometheus.Collector{numReceivedAlerts, numInvalidAlerts} { + r.Unregister(c) + if err := r.Register(c); err != nil { + level.Error(l).Log("msg", "Failed to register collector", "err", err) + } + } } return &Alerts{ firing: numReceivedAlerts.WithLabelValues("firing"), diff --git a/vendor/github.com/prometheus/alertmanager/api/v2/api.go b/vendor/github.com/prometheus/alertmanager/api/v2/api.go index 80babb460b3..4372309e5cf 100644 --- a/vendor/github.com/prometheus/alertmanager/api/v2/api.go +++ b/vendor/github.com/prometheus/alertmanager/api/v2/api.go @@ -100,7 +100,7 @@ func NewAPI( peer: peer, silences: silences, logger: l, - m: metrics.NewAlerts(r), + m: metrics.NewAlerts(r, l), uptime: time.Now(), } diff --git a/vendor/modules.txt b/vendor/modules.txt index 2136cfaeb89..84b219ed9df 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -915,7 +915,7 @@ github.com/pmezard/go-difflib/difflib # github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c ## explicit; go 1.14 github.com/power-devops/perfstat -# github.com/prometheus/alertmanager v0.27.0 => github.com/grafana/prometheus-alertmanager v0.25.1-0.20240924175849-b8b7c2c74eb6 +# github.com/prometheus/alertmanager v0.27.0 => github.com/grafana/prometheus-alertmanager v0.25.1-0.20240930132144-b5e64e81e8d3 ## explicit; go 1.22 github.com/prometheus/alertmanager/api github.com/prometheus/alertmanager/api/metrics @@ -1674,6 +1674,6 @@ sigs.k8s.io/yaml/goyaml.v3 # github.com/munnerz/goautoneg => github.com/grafana/goautoneg v0.0.0-20240607115440-f335c04c58ce # github.com/opentracing-contrib/go-stdlib => github.com/grafana/opentracing-contrib-go-stdlib v0.0.0-20230509071955-f410e79da956 # github.com/opentracing-contrib/go-grpc => github.com/charleskorn/go-grpc v0.0.0-20231024023642-e9298576254f -# github.com/prometheus/alertmanager => github.com/grafana/prometheus-alertmanager v0.25.1-0.20240924175849-b8b7c2c74eb6 +# github.com/prometheus/alertmanager => github.com/grafana/prometheus-alertmanager v0.25.1-0.20240930132144-b5e64e81e8d3 # github.com/twmb/franz-go => github.com/grafana/franz-go v0.0.0-20241009101240-fa97d35e871f # google.golang.org/grpc => google.golang.org/grpc v1.65.0