仅发送第一个通知

仅发送第一个通知

本文介绍了Bosun:仅发送第一个通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am experiencing strange behaviour with my first-time Bosun config.It seems I'm receiving mail only first time the alert is being called.I am surely misunderstanding something.. Here's my .conf file:

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 = [email protected]
    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的输出是这样的:

As you can see, crit is set always. However, nothing never happens. The Bosun output is like this:

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,则会触发通知并且邮件到达:

So he knows the alert resulted in a critical state, but does not send any notification.However, if I change alert name to company.errors.rate.exceeds0_newname, the notification is fired and mail arrives:

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 [[email protected]] 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

显然仅使用新"警报发送通知.这是宝顺的工作方式吗?在有人取消通知之前,我是否必须重新发送通知?

Notifications are being sent apparently only with "new" alerts. Is this how Bosun works? Do I have to resend the notification until somebody acks it?

邮件服务器是gmail.

The mail server is gmail.

提前谢谢!

推荐答案

是的,Bosun仅在警报从正常转变为警告或从警告转变为暴击时才发送通知.但是,您可以进行链式通知,甚至可以指定

Yes, Bosun only sends notification when an alert transitions from normal to warn or from warn to crit. You can, however chain notifications or even specify

notification onError {
    email = [email protected]
    print = true
    timeout = 1m
    next = onError
}

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

That way Bosun will send notification every minute until the alert gets acknowledged.

这篇关于Bosun:仅发送第一个通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 00:27