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.
More on Prometheus Architecture
Describe the Prometheus architecture.BeginnerWhat does a basic prometheus.yml look like?BeginnerWhat is the `up` metric?BeginnerWhat are `job` and `instance` labels and where do they come from?BeginnerHow is the Prometheus TSDB organized on disk?AdvancedWhat is the WAL and why does Prometheus restart slowly sometimes?Advanced