Search code examples
prometheuspromql

How to boolean compare histogram_quantile against gauge?


I want to compare the returned instant vector of histogram_quantile against a gauge.

(
  histogram_quantile(1.0,
    sum by (le) (
      rate(discoverer__round_duration_seconds_bucket[1m])
    )
  )
)
>= bool
(
  discoverer__info_interval_seconds * 0.0001
)

But what I get back is no datapoints found. Please notice that I multiple the gauge with a very small number. This is just to make clear that it will be always <= than the quantile. Both "subqueries" work if I enter them separately into Prometheus Web UI.

Why is this not working?

When I switch out the quantile with a rate it suddenly works:

(
  rate(discoverer__round_duration_seconds_sum[1m])
  /
  rate(discoverer__round_duration_seconds_count[1m])
)
> bool
(
  discoverer__info_interval_seconds * 0.02
)

image

I made sure that all queries work by themselves.

What I would like to see is something similar to the second screenshot. Just with a percentile, because I prefer it's calculation for my alert.


Solution

  • I got it to work by wrapping the gauge in avg(). Still, I would really like to know why it works in one example without avg().

    histogram_quantile(1.0, sum by (le) (rate(discoverer__round_duration_seconds_bucket[1m]))) > bool avg(discoverer__info_interval_seconds) * 0.1