问题描述
我正在使用Graphite + Statsd(带有Python客户端)从Web应用程序收集自定义指标:成功交易的计数器.假设计数器为stats.transactions.count
,该计数器在stats.transactions.rate
处也具有速率/每秒"指标.
I'm using Graphite+Statsd (with Python client) to collect custom metrics from a webapp: a counter for successful transactions. Let's say the counter is stats.transactions.count
, that also has a rate/per/second metric available at stats.transactions.rate
.
我还设置了 Seyren 作为Monitor + Alert系统,并成功地从Graphite中提取了指标.现在,如果最近60分钟内成功交易的数量少于某个最小值,我想在赛伦设置警报.
I've also setup Seyren as a monitor+alert system and successfully pulled metrics from Graphite. Now I want to setup an alert in Seyren if the number of successful transactions in the last 60 minutes is less than a certain minimum.
我应该使用哪个指标和Graphite函数?我尝试使用summarize(metric, '1h')
,但这在Graphite开始汇总开始时间的指标时,每个小时都会向我发出警报.
Which metric and Graphite function should I use? I tried with summarize(metric, '1h')
but this gives me an alert each hour when Graphite starts aggregating the metric for the starting hour.
请注意,如果有帮助,Seyren还可以指定Graphite的from
和until
参数.
Note that Seyren also allows to specify Graphite's from
and until
parameters, if this helps.
推荐答案
我贡献了Seyren代码来支持from
/until
,以便处理这种确切情况.
I contributed the Seyren code to support from
/until
in order to handle this exact situation.
如果最后一小时的计数低于50,则以下配置应发出警告,如果计数低于25,则应发出错误.
The following configuration should raise a warning if the count for the last hour drops below 50, and an error if it drops below 25.
- 目标:摘要(nonNegativeDerivative(stats.transactions.count),"1h","sum",true)
- 发件人: -1h
- 收件人: [空白]
- 警告::50(最低软限度)
- 错误::25(最低要求)
- Target: summarize(nonNegativeDerivative(stats.transactions.count),"1h","sum",true)
- From: -1h
- To: [blank]
- Warn: 50 (soft minimum)
- Error: 25 (hard minimum)
请注意,此操作将每分钟运行一次,因此最后一小时"是一个滑动比例.另请注意,summary函数的第三个布尔参数true
告诉它将其1h时段与From
对齐,这意味着从1小时前开始,您将获得一个完整的1小时时段,而不是意外地获得了一个半时段. (较新版本的Graphite可能会自动执行此操作.)
Note this will run every minute, so the "last hour" is a sliding scale. Also note that the third boolean parameter true
for the summarize function is telling it to align its 1h bucket to the From
, meaning you get a full 1-hour bucket starting 1 hour ago, rather than accidentally getting a half bucket. (Newer versions of Graphite may do this automatically.)
您的里程可能会有所不同.当服务器重新启动时将计数器设置回0时,我在使用此方法时遇到了问题.但就我而言,我使用的是dropwizard指标+石墨,而不是statsd +石墨,因此您可能没有这个问题.
Your mileage may vary. I have had problems with this approach when the counter gets set back to 0 on a server restart. But in my case I'm using dropwizard metrics + graphite, not statsd + graphite, so you may not have that problem.
请让我知道这种方法是否对您有用!
Please let me know if this approach works for you!
这篇关于如果最近60分钟内的交易量少于x,如何用Graphite提醒塞伦?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!