Previously we looked at how to use the Prometheus Alertmanager with Pagerduty. The Alertmanager supports more than just sending pages, there's integrations with popular chat applications too. Let's look at how to integrate with Slack.
The Alertmanager uses the Incoming Webhooks feature of Slack, so first we need to set that up.
Go to the Incoming Webhooks page in the App Directory and click "Install" (or "Configure" and then "Add Configuration" if it's already installed):
You can then configure your new webhook. Choose the default channel to post to, and then add the integration:
This will then give us the Webhook URL we need:
Let's download, configure and run an Alertmanger:
WEBHOOK_URL=XXXX # Substitute in your Webhook URL here. wget https://github.com/prometheus/alertmanager/releases/download/v0.8.0/alertmanager-0.8.0.linux-amd64.tar.gz tar -xzf alertmanager-0.8.0.linux-amd64.tar.gz cd alertmanager-* cat <<EOF > alertmanager.yml route: group_by: [cluster] # If an alert isn't caught by a route, send it slack. receiver: slack_general routes: # Send severity=slack alerts to slack. - match: severity: slack receiver: slack_general receivers: - name: slack_general slack_configs: - api_url: $WEBHOOK_URL channel: '#general' EOF ./alertmanager &
That's all now setup, and you can see your firing alerts in Slack:
The flexibility the Prometheus Alertmanager offers means that each team can route alerts to their own Slack channels, and customise the messages.