Skip to content

Add cluster label to snapshot metrics - #1238

Open
locker95 wants to merge 1 commit into
prometheus-community:masterfrom
locker95:add-cluster-label-snapshots
Open

Add cluster label to snapshot metrics#1238
locker95 wants to merge 1 commit into
prometheus-community:masterfrom
locker95:add-cluster-label-snapshots

Conversation

@locker95

@locker95 locker95 commented Sep 1, 2026

Copy link
Copy Markdown

This adds a cluster label (the cluster name) to all elasticsearch_snapshot_stats_* metrics, so snapshot metrics from multiple clusters no longer collide.

As sysadmind noted in #629, "#1052 should unblock this support." This PR is a first consumer of that new API: the collector resolves the cluster name via UpdateContext.GetClusterInfo at the start of Update and appends cluster to the existing metric labels, intended as a pattern other collectors can follow. If GetClusterInfo fails the collector returns an error, which goes through the same warn-and-mark-unsuccessful path as any other fetch failure.

The shared test mock now returns a fixed cluster name (test-cluster), and the snapshots test asserts the label on every metric.

Fixes #629

Resolve the cluster name through the UpdateContext introduced in prometheus-community#1052
and attach it as a "cluster" label to all snapshot_stats metrics, so
snapshot metrics from multiple clusters can be told apart.

Fixes prometheus-community#629

Signed-off-by: Dean Chen <862469039@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"cluster" label unavailable for elasticsearch_snaphot_stats_* metrics

1 participant