Skip to main content
Skip table of contents

Pushing Seeq Notifications to an Outgoing Webhook

It is possible to publish Notifications from Workbench to an outgoing webhook. It must be a webhook configured in Seeq (Data Lab). This article outlines how users can receive notifications on the presence of Seeq capsules via something other than email, such as in Slack.

This feature requires an additional software license. Please contact your Seeq sales representative for more information.

When posting to Data Lab the URL set in the Seeq configuration should be in “relative” form (details in the next section).

Seeq Vantage Condition Monitors

Starting in R65, Seeq Vantage utilizes the same condition monitoring infrastructure as email notifications, and these outgoing webhooks. If your organization is using Vantage, you may see Conditions with a notification that shows this message when clicked:

image-20240603-154113.png

You can confirm this is a Condition being monitored by Seeq Vantage by opening its Item Properties, and validating it’s name is “Vantage monitor”:

image-20240603-154313.png

Below is a sample project that includes the full path from Seeq to Slack:

Slack

Steps to implement the sample project:

  1. Enable Notifications configuration -Features/Notifications/ConditionMonitors/Enabled on the Seeq server (Administrator access required).

  2. Create a notification on a condition.

  3. In Seeq Data Lab, make a new project.

  4. Add an API endpoint that will be receiving the notifications and sending them out to slack (Like the script provided below). The code below can be copy-pasted and used right after replacing the URL on line 68.

    Depending on how many notifications are configured on the system, you may want to adjust this script to filter to a subset of the notifications for the webhook integration.

Sample data lab API that receives condition monitor results and sends them out in slack in a readable format.
PY
# POST /condition_monitors_template
import traceback
import requests
import json
from datetime import datetime

"""
Request to the webhook will get a response with the results from a condition monitor search along with some metadata 
in the following format. 
===================                     ===================================================
Property                                Description
===================                     ===================================================
WebhookNotificationResult                   
    notificationConfiguration              
        notificationTriggerId           UUID Id of a condition monitor that triggered the notification
        contextualText                  A string with additional information configured on a notification like a    
                                            link to a workbook
        timezone                        A string timezone for the condition monitor
        capsuleGrouping                 CONDITION - One notification per one condition results
                                        CAPSULE - One notification per one capsule found
                                        ALL - All results in one notification
        capsuleProperties               A list of capsule properties selected to be sent with a notification
    conditionMonitorName                A string name of the condition monitor
    results                                 
        ConditionResultForWebhook           
            capsuleEvents                   
                conditionGuid           UUID id for condition that the capsule event belongs to
                source                     
                    capsule                 
                        start              
                            value       Start of the event 
                        end 
                            value       End of the event
                        properties      A map of properties
            conditionName               A string name of the condition that the capsules are part of         
====================================================================== 
"""
text = ""
try:
    data = REQUEST['body']
    conditionResults = data['results']
    conditionMonitorName = data['conditionMonitorName']
    notificationConfiguration = data['notificationConfiguration']

    text = f":scream: *{conditionMonitorName}:*\n\t"

    for conditionResult in conditionResults:
        conditionName = conditionResult['conditionName']
        capsuleEvents = conditionResult['capsuleEvents']
        for capsule in capsuleEvents:
            source = capsule['source']
            start = '' if 'start' not in source else 'Start: {0}\n\t'.format(datetime.utcfromtimestamp(int(source['start']['value'] / 1e9)).strftime('%Y-%m-%d %H:%M:%S'))
            end = '' if 'end' not in source else 'End: {0}\n\t'.format(datetime.utcfromtimestamp(int(source['end']['value'] / 1e9)).strftime('%Y-%m-%d %H:%M:%S'))
            duration = '' if 'Duration' not in source else 'Duration: {0}\n\t'.format(source['duration']['value'])
            text += f"Condition: {conditionName}\n\t"
            text += (start + end + duration)
            properties = source['properties']
            for capsuleProperty in notificationConfiguration['capsuleProperties']:
                if capsuleProperty in properties:
                    text += f"{capsuleProperty}: {properties[capsuleProperty]['value']}\n\t"
            text += "\n"
            
except Exception as e:
    text += f"{str(e)}\n"
    text += traceback.format_exc()
            
body = {'text': text}
url = 'https://hooks.slack.com/services/xxxxxxxxx/yyyyyyyyyyy/zzzzzzzzzzzzzzzzzzzzzzzz'
response = requests.post(url, json.dumps(body))

5. Once this script is placed in a Data Lab notebook, the user will be able to construct a relative URL of the following format:
/data-lab/{project_uuid}/sdl/api/notebooks/{notebook_name}/endpoints/{endpoint_path}?{query_string}
Once variables in this URL are replaced with real values from the Data Lab notebook, the URL will need to be set in the following configuration setting: Features/Notifications/ConditionMonitors/OutgoingWebhookUrl. This is the global notifications webhook. To receive notifications from a single condition monitor, set the condition monitor’s webhookUrl field via the API endpoint POST /condition-monitors/{id}.

6. Finally, to make the script work, the user needs to create a new Slack App that will post messages to a selected channel. For this step Slack has thorough documentation and guided tutorials. Some helpful resources are:

Once a user has created and configured the Slack App, Slack will provide a webhook URL that will replace the URL on line 68 in the data lab script provided above.


An example Slack message received after implementing the sample project:

😱 SaaS Application Alerts:
   Condition: Chocolate is lacking some sugar
    Start: 2021-03-12 11:05:05
    Customer: ChocolateFactory
    Domain: MagicLand
    Server: MagicServer1

Also see this YouTube video where a Microsoft Teams integration was deployed:

https://www.youtube.com/watch?v=ksghY0bWGHc

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.