How to get all metric names from Prometheus server filtered by a particular label

4,655 views
Skip to first unread message

Amey Barve

unread,
Dec 10, 2021, 3:10:51 AM12/10/21
to Prometheus Developers

We want to get all metric names from Prometheus server filtered by a particular label.

Step 1 : Used following query to get all metric names, query succeeded with all metric names.

curl -g 'http://localhost:9090/api/v1/label/__name__/values

Step 2 : Used following query to get all metrics names filtered by label, but query still returned all metric names without filtering those metrics which do not have job label equal to "prometheus"

curl -g 'http://localhost:9090/api/v1/label/__name__/values?match[]={job!="prometheus"}'

Can somebody please help me filter all metric names by label over http? 


Thanks

Ben Kochie

unread,
Dec 10, 2021, 5:18:26 AM12/10/21
to Amey Barve, Prometheus Developers
Your second query is using not-equals. I would expect it to return all metrics names that do not have job="prometheus". Seems to be working correctly.

--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/d1b87f13-e584-49b9-9eee-4526cf6da392n%40googlegroups.com.

Amey Barve

unread,
Dec 10, 2021, 8:05:26 AM12/10/21
to Ben Kochie, Prometheus Developers
The second query still returns the exact same results as that of first even though all the metrics have label job equal to "prometheus".
Correct output would be empty results. 
So it's not working properly. 

Regards, 
Amey 
Reply all
Reply to author
Forward
0 new messages