Combine 2 prom queries without Unique value

46 views
Skip to first unread message

Prajakta

unread,
Oct 14, 2020, 12:58:17 PM10/14/20
to Prometheus Users
Hello Everyone,

 I am trying to combine 2 queries which do not have unique value among each. Can anybody please help me to find the solution.

Below are the 2 queries.

Query1 : sum by(statefulset)((kube_statefulset_replicas) == (kube_statefulset_status_replicas_ready))

Query2 : (kube_pod_status_phase{phase!="Succeeded"})  ==1)

I have combined 2 queries in past but those were having unique value like below.

sum by(namespace, pod, container) ((avg without(instance) (changes(kube_pod_container_status_restarts_total{namespace=~".*-prod"}[15m])))> 0) + on(pod, namespace) group_left(node) (sum by(pod, namespace, node) (kube_pod_info))

Thanks all in advance.

Brian Candler

unread,
Oct 14, 2020, 1:22:50 PM10/14/20
to Prometheus Users
On Wednesday, 14 October 2020 17:58:17 UTC+1, Prajakta wrote:
Below are the 2 queries.

Query1 : sum by(statefulset)((kube_statefulset_replicas) == (kube_statefulset_status_replicas_ready))

Query2 : (kube_pod_status_phase{phase!="Succeeded"})  ==1)

Can you show some examples of the outputs of those two queries separately?  And then how you'd like to combine those answers?

Prajakta

unread,
Oct 15, 2020, 10:12:26 AM10/15/20
to Prometheus Users
Query 1 Result:

I have changed query just to NOT EQUAL instead of EQUAL



Query 2



Here the condition is ,in the stateful set if desired and ready state is not same then only it should notify me that POD is not ready.
If the desired and ready count is same and one of the POD in that getting restarted or not available then I don't want to alert on.

Can you please help :)
Thanks in advance.

Brian Candler

unread,
Oct 15, 2020, 11:25:25 AM10/15/20
to Prometheus Users
You appear to have pasted two empty white boxes :-(
Message has been deleted

Prajakta

unread,
Oct 15, 2020, 12:37:06 PM10/15/20
to Prometheus Users
Hello ,

Sorry for that :). I have attached with query no. Please see if you can receive now,

And thank you so much for help in advance.
query2.png
query1.png

Prajakta

unread,
Oct 16, 2020, 3:43:55 AM10/16/20
to Prometheus Users
Hello All,

can anybody please help here. I am stuck on this issue.

Reply all
Reply to author
Forward
0 new messages