Platform
Scrape selective metrics in Prometheus
Recipe to only scrape selective metrics in Prometheus to reduce cardinality
Prometheus provides the ability to filter specific metrics post-scraping, via
the metrics_relabel_config
stanza.
We will use the node_exporter
Prometheus exporter as an example, and send only
metrics matching the regex node_cpu.*
.
Prometheus scrape config without filtering
This scrapes and stores all node exporter metrics.
Prometheus scrape config with filtering
This will scrape all metrics, but drop anything that does not match the entries
in the regex
section.