'Calculate Decrease of count in Prometheus
I am looking for an option in Prometheus to give me the opposite of increase(). I can see increase(), change(), delta() but none of them specifically mentions reduction in count over time. I have used increase many times for checking if number of errors have increased over a period of time:
increase(http_request_failure[5m]) > 5
Now, for an alerting purpose I need to find if a specific count has reduced over a period of time. It turns out there is no decrease function. How do I find out a change in negative direction? Of a metric's count that has reduced by some amount over 5 minutes?
Thanks, Arnav
Solution 1:[1]
I have other metrics requirements, however, the principle and function are the same and can be applied to any other queues under monitoring. My case here is to notify a queue owner in case the queue has more than 1000 unconsumed messages and is not decreasing within 1h:
sum by (queue) (min_over_time(messages_ready[1h]) >= 1000) and delta(messages_ready[1h])>=0)
It works well for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | monk |
