System Notification

EdgeLake includes a rule engine that can be configured to execute periodic tasks and monitor and alert using services like REST, SMS and STMP (eMail). For example, users can be alerted on CPU, Network, RAM, Disk utilization and data ingestion.
Details on the Rule Engine is available in the section Alerts and Monitoring.

Setting up Webhooks

Webhooks are user-defined HTTP callbacks that enable real-time communication between web applications; they are the simplest and fastest way to send messages into third-party applications as these callbacks use REST (POST) requests for messaging.

Steps

For demonstration purposes, this document uses Slack, however, the same logic can be applied with other webhooks.

  1. Go to Slack Applications Sections -- may require to login / admin permissions
  2. Under _Create_, Create an app from manifest

  3. Select the preferred channel

  4. Press continue / next till the end
  5. Select Incoming Webhooks

  6. Enable Webhooks

  7. At the bottom, add Webbooks to workspace

  8. Select which channel in Slack to send messages to

  9. When done you should see a Webhook (URL) - this will be used as part of your REST request in EdgeLake

Generated URL:

https://hooks.slack.com/services/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

Send Notifications via EdgeLake

EdgeLake allows to send cURL requests the rest command. Since Webhooks are essentially URLs embedded with messages, below is a rest command that sends notifications from EdgeLake into Slack.

  1. Create webhook URL as a variables
    webhook_url = "https://hooks.slack.com/services/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"

  2. get percentage of CPU used and current timestamp
    cpu_percent = get node info cpu_percent
    date_time = python "datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')"

  3. Create payload
    text_msg = !date_time + "  CPU usage: " + !cpu_percent 
    payload = json {"text": !text_msg}

  4. Publish information to Slack via _REST_
    <rest post where 
        url = !webhook_url and 
        body = !payload and 
        headers = "{'Content-Type': 'application/json'}">

    Note: Google Hangouts, Discord and Microsoft Teams use content for the payload key as opposed to text.

Once sent, an output would appear in the proper Slack channel