HipChat

使用 warnNotification 和 critNotification 将 Bosun 通知分配给警报定义,并指示在发生新事件时将呈现的警报模板发送到何处。的 $ {env.VARIABLENAME}语法可以被用于从一个环境的可变负荷的值。

要向 HipChat 发布警报,请首先创建名为 Bosun 的集成。Integration 将提供发布消息(包括令牌)所需的 URL,如下所示:

StackOverflow 文档

剩下的就是设置模板和通知:

#Example template
template hipchat.bandwidth {
    subject = `{"color":{{if lt (.Eval .Alert.Vars.dlspeed) (.Eval .Alert.Vars.dlcritval) }}"red"{{else}} {{if lt (.Eval .Alert.Vars.dlspeed) (.Eval .Alert.Vars.dlwarnval) }}"yellow"{{else}}"green"{{end}}{{end}},"message":"Server: {{.Group.host}}<br/>Metric: {{.Alert.Name}}<br/><br/>DL speed: {{.Eval .Alert.Vars.dlspeed | printf "%.2f" }}<br/>DL Warning threshold: {{.Alert.Vars.dlwarnval}}<br/>DL Critical threshold: {{.Alert.Vars.dlcritval}}<br/><br/>Notes: {{.Alert.Vars.notes}}<br/><br/>RunBook: <a href={{.Alert.Vars.runbook}} >wiki article</a>","notify":false,"message_format":"html"}`
}

#Example notification
notification hipchat {
    #Create an Integration in HipChat to generate the POST URL
    #Example URL:  https://<YOURHIPCHATSERVER_FQDN>/v2/room/<ROOM_NUMBER>/<TOKEN>
    post = ${env.HIPCHAT_ROOM_ABC} 
    body = {{.}}
    contentType = application/json
}