Query with diivision

13 views
Skip to first unread message

Альберт Александров

unread,
Jul 6, 2020, 3:48:12 AM7/6/20
to Prometheus Users


Hi all!


Have such metrics:


photo_2020-07-06_10-30-12.jpg


I would like to query:

(rules_job_count{cluster="loco-prod", status="failed"} + rules_job_count{cluster="loco-prod", status="cancelled"}) / rules_job_count{cluster="loco-prod", status="finished"}

But this didn't work. At the same time this query works:

rules_job_count{cluster="loco-prod", status="failed"} + rules_job_count{cluster="loco-prod", status="failed"} 

Could you say please how to make the first query work?

Aliaksandr Valialkin

unread,
Jul 6, 2020, 4:19:12 AM7/6/20
to Альберт Александров, Prometheus Users
Try the following query:

(rules_job_count{cluster="loco-prod", status="failed"} + ignoring(status) rules_job_count{cluster="loco-prod", status="cancelled"}) / ignoring(status) rules_job_count{cluster="loco-prod", status="finished"}

It instructs Prometheus to ignore the `status` label when performing the addition and division operations. See more details about this at https://prometheus.io/docs/prometheus/latest/querying/operators/#vector-matching


--
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/ac417564-df12-4627-8c09-2538c759a7c7o%40googlegroups.com.


--
Best Regards,

Aliaksandr Valialkin, CTO VictoriaMetrics

Альберт Александров

unread,
Jul 6, 2020, 4:27:57 AM7/6/20
to Prometheus Users
I suspected there is something wrong with labels. 

Thanks for your answer! That worked

понедельник, 6 июля 2020 г., 11:19:12 UTC+3 пользователь Aliaksandr Valialkin написал:
Try the following query:

(rules_job_count{cluster="loco-prod", status="failed"} + ignoring(status) rules_job_count{cluster="loco-prod", status="cancelled"}) / ignoring(status) rules_job_count{cluster="loco-prod", status="finished"}

It instructs Prometheus to ignore the `status` label when performing the addition and division operations. See more details about this at https://prometheus.io/docs/prometheus/latest/querying/operators/#vector-matching


On Mon, Jul 6, 2020 at 10:48 AM Альберт Александров <yakhsh...@yandex.ru> wrote:


Hi all!


Have such metrics:


photo_2020-07-06_10-30-12.jpg


I would like to query:

(rules_job_count{cluster="loco-prod", status="failed"} + rules_job_count{cluster="loco-prod", status="cancelled"}) / rules_job_count{cluster="loco-prod", status="finished"}

But this didn't work. At the same time this query works:

rules_job_count{cluster="loco-prod", status="failed"} + rules_job_count{cluster="loco-prod", status="failed"} 

Could you say please how to make the first query work?

--
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 promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages