Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prometheus: how to drop a target based on Consul tags

My Prometheus server gets its list of targets (or "services", in Consul's lingo) from Consul. I only want to monitor a subset of these targets. This should be possible via Prometheus's regex mechanism, but the correct configuration eludes me. How is this done?

like image 620
FuzzyAmi Avatar asked Dec 29 '25 21:12

FuzzyAmi


1 Answers

I've scoured the web and there is not a single example showing how its done, so for posterity - the following configuration will drop all consul services marked with the 'ignore-at-prometheus' tag

# ignore consul services with 'ignore_at_prometheus' tag
# https://www.robustperception.io/little-things-matter/
relabel_configs:
- source_labels: ['__meta_consul_tags']
  regex: '(.*),ignore-at-prometheus,(.*)'
  action: drop
like image 105
FuzzyAmi Avatar answered Jan 01 '26 16:01

FuzzyAmi