Skip to content

Add SeriesLabelsDeduplicated metrics#14382

Open
lamida wants to merge 10 commits intomainfrom
lamida/labels-deduplicates-metrics
Open

Add SeriesLabelsDeduplicated metrics#14382
lamida wants to merge 10 commits intomainfrom
lamida/labels-deduplicates-metrics

Conversation

@lamida
Copy link
Contributor

@lamida lamida commented Feb 16, 2026

Follow up #14148. Add metrics on SeriesLabelsDeduplicator so that we can measure the impact better.

More context in MQE sync 17 Feb 2026 note.

What this PR does

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]. If changelog entry is not needed, please add the changelog-not-needed label to the PR.
  • about-versioning.md updated with experimental features.

Note

Low Risk
Instrumentation-only change that adds counters and updates call sites to pass a registerer; main risk is minor metric/registry wiring issues in tests or embedded-querier deployments.

Overview
Adds Prometheus counters to SeriesLabelsDeduplicator to track how many series labels are processed vs deduplicated (cortex_querier_labels_deduplicator_processed_total, ..._deduplicated_total).

Threads a shared metrics instance through ContextWithNewSeriesLabelsDeduplicator and NewMemoryTrackingQueryable, updates affected tests/benchmarks to provide a registry, and adjusts integration metric-prefix assertions to ignore these new cortex_querier_* metrics when also exposed by embedded-querier Ruler.

Written by Cursor Bugbot for commit ebb0b80. This will update automatically on new commits. Configure here.

@lamida lamida added the changelog-not-needed PRs that don't need a CHANGELOG.md entry label Feb 16, 2026
@lamida lamida marked this pull request as ready for review February 16, 2026 15:16
@lamida lamida requested a review from a team as a code owner February 16, 2026 15:16
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is ON. A Cloud Agent has been kicked off to fix the reported issue.

@cursor
Copy link

cursor bot commented Feb 16, 2026

Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.

  • ✅ Fixed: Ignored prefixes ordered after broad matcher
    • Moved the ignore prefixes !cortex_querier_series_labels_total and !cortex_querier_series_labels_deduplicated_total before the broad cortex_querier matcher so they are evaluated first.

Create PR

Or push these changes by commenting:

@cursor push 10e282d7fe
Preview (10e282d7fe)
diff --git a/integration/asserts.go b/integration/asserts.go
--- a/integration/asserts.go
+++ b/integration/asserts.go
@@ -35,7 +35,7 @@
 	serviceMetricsPrefixes = map[ServiceType][]string{
 		Distributor:    {},
 		Ingester:       {"!cortex_ingester_client", "cortex_ingester"},                                                                                                                                                                              // The metrics prefix cortex_ingester_client may be used by other components so we ignore it.
-		Querier:        {"!cortex_querier_storegateway", "!cortex_querier_blocks", "!cortex_querier_queries", "!cortex_querier_query", "cortex_querier", "!cortex_querier_series_labels_total", "!cortex_querier_series_labels_deduplicated_total"}, // The metrics prefix cortex_querier_storegateway, cortex_querier_blocks, cortex_querier_queries, cortex_querier_query, cortex_querier_series_labels_total, and cortex_querier_series_labels_deduplicated_total may be used by other components so we ignore it.
+		Querier:        {"!cortex_querier_storegateway", "!cortex_querier_blocks", "!cortex_querier_queries", "!cortex_querier_query", "!cortex_querier_series_labels_total", "!cortex_querier_series_labels_deduplicated_total", "cortex_querier"}, // The metrics prefix cortex_querier_storegateway, cortex_querier_blocks, cortex_querier_queries, cortex_querier_query, cortex_querier_series_labels_total, and cortex_querier_series_labels_deduplicated_total may be used by other components so we ignore it.
 		QueryFrontend:  {"cortex_frontend", "cortex_query_frontend"},
 		QueryScheduler: {"cortex_query_scheduler"},
 		AlertManager:   {"cortex_alertmanager"},

Ingester: {"!cortex_ingester_client", "cortex_ingester"}, // The metrics prefix cortex_ingester_client may be used by other components so we ignore it.
Querier: {"!cortex_querier_storegateway", "!cortex_querier_blocks", "!cortex_querier_queries", "!cortex_querier_query", "cortex_querier"}, // The metrics prefix cortex_querier_storegateway, cortex_querier_blocks, cortex_querier_queries, and cortex_querier_query may be used by other components so we ignore it.
Ingester: {"!cortex_ingester_client", "cortex_ingester"}, // The metrics prefix cortex_ingester_client may be used by other components so we ignore it.
Querier: {"!cortex_querier_storegateway", "!cortex_querier_blocks", "!cortex_querier_queries", "!cortex_querier_query", "!cortex_querier_series_labels_total", "!cortex_querier_series_labels_deduplicated_total", "cortex_querier"}, // The metrics prefix cortex_querier_storegateway, cortex_querier_blocks, cortex_querier_queries, cortex_querier_query, cortex_querier_series_labels_total, and cortex_querier_series_labels_deduplicated_total may be used by other components so we ignore it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What other component would see the new metrics? The ruler?

Copy link
Contributor Author

@lamida lamida Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we added !cortex_querier_series_labels_total", "!cortex_querier_series_labels_deduplicated_total" on that line 38 because Ruler component also can use it when using embedded mode querier.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a comment here explaining that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in the last two commits

@lamida lamida requested a review from charleskorn February 19, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-not-needed PRs that don't need a CHANGELOG.md entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments