Yes, using a recording rule will work fine too.

> Prometheus seems unable to do a min_over_time() from a sum()

That's because the input to min_over_time is a range vector - which covers 
multiple points over a period of time, not a single instant of time.

As I said before, you can turn an instant vector into a range vector using 
a subquery. Something like:

    min_over_time((sum by (instance) (apt_upgrades_pending))[48h:5m])

A subquery is just like specifying a time range on a metric, but you have 
to specify the sampling interval (here "5m"). The instant query is repeated 
at this interval to generate a range of data points.  You don't need to do 
this on a plain metric because it just uses all the individual samples 
which were scraped.

On Sunday, 21 November 2021 at 22:24:44 UTC [email protected] wrote:

> > sum by (instance) (apt_upgrades_pending) > 0
>
> I think that your suggestion will work. I'll try it out for the next days. 
> Many thanks.
>
> About the other way, for completeness: Instead of using a subquery, I 
> wonder whether this would work too:
>
>   - record: apt_upgrades_pending:sum_grouped_by_instance
>     expr: sum by ( instance ) ( apt_upgrades_pending )
>
>   - alert: AptNotUpdatingPackages
>     expr: min_over_time( apt_upgrades_pending:sum_grouped_by_instance[7d] 
> ) > 0
>     for: 0m
>     labels:
>       severity: warning
>
> Prometheus seems unable to do a min_over_time() from a sum(). Is that kind 
> of intermediate step with "record" a generic way to overcome this 
> limitation? Or have I missed something?
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/ab1ed651-2a60-4ccd-ac79-9c237b0a87dcn%40googlegroups.com.

Reply via email to