首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >bosun时间依赖警报

bosun时间依赖警报
EN

Stack Overflow用户
提问于 2015-08-19 08:15:18
回答 2查看 1.3K关注 0票数 1

早上好。

在过去的几天里,我一直在使用bosun监控应用程序,我非常喜欢它。但我需要一件我无法锻炼的东西。

我希望有一个警报的反应不同,取决于是什么时候。所以,我的网站的登录量在白天需要100次,晚上需要10次。当它低于这个值时,我想要创建一个警告。

如果我用两个警报来做,白天的警报就会在晚上发出。所以我需要一个检查时间的查找,然后给出正确的阈值。

任何人都知道怎么做。

马塞尔·科尔特

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-08-19 11:28:17

Bosun没有这个功能。我已经考虑过了,但从来没有给我看过必要的用例。为什么?

在这方面,我曾考虑过两项一般个案:

  • 某些作业或事件在时间X运行,而您不想发出警告,因为当作业运行时,它会期望某些事情发生。在这种情况下,最好是监视作业,而不是在作业运行时发出警报。这使得耦合更加紧密,所以当您更改作业时间时,警报仍然不会误触发。
  • 随着时间的变化而变化的事物。如果我没有弄错的话,这就是你指的情况。当发生这种情况时,我们会看到数据的一些季节性(在下面的例子中,每周季节性):

为了处理这种情况,我们使用异常警报。这实际上是说“这不是过去几周同一时间的情况,发送一个警告”。这方面的关键函数是带带函数。下面是从示例页中执行此操作的示例

代码语言:javascript
复制
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
}

希望这条路能解决你的报警需求?

票数 5
EN

Stack Overflow用户

发布于 2017-04-25 17:51:55

使用epoch()函数,您可以确定一天中的什么时候。只需每天86400秒的epoch(),你就有了第二个相对于当前的一天。将其与您希望窗口开始和结束的UTC中的开始和结束秒进行比较。

如果计算警报的时间为08:00至03:00 UTC,则此宏将$during_business_hours设置为true。

代码语言:javascript
复制
macro business_hours {
    $time = epoch() % 86400
    $start = 8 * 3600
    $end = 3 * 3600
    $during_business_hours = $time >= $start || $time <= $end
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32090026

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档