Drop metrics based on label values

44 views
Skip to first unread message

piyush sharma

unread,
May 11, 2020, 7:26:19 AM5/11/20
to Prometheus Users
Hello ,


I want to achieve one thing . I have a label env which has 2 values prod and stage
I want that if 

env = prod , then metrics should be collected and 
if 
env = stg 

metrics should be dropped. Is there any way I can achieve this ?

I see the example below but it drops metrics based on the label name and not value . I want to drop metric based on label; value.

Matthias Rampke

unread,
May 16, 2020, 5:33:12 PM5/16/20
to piyush sharma, Prometheus Users
The "drop" relabeling action does this. Specify the name of the label under "labels" and the match the value under "regex". For your case,

labels: ['env']
regex: stg
action: drop

should do. You can also go the other way and use

labels: ['env']
regex: prod
action: keep

/MR

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/16222da5-e3bf-4672-a0d8-6d505fcb7587%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages