2020 Notify Slack when Alerts Arrive¶
10 Minutes intermediate
Integrate Digital Rebar Provision events and alerts into Slack notifications
In this lab, the User will explore how to orchestrate the delivery of Slack notifications on events and alerts. Business ROI: Improved visibility into operational status improves system uptime and maintenance
Prerequisites¶
Additional Labs:
Additional Checklist Items:
- Must have authority to create a webhook application in Slack see
- A Slack Messaging Application URL Per the Slack Documentation, the URL will need appropriate tokens to access slack.
Concepts¶
- alerts
- triggers
- blueprints
Notify Slack when Alerts Arrive¶
Build orchestration¶
Choose a path to setup the orchestration. Both paths can be done without resetting anything.
1. Navigate to the [global](ux://profiles/global) profile
1. Add Parameter by clicking `Add Params`
Search and select `slack/service-url`
Click `Decrypt Secure Param`
Enter the URL for Slack Messaging Application URL
Click outside of the text box to save the value
1. Navigate to the [Blueprints](ux://blueprints) view
1. Click the `Add` button
Set `Name` to `lab2020`
Click `Save`
1. Add a Task by selecting `slack-app-webhook`
1. Go to the [Triggers](ux://triggers) view
1. Click the `Add` button
Set `Name` to `lab2020`
Set `Provider` to `event-trigger`
Set `Blueprint` to `lab2020`
Set `Filter` to `Local Self Runner`
Add a Param `event-trigger/event-match` with a value of
`alerts.create.*`
Click `Save`
1. Go to the [Alerts](ux://alerts) view
1. Click the `Add` button
Set `Name` to `lab2020`
Set `Level` to `INFO`
Click `Save`
1. Check Slack for a message from that alert.
1. Go to [Work Orders](ux://work_orders) view
1. Notice the `lab2020` Blueprint WorkOrder
1. Go to the [lab2020](ux://triggers/lab2020) trigger
1. Click the `Merge Data` toggle to `true`
1. Add a WorkOrder Parameter `slack/message`
The value should be set to:
```json
{"text":"{{.Param "Level"}} {{.Param "Name"}} Alert from Digital Rebar at {{.ApiURL }}"}
```
1. Go to the [Alerts](ux://alerts) view
1. Click the `Add` button
Set `Name` to `lab2020`
Set `Level` to `INFO`
Click `Save`
1. Check Slack for a message from that alert.
1. Bring up the shell
1. Set the Slack URL in the global profile
```sh
drpcli profiles set global param slack/service-url to <URL from Prereqs>
```
Returns the URL on success. It will automatically be encrypted on the server as a secure parameter.
1. Create a blueprint to do slack notifications
```sh
drpcli blueprints create - <<EOF
Name: lab2020-cli
Tasks:
- slack-app-webhook
EOF
```
Returns the JSON object of the new blueprint on success.
1. Create a trigger to run the blueprint
```sh
drpcli triggers create - <<EOF
Name: lab2020-cli
Blueprint: lab2020-cli
Description: 'Notify Slack on new Alerts'
Enabled: true
Filter: Params.machine-self-runner=true Endpoint=
FilterCount: 1
MergeDataIntoParams: true
Params:
event-trigger/event-match: alerts.create.*
TriggerProvider: event-trigger
WorkOrderParams:
slack/message: >-
{"text":"{{.Param "Level"}} {{.Param "Name"}} Alert from Digital Rebar at {{.ApiURL }}"}
EOF
```
Returns the JSON object of the new trigger on success.
1. Post the alert
```sh
drpcli alerts post --unique INFO lab2020-cli
```
Returns the JSON object of the alert.
1. Go to [Work Orders](ux://work_orders) view
1. Notice the `lab2020-cli` Blueprint WorkOrder