I have a counter cart_transactions_messages_processed_total. Trying to set an alert, if the counter increases continually during/for an hour.
From the documentation, I learnt that, if the counter value drops the counter resets altogether, if so, how to take this into consideration while creating a rule ?
Will this be a right approach – increase(cart_transactions_messages_processed_total[1h]) ?
>Solution :
increase(cart_transactions_messages_processed_total[1h]) returns increase of your counter over an hour.
Based on your question, I assume you want to fire alert, if counter was increased every minute of some hour. If this is correct, you’ll need something like this:
- alert: ConstantIncrease
expr: increase(cart_transactions_messages_processed_total[1m]) > 0
for: 1h
labels:
severity: page
annotations:
summary: Counter is constantly increasing
Here, expression increase(cart_transactions_messages_processed_total[1m]) > 0 executed every evaluation_interval, and if it returns result for one hour, alert will be fired.