关于一个持续增长的度量标准的正确函数

huangapple go评论82阅读模式
英文:

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]) 返回计数器在一小时内的增加量。

根据您的问题,我假设您想在某个小时内的每一分钟都增加计数器时触发警报。如果我的理解正确,您需要类似以下的配置:

  1. - alert: ConstantIncrease
  2. expr: increase(cart_transactions_messages_processed_total[1m]) > 0
  3. for: 1h
  4. labels:
  5. severity: page
  6. annotations:
  7. 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:

  1. - alert: ConstantIncrease
  2. expr: increase(cart_transactions_messages_processed_total[1m]) > 0
  3. for: 1h
  4. labels:
  5. severity: page
  6. annotations:
  7. 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])

huangapple
  • 本文由 发表于 2023年6月21日 23:00:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76524688.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定