Prometheus Query help

32 views
Skip to first unread message

Meher Garda

unread,
Mar 14, 2017, 12:15:36 PM3/14/17
to Prometheus Users
Hi

We have a service setup in active/passive mode.

Each service spits out two metrics, lock_state and request_process_time

both these metrics have the following common labels: env (dev or qa or prod) , instance (instance ip) , stack (consul service name )

With query 

lock_state{stack=~"failoversvc.*"} == 1 , I can find out which instance has the lock and is active

With query

request_process_time{stack=~"failoversvc.*"} , I can get the value for this metric


Is it possible, to run the second query only for the instance which has the lock ?


Brian Brazil

unread,
Mar 14, 2017, 12:35:41 PM3/14/17
to Meher Garda, Prometheus Users
request_process_time{stack=~"failoversvc.*"} and lock_state{stack=~"failoversvc.*"} == 1

--

Meher Garda

unread,
Mar 14, 2017, 12:44:18 PM3/14/17
to Prometheus Users, meher...@gmail.com
Hi Brian

Thanx , i kinda got to the same query but im seeing something weird.

request_process_time{stack=~"failoversvc.*"} and lock_state{stack=~"failoversvc.*"} == 1        <------- this gives me no result


But

request_process_time{stack=~"failoversvc.*"} and on (stack,instance) lock_state{stack=~"failoversvc.*"} == 1    <------ gives me data


Can you help me understand what is keyword `on` doing or what is it adding to the mix?


Regards

Brian Brazil

unread,
Mar 14, 2017, 12:47:04 PM3/14/17
to Meher Garda, Prometheus Users
On 14 March 2017 at 16:44, Meher Garda <meher...@gmail.com> wrote:
Hi Brian

Thanx , i kinda got to the same query but im seeing something weird.

request_process_time{stack=~"failoversvc.*"} and lock_state{stack=~"failoversvc.*"} == 1        <------- this gives me no result


But

request_process_time{stack=~"failoversvc.*"} and on (stack,instance) lock_state{stack=~"failoversvc.*"} == 1    <------ gives me data


Can you help me understand what is keyword `on` doing or what is it adding to the mix?

I'd guess that there's other labels in play than the ones you listed, and this is causing them not to be considered.

Brian
 


Regards

On Tuesday, March 14, 2017 at 9:35:41 AM UTC-7, Brian Brazil wrote:
On 14 March 2017 at 16:15, Meher Garda <meher...@gmail.com> wrote:
Hi

We have a service setup in active/passive mode.

Each service spits out two metrics, lock_state and request_process_time

both these metrics have the following common labels: env (dev or qa or prod) , instance (instance ip) , stack (consul service name )

With query 

lock_state{stack=~"failoversvc.*"} == 1 , I can find out which instance has the lock and is active

With query

request_process_time{stack=~"failoversvc.*"} , I can get the value for this metric


Is it possible, to run the second query only for the instance which has the lock ?



request_process_time{stack=~"failoversvc.*"} and lock_state{stack=~"failoversvc.*"} == 1

--

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/24986391-a2ec-4ba1-a6da-d1858d570019%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Meher Garda

unread,
Mar 14, 2017, 12:59:24 PM3/14/17
to Prometheus Users, meher...@gmail.com
Yes, there are other labels too, Thanx once again.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.



--
Reply all
Reply to author
Forward
0 new messages