Bosun警报是使用自定义DSL在配置文件中定义的。它们使用函数来评估时间序列数据,并在警告或关键表达式非零时生成警报。警报使用模板在通知中包括其他信息,这些信息通常是电子邮件和/或HTTP POST请求。
templatesample.alert{
body = `<p>Alert: {{.Alert.Name}} triggered on {{.Group.host}}
<hr>
<p><strong>Computation</strong>
<table>
{{range .Computations}}
<tr><td><a href="{{$.Expr .Text}}">{{.Text}}</a></td><td>{{.Value}}</td></tr>
{{end}}
</table>
<hr>
{{ .Graph .Alert.Vars.metric }}`
subject = {{.Last.Status}}: {{.Alert.Name}} cpu idle at {{.Alert.Vars.q | .E}}% on {{.Group.host}}
}
notificationsample.notification{
email = alerts@example.com
}
alertsample.alert{
template = sample.template
$q = avg(q("sum:rate:linux.cpu{host=*,type=idle}", "1m"))
crit = $q < 40
notification = sample.notification
}该警报将发送电子邮件,主题为过去1分钟内空闲CPU使用率平均不到40%的任何主机。此示例是“主机范围的”警报,但Bosun还支持群集,数据中心或全局范围的警报(有关更多详细信息,请参阅基础知识视频系列)。Critical:sample.alertcpu idle at 25% on hostname