Skip to content

::: {.index} pair: Notify Slack when Alerts Arrive; Labs :::

2020 Notify Slack when Alerts Arrive

Overview

  • Id: 2020
  • Time: 10 Minutes
  • Enabled: Yes
  • Difficulty: intermediate
  • Tags: slack, orchestration, integration, triggers

* Concepts: alerts, triggers, blueprints .. youtube:: VBnGduQdrnE :privacy_mode: Video Link

Objective

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

Required Labs:

  • 2000
  • 2010

Addtional 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.

Notify Slack when Alerts Arrive

Build orchestration

Choose a path to setup the orchestration. Both paths can be done without resetting anything.

::: {.tabs} ::: {.tab} UX :::

  1. Setup Slack Service Integration

    1. Navigate to the global profile
    2. 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

  2. Setup a Blueprint

    1. Navigate to the Blueprints view
    2. Click the Add button

      Set Name to lab2020

      Click Save

    3. Add a Task by selecting slack-app-webhook

  3. Create a Trigger to Run the Blueprint

    1. Go to the Triggers view
    2. 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

  4. Create an Alert to Test the Process

    1. Go to the Alerts view
    2. Click the Add button

      Set Name to lab2020

      Set Level to INFO

      Click Save

    3. Check Slack for a message from that alert.

  5. Observe Work Orders

    1. Go to Work Orders view
    2. Notice the lab2020 Blueprint WorkOrder
  6. Customize the message

    1. Go to the lab2020 trigger
    2. Click the Merge Data toggle to true
    3. Add a WorkOrder Parameter slack/message

      The value should be set to:

      {"text":"{{.Param "Level"}} {{.Param "Name"}} Alert from Digital Rebar at {{.ApiURL }}"}
      
  7. Create an Alert to Test the Custom Message

    1. Go to the Alerts view
    2. Click the Add button

      Set Name to lab2020

      Set Level to INFO

      Click Save

    3. Check Slack for a message from that alert.

::: {.tab} CLI :::

  1. Using the Shell from Lab 2000
    1. Bring up the shell
  2. Setup Slack Service Integration

    1. Set the Slack URL in the global profile

      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.

  3. Setup a Blueprint

    1. Create a blueprint to do slack notifications

      drpcli blueprints create - <<EOF
      Name: lab2020-cli
      Tasks:
        - slack-app-webhook
      EOF
      

      Returns the JSON object of the new blueprint on success.

  4. Create a Trigger to Run the Blueprint

    1. Create a trigger to run the blueprint

      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.

  5. Create an Alert to Test the Process

    1. Post the alert

      drpcli alerts post --unique INFO lab2020-cli
      

      Returns the JSON object of the alert.

  6. Observe Work Orders

    1. Go to Work Orders view
    2. Notice the lab2020-cli Blueprint WorkOrder :::