How do you drop a high-cardinality metric at scrape time?

IntermediateConceptPrometheus Architecture
Answer

Use metric_relabel_configs, which runs after the scrape but before storage:

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

The sample is still transferred over the network but never hits the TSDB. If you can change the app, fixing it at the source is better.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Prometheus Architecture