bosun时间取决于警报

use*_*022 1 time monitoring alerts bosun

早上好.

我最近几天一直在使用bosun监控应用程序,我非常喜欢它.但我需要一件事我无法解决.

我希望有1个警报响应不同,具体取决于它的时间.因此,白天每小时登录我的网站的数量需要为100,而夜间需要为10.当它低于我想要创建警报时.

如果我使用2个警报执行此操作,那么白天警报将在晚上发出警报.所以我需要一个查找,检查它是什么时间,然后给出正确的阈值.

任何人都知道如何做到这一点.

马塞尔科尔特

Kyl*_*ndt 5

博森没有这个功能.我已经考虑过了,但我从来没有被证明是必要的用例.为什么?

我考虑过两个一般情况:

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

在此输入图像描述

为了处理这种情况,我们使用异常警报.这实际上说的是"这不是过去几周一周中同一时间的情况,发出警报".对此的关键功能是波段功能.以下是从示例页面执行此操作的示例:

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
}
Run Code Online (Sandbox Code Playgroud)

希望这条路可以解决您的警报需求?