Interview Prep/Monitoring & Observability/Cardinality Control & Cost

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).

All Monitoring & Observability questions

More on Cardinality Control & Cost