早上好。
在过去的几天里,我一直在使用bosun监控应用程序,我非常喜欢它。但我需要一件我无法锻炼的东西。
我希望有一个警报的反应不同,取决于是什么时候。所以,我的网站的登录量在白天需要100次,晚上需要10次。当它低于这个值时,我想要创建一个警告。
如果我用两个警报来做,白天的警报就会在晚上发出。所以我需要一个检查时间的查找,然后给出正确的阈值。
任何人都知道怎么做。
马塞尔·科尔特
发布于 2015-08-19 11:28:17
Bosun没有这个功能。我已经考虑过了,但从来没有给我看过必要的用例。为什么?
在这方面,我曾考虑过两项一般个案:

为了处理这种情况,我们使用异常警报。这实际上是说“这不是过去几周同一时间的情况,发送一个警告”。这方面的关键函数是带带函数。下面是从示例页中执行此操作的示例
alert slower.route.performance {
template = route.performance
$notes = Response time is based on HAProxy's Tr Value. This is the web server response time (time elapsed between the moment the TCP connection was established to the web server and the moment it send its complete response header
$duration = "1d"
$route=*
$metric = "sum:10m-avg:haproxy.logs.route_tr_median{route=$route}"
$route_hit_metric = "sum:10m-avg:rate{counter,,1}:haproxy.logs.hits_by_route{route=$route}"
$total_hit_metric = "sum:10m-avg:rate{counter,,1}:haproxy.logs.hits_by_route"
$route_hits = change($route_hit_metric, $duration, "")
$total_hits = change($total_hit_metric, $duration, "")
$hit_percent = $route_hits / $total_hits * 100
$current_hitcount = len(q($metric, $duration, ""))
$period = "7d"
$lookback = 4
$history = band($metric, $duration, $period, $lookback)
$past_dev = dev($history)
$past_median = percentile($history, .5)
$current_median = percentile(q($metric, $duration, ""), .5)
$diff = $current_median - $past_median
warn = $current_median > ($past_median + $past_dev*2) && abs($diff) > 10 && $hit_percent > 1
warnNotification = default
ignoreUnknown = true
}希望这条路能解决你的报警需求?
发布于 2017-04-25 17:51:55
使用epoch()函数,您可以确定一天中的什么时候。只需每天86400秒的epoch(),你就有了第二个相对于当前的一天。将其与您希望窗口开始和结束的UTC中的开始和结束秒进行比较。
如果计算警报的时间为08:00至03:00 UTC,则此宏将$during_business_hours设置为true。
macro business_hours {
$time = epoch() % 86400
$start = 8 * 3600
$end = 3 * 3600
$during_business_hours = $time >= $start || $time <= $end
}https://stackoverflow.com/questions/32090026
复制相似问题