1

我第一次使用 Bosun 配置时遇到了奇怪的行为。看来我只在第一次调用警报时才收到邮件。我肯定误解了一些东西。这是我的 .conf 文件:

smtpHost = ${env.BOSUN_MAIL_SERV}
smtpUsername =  ${env.BOSUN_MAIL_USER}
smtpPassword = ${env.BOSUN_MAIL_PASS}
emailFrom = ${env.BOSUN_MAIL_FROM}
httpListen = :8070
timeAndDate = 31
stateFile = ../bosun.state
ledisDir = ../ledis_data
checkFrequency = 10s
logstashElasticHosts = ${env.BOSUN_ES_HOSTS}

notification onError {
    email = elkarel@company.net
    print = true
}

template generic {
    subject = Test alert
    body = `<p>Alert: {{.Alert.Name}} triggered </p>`
}

alert company.errors.rate.exceeds0 {
    template = generic
    unknownIsNormal = true
    runEvery = 1
    $notes = "The rate of errors exceeds 1."
    crit = 1
    critNotification = onError
}

如您所见,crit始终设置。然而,什么都不会发生。Bosun 的输出是这样的:

elkarel@thinkPad-E550:~/Bosun$ ./bosun-linux-amd64-0.5.0-rc3 -c company.conf 
2016/05/18 13:14:45 enabling syslog
2016/05/18 13:14:45 info: search.go:194: Loading last datapoints from redis
2016/05/18 13:14:45 info: search.go:201: Done
2016/05/18 13:14:45 info: bolt.go:53: RestoreState
2016/05/18 13:14:45 info: bolt.go:65: RestoreState done in 23.954µs
2016/05/18 13:14:45 info: check.go:513: check alert company.errors.rate.exceeds0 start
2016/05/18 13:14:45 info: check.go:537: check alert company.errors.rate.exceeds0 done (463.184µs): 1 crits, 0 warns, 0 unevaluated, 0 unknown
2016/05/18 13:14:45 info: web.go:154: bosun web listening on: :8070
2016/05/18 13:14:45 info: web.go:155: tsdb host: 
2016/05/18 13:14:45 info: alertRunner.go:55: runHistory on company.errors.rate.exceeds0 took 11.525239ms
2016/05/18 13:14:55 info: check.go:513: check alert company.errors.rate.exceeds0 start
2016/05/18 13:14:55 info: check.go:537: check alert company.errors.rate.exceeds0 done (418.716µs): 1 crits, 0 warns, 0 unevaluated, 0 unknown
2016/05/18 13:14:55 info: alertRunner.go:55: runHistory on company.errors.rate.exceeds0 took 2.298315ms

2016/05/18 13:15:05 info: notify.go:147: Batching and sending unknown notifications
2016/05/18 13:15:05 info: notify.go:177: Done sending unknown notifications
2016/05/18 13:15:05 info: check.go:513: check alert company.errors.rate.exceeds0 start
2016/05/18 13:15:05 info: check.go:537: check alert company.errors.rate.exceeds0 done (380.23µs): 1 crits, 0 warns, 0 unevaluated, 0 unknown
2016/05/18 13:15:05 info: alertRunner.go:55: runHistory on company.errors.rate.exceeds0 took 919.933µs
2016/05/18 13:15:15 info: check.go:513: check alert company.errors.rate.exceeds0 start
2016/05/18 13:15:15 info: check.go:537: check alert company.errors.rate.exceeds0 done (351.148µs): 1 crits, 0 warns, 0 unevaluated, 0 unknown
2016/05/18 13:15:15 info: alertRunner.go:55: runHistory on company.errors.rate.exceeds0 took 807.104µs
2016/05/18 13:15:25 info: notify.go:147: Batching and sending unknown notifications
2016/05/18 13:15:25 info: notify.go:177: Done sending unknown notifications
2016/05/18 13:15:25 info: check.go:513: check alert company.errors.rate.exceeds0 start
2016/05/18 13:15:25 info: check.go:537: check alert company.errors.rate.exceeds0 done (439.26µs): 1 crits, 0 warns, 0 unevaluated, 0 unknown
2016/05/18 13:15:25 info: alertRunner.go:55: runHistory on company.errors.rate.exceeds0 took 2.429369ms

所以他知道警报导致了严重状态,但没有发送任何通知。但是,如果我将警报名称更改为company.errors.rate.exceeds0_newname,则会触发通知并收到邮件:

elkarel@thinkPad-E550:~/Bosun$ ./bosun-linux-amd64-0.5.0-rc3 -c company.conf 
2016/05/18 13:18:35 enabling syslog
2016/05/18 13:18:35 info: search.go:194: Loading last datapoints from redis
2016/05/18 13:18:35 info: search.go:201: Done
2016/05/18 13:18:35 info: bolt.go:53: RestoreState
2016/05/18 13:18:35 info: bolt.go:65: RestoreState done in 28.431µs
2016/05/18 13:18:35 info: check.go:513: check alert company.errors.rate.exceeds_newname start
2016/05/18 13:18:35 info: check.go:537: check alert company.errors.rate.exceeds_newname done (638.843µs): 1 crits, 0 warns, 0 unevaluated, 0 unknown
2016/05/18 13:18:35 info: web.go:154: bosun web listening on: :8070
2016/05/18 13:18:35 info: web.go:155: tsdb host: 
2016/05/18 13:18:35 info: alertRunner.go:55: runHistory on company.errors.rate.exceeds_newname took 2.380886ms
2016/05/18 13:18:35 info: notify.go:57: Test alert
2016/05/18 13:18:36 info: notify.go:115: relayed alert company.errors.rate.exceeds_newname{} to [elkarel@company.net] sucessfully. Subject: 10 bytes. Body: 99 bytes.
2016/05/18 13:18:45 info: check.go:513: check alert company.errors.rate.exceeds_newname start
2016/05/18 13:18:45 info: check.go:537: check alert company.errors.rate.exceeds_newname done (558.396µs): 1 crits, 0 warns, 0 unevaluated, 0 unknown
2016/05/18 13:18:45 info: alertRunner.go:55: runHistory on company.errors.rate.exceeds_newname took 746.837µs
2016/05/18 13:18:55 info: notify.go:147: Batching and sending unknown notifications
2016/05/18 13:18:55 info: notify.go:177: Done sending unknown notifications
2016/05/18 13:18:55 info: check.go:513: check alert company.errors.rate.exceeds_newname start
2016/05/18 13:18:55 info: check.go:537: check alert company.errors.rate.exceeds_newname done (394.645µs): 1 crits, 0 warns, 0 unevaluated, 0 unknown
2016/05/18 13:18:55 info: alertRunner.go:55: runHistory on company.errors.rate.exceeds_newname took 956.957µs
2016/05/18 13:19:05 info: check.go:513: check alert company.errors.rate.exceeds_newname start
2016/05/18 13:19:05 info: check.go:537: check alert company.errors.rate.exceeds_newname done (404.464µs): 1 crits, 0 warns, 0 unevaluated, 0 unknown
2016/05/18 13:19:05 info: alertRunner.go:55: runHistory on company.errors.rate.exceeds_newname took 832.393µs
2016/05/18 13:19:15 info: notify.go:147: Batching and sending unknown notifications

显然只有“新”警报才会发送通知。这是 Bosun 的工作方式吗?我是否必须重新发送通知,直到有人确认?

邮件服务器是gmail。

提前致谢!

4

1 回答 1

4

是的,Bosun 仅在警报从正常转换为警告或从警告转换为暴击时发送通知。但是,您可以链接通知甚至指定

notification onError {
    email = elkarel@company.net
    print = true
    timeout = 1m
    next = onError
}

这样,Bosun 将每分钟发送一次通知,直到警报得到确认。

于 2016-05-18T12:57:58.983 回答