Skip to content

Conversation

@aa-joshi
Copy link
Contributor

@aa-joshi aa-joshi commented Nov 1, 2025

Previously, we have introduced high cardinality metrics. This patch introduces HighCardinalityMetricOptions to support user defined configurations. It has below fields:
- Metadata: Metadata represents the metadata associated with metrics.
- MaxLabelValues (default: 5000): MaxLabelValues sets the maximum number of distinct label value combinations that can be stored before eviction.
- RetentionTimeTillEviction (default: 20 seconds): specifies the time duration after which unused label value combinations can be evicted. Entries that haven't been accessed for longer than this duration may be evicted.

A label value is removed when number of label values are greater than MaxLabelValues and it has passed the RetentionTimeTillEviction.

This commit also introduces 2 environment variables:
- COCKROACH_HIGH_CARDINALITY_METRICS_MAX_LABEL_VALUES (default:0): The maximum value of the variable and MaxLabelValues is used during initialisation for max label combinations.
- COCKROACH_HIGH_CARDINALITY_METRICS_RETENTION_TIME_TILL_EVICTION (default:10): The maximum value of the variable and RetentionTimeTillEviction is used during initialisation for max retention of a label value.

Epic: CRDB-53398
Part of: CRDB-54635
Release notes: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@aa-joshi aa-joshi force-pushed the CRDB_54635_make_hcm_metrics_configurable branch from ccd6ce8 to cea5c59 Compare November 1, 2025 13:42
@aa-joshi aa-joshi marked this pull request as ready for review November 10, 2025 06:12
@aa-joshi aa-joshi requested review from a team as code owners November 10, 2025 06:12
@aa-joshi aa-joshi requested review from Abhinav1299, arjunmahishi and dhartunian and removed request for a team November 10, 2025 06:12
Previously, we have introduced high cardinality metrics. This patch introduces
`HighCardinalityMetricOptions` to support user defined configurations. It has
below fields:
	- Metadata: Metadata represents the metadata associated with metrics.
	- MaxLabelValues (default: 5000): MaxLabelValues sets the maximum
	  number of distinct label value combinations that can be stored before
	  eviction.
	- RetentionTimeTillEviction (default: 20 seconds): specifies the time
	  duration after which unused label value combinations can be evicted.
	  Entries that haven't been accessed for longer than this duration may
          be evicted.

A label value is removed when number of label values are greater than
MaxLabelValues and it has passed the RetentionTimeTillEviction.

This commit also introduces 2 environment variables:
	- COCKROACH_HIGH_CARDINALITY_METRICS_MAX_LABEL_VALUES (default:0): The
	  maximum value of the variable and `MaxLabelValues` is used during
	  initialisation for max label combinations.
	- COCKROACH_HIGH_CARDINALITY_METRICS_RETENTION_TIME_TILL_EVICTION
	  (default:10): The maximum value of the variable and
	  `RetentionTimeTillEviction` is used during initialisation for max
	   retention of a label.

Epic: CRDB-53398
Part of: CRDB-54635
Release notes: None
@aa-joshi aa-joshi force-pushed the CRDB_54635_make_hcm_metrics_configurable branch from cea5c59 to cfba6ea Compare November 10, 2025 09:36
Copy link
Contributor Author

@aa-joshi aa-joshi left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Abhinav1299, @arjunmahishi, and @dhartunian)

Copy link
Contributor

@Abhinav1299 Abhinav1299 left a comment

Choose a reason for hiding this comment

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

LGTM

@aa-joshi
Copy link
Contributor Author

TFTR!
bors r=[list]

@craig
Copy link
Contributor

craig bot commented Nov 28, 2025

@craig craig bot merged commit 60a9c9e into cockroachdb:master Nov 28, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants