Not able to get filtered data if i use match labels.

17 views
Skip to first unread message

Kumar

unread,
Jun 19, 2020, 12:14:23 PM6/19/20
to Prometheus Users
Not able to get filtered data if i use match labels.

used query: {__name__=~"memo_.*_memberlist"}, returning below values

memo_01_memberlist{instance="server1",job="x"}0
memo_02_memberlist{instance="server2",job="y"}

if i pass job to query---> {__name__=~"memo_.*_memberlist{job="x"}"}, PQL is not allowing. did anyone resolve to get specific with combination of match labels.

Brian Candler

unread,
Jun 20, 2020, 4:31:31 AM6/20/20
to Prometheus Users
__name__ is a meta-label which you match just like any other label.  To match on two labels at once, you use {foo="a",bar="b"}

In your case it would be:

{__name__=~"memo_.*_memberlist",job="x"}

Note: it's rare in practice that you need to match on the metric name in this way.  It could suggest your metrics are set up wrongly: something which ought to be a label has been put in the metric name.

Kumar

unread,
Jun 23, 2020, 6:30:07 PM6/23/20
to Prometheus Users
thanks , its working now
Reply all
Reply to author
Forward
0 new messages