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
}