Bosun Notifications: Chat Systems

From WikiOD
Revision as of 12:39, 17 May 2021 by Admin (talk | contribs) (Text replacement - "{{note| This article is an extract of the original Stack Overflow Documentation created by contributors and released under [ CC BY-SA 3.0]. This website is not affiliated with Stack Overflow }}" to "{{note| Credit:Stack_Overflow_Documentation }}")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Remarks[edit | edit source]

In Bosun notifications are used for both new alert incidents and when an alert is acked/closed/etc. If you don't want the other events to trigger a notification add runOnActions = false to the notification definition.

See Notification Overview for more examples.

HipChat[edit | edit source]

Bosun notifications are assigned to alert definitions using warnNotification and critNotification and indicate where to send the rendered alert template when a new incident occur. The ${env.VARIABLENAME} syntax can be used to load values from an Environmental Variable.

In order to post alerts to HipChat, start by creating an Integration named "Bosun". The Integration will provide the URL necessary to post messages (including the token) as seen here:

HipChat screenshot

All that's left is to setup the template and notification:

#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: {{}}<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

Slack Notifications[edit | edit source]

#Post to a chatroom via their Incoming Webhooks integration
notification slack{
    post =
    body = {"text": {{.|json}}}
#To customize the icon and user use:
#   body = {"text": {{.|json}}, "icon_emoji": ":hammer_and_wrench:", "username": "Bosun"}