diff --git a/CHANGELOG.md b/CHANGELOG.md index 93522b41164..5d72df54773 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## master / unreleased * [FEATURE] Ruler: Add `external_labels` option to tag all alerts with a given set of labels. +* [ENHANCEMENT] Ring: Add `cortex_ring_availability_zone` metric to display which availability zone an instance is configured to run in. #4681 * [CHANGE] Fix incorrectly named `cortex_cache_fetched_keys` and `cortex_cache_hits` metrics. Renamed to `cortex_cache_fetched_keys_total` and `cortex_cache_hits_total` respectively. #4686 ## 1.12.0 in progress diff --git a/pkg/ring/basic_lifecycler.go b/pkg/ring/basic_lifecycler.go index e8bcf8914bb..d7528619aeb 100644 --- a/pkg/ring/basic_lifecycler.go +++ b/pkg/ring/basic_lifecycler.go @@ -92,7 +92,7 @@ func NewBasicLifecycler(cfg BasicLifecyclerConfig, ringName, ringKey string, sto logger: logger, store: store, delegate: delegate, - metrics: NewBasicLifecyclerMetrics(ringName, reg), + metrics: NewBasicLifecyclerMetrics(ringName, cfg.Zone, reg), actorChan: make(chan func()), } diff --git a/pkg/ring/basic_lifecycler_metrics.go b/pkg/ring/basic_lifecycler_metrics.go index 6503baa4a0f..76f1bf9ff34 100644 --- a/pkg/ring/basic_lifecycler_metrics.go +++ b/pkg/ring/basic_lifecycler_metrics.go @@ -9,9 +9,16 @@ type BasicLifecyclerMetrics struct { heartbeats prometheus.Counter tokensOwned prometheus.Gauge tokensToOwn prometheus.Gauge + zoneInfo prometheus.GaugeVec } -func NewBasicLifecyclerMetrics(ringName string, reg prometheus.Registerer) *BasicLifecyclerMetrics { +func NewBasicLifecyclerMetrics(ringName string, zone string, reg prometheus.Registerer) *BasicLifecyclerMetrics { + zoneInfo := promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{ + Name: "ring_availability_zone", + Help: "The availability zone of the instance", + }, []string{"az"}) + zoneInfo.WithLabelValues(zone).Set(1) + return &BasicLifecyclerMetrics{ heartbeats: promauto.With(reg).NewCounter(prometheus.CounterOpts{ Name: "ring_member_heartbeats_total", @@ -28,5 +35,6 @@ func NewBasicLifecyclerMetrics(ringName string, reg prometheus.Registerer) *Basi Help: "The number of tokens to own in the ring.", ConstLabels: prometheus.Labels{"name": ringName}, }), + zoneInfo: *zoneInfo, } }