英文:
Right function for a metric that grows steadily
问题
我有一个计数器 cart_transactions_messages_processed_total
。尝试设置一个警报,如果在一小时内计数器不断增加。
根据文档,我了解到,如果计数器的值下降,计数器将完全重置,如果是这样,如何在创建规则时考虑这一点?
这是否是正确的方法 - increase(cart_transactions_messages_processed_total[1h])
?
英文:
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])
?
答案1
得分: 1
increase(cart_transactions_messages_processed_total[1h])
返回计数器在一小时内的增加量。
根据您的问题,我假设您想在某个小时内的每一分钟都增加计数器时触发警报。如果我的理解正确,您需要类似以下的配置:
- alert: ConstantIncrease
expr: increase(cart_transactions_messages_processed_total[1m]) > 0
for: 1h
labels:
severity: page
annotations:
summary: 计数器持续增加
在这里,表达式 increase(cart_transactions_messages_processed_total[1m]) > 0
每次在 evaluation_interval
内执行,如果在一小时内返回结果,则触发警报。
英文:
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.
答案2
得分: 0
不是正确的方法
"increase" 函数计算指定时间范围内第一个值与最后一个值之间的差异,这不会捕捉到随着时间稳定增加的情况。
相反,你应该使用 "rate" 函数
rate(cart_transactions_messages_processed_total[1h])
英文:
No This is not Right Approach
The "increase" function calculates the difference btw first & last value within the specified time range,which would not capture the steady increase over time.
Instead, you should use the "rate" function
rate(cart_transactions_messages_processed_total[1h])
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论