Skip to content

Commit

Permalink
Document message format
Browse files Browse the repository at this point in the history
  • Loading branch information
codez committed Jan 9, 2020
1 parent 5a0873e commit ebfbfbe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ A Rocket.Chat webhook that receives Prometheus Alertmananager alerts, creates co

See https://rocket.chat/docs/administrator-guides/integrations/ for details on how to generate Rocket.Chat webhooks.

## Message Format

Rocket.Chat messages produced by this webhook will have the following basic format (based on the keys in the [Alertmanager request](sample-request.json)):

[annotations.severity OR status] annotations.summary
annotations.description

You are responsible to put all labels you would like to see into the summary or the description when you define the alert rules for Prometheus. The description is optional, leave it empty if it does not contain additional information.

You may optionally set the label `rocketchat_channel` in the alert rule to route a message to a custom channel.


## Installation

### Rocket.Chat
Expand All @@ -23,8 +35,6 @@ Create Integration. Copy the WebHook URL and proceed to Alertmanager.
Create a new receiver or modify config of existing one. You'll need to add `webhooks_config` to it. Small example:

route:
repeat_interval: 30m
group_interval: 30m
receiver: rocketchat

receivers:
Expand All @@ -44,4 +54,4 @@ To test the webhook, you may send a sample request to your Rocket.Chat instance:
## License

prometheus-rocket-chat is released under the terms of the MIT License.
Copyright 2019 Puzzle ITC GmbH. See `LICENSE` for further information.
Copyright 2019-2020 Puzzle ITC GmbH. See `LICENSE` for further information.
10 changes: 5 additions & 5 deletions webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ class Script {
}

getAlertColor(status) {
let color = "warning";
if (status === "resolved") {
color = "good";
return "good";
} else if (status === "firing") {
color = "danger";
return "danger";
} else {
return "warning";
}
return color;
}

getAlertTitle(alert, status) {
let title = "[" + this.getAlertStatus(alert, status).toUpperCase() + "] ";
if (!!alert.annotations.summary) {
title += alert.annotations.summary;
} else {
} else if (!!alert.labels.alertname) {
title += alert.labels.alertname + ": " + alert.labels.instance;
}
return title;
Expand Down

0 comments on commit ebfbfbe

Please sign in to comment.