Compare metric with label average

I want to be able to compare a given metric avg_over_time(metric_1[5m]) to determine whether this value is greater than the average of the other metric_1 that has some shared label.

For example:

If querying: avg_over_time(metric_1[5m])

I want to know if (example result) metric_1{colour="blue", name="bob"} is greater than the average of the rest of the metric_1{colour="blue"} but that have a different {name}

What's the best way to do this in PromQL?

I tried doing something like avg_over_time(metric_1[5m]) > avg_over_time(metric_1[30m]) but its not exactly what im looking for (need to compare with values with same colour label but excluding same name)

Thanks for the insights :)

1 answer

  • answered 2022-04-28 21:53 Marcelo Ávila de Oliveira

    Use the following PromQL:

    scalar(avg_over_time(metric_1{colour="blue", name="bob"}[5m])) - avg(avg_over_time(metric_1{colour="blue"}[5m])) > bool 0

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum