How do you drop or aggregate metrics you do not need?
IntermediateProductionCardinality Control & Cost
Answer
Drop at scrape time with metric_relabel_configs (after scraping, before storage), or before sending with write_relabel_configs:
metric_relabel_configs:
- source_labels: [__name__]
regex: 'apiserver_request_duration_seconds_bucket|etcd_request_duration_seconds_bucket'
action: drop
- regex: 'pod_template_hash|controller_revision_hash'
action: labeldrop
For vendors, Grafana Cloud Adaptive Metrics and Datadog Metrics without Limits aggregate away unused labels server-side. Always check dashboards and alerts before dropping (Grafana's mimirtool analyze lists used metrics).
More on Cardinality Control & Cost
What is cardinality and why is it the main cost driver for metrics?BeginnerHow do you find which metrics and labels are driving cardinality?IntermediateWhich labels should never appear on metrics?BeginnerHow do you enforce cardinality limits so one team cannot blow up the shared system?AdvancedHow do histograms affect cardinality, and how do you control it?IntermediateHow do you estimate the monthly cost of a new metric before it ships?Intermediate