Streaming checklists in Nominal with Python
Overview
Nominal’s streaming checklists allow you to continuously monitor real-time data from a connection and trigger alerts whenever certain conditions are met. This guide walks you through the process of setting up and running a streaming checklist in Python using the Nominal client.
To run a streaming checklist and receive notifications, we will create/select the following in the next steps:
- A Connection.
- A Run, needed to create a Checklist in the web GUI. It is used as a preview for the checklist.
- An Asset.
- A Checklist.
- Stream some data to trigger notifications.
Prerequisites
Make sure you have the nominal Python packages installed. You can install it using:
Connect to Nominal
Get your Nominal API token from your User settings page.
See the Quickstart for more details on connecting to Nominal from Python.
Create a Connection to Nominal’s Internal Time Series Database
You only need to run the code below to create a connection once!
Moreover, you may not even need to create a new connection if you or a
colleague has already set one up. Check the connections page
for existing connections where Type = nominal
and Status = Connected
.
To stream data to a Connection, first create a connection to Nominal’s internal time series database. The
datasource_id
must be unique within your organization, and connection_name
is a friendly name that will appear on
the Nominal platform under all connections.
You can access this connection later using its rid
. You can find the rid
in connection.rid
of the code above
or look it up on the Nominal platform in the “Connections” section and use it in the nm.get_connection() function
Create a Run and Stream Test Data
Here, we’ll create a temporary run, associate it with our connection, and then stream some initial data.
Create an Asset
Create the Checklist in the Nominal Web UI
- Go to the Checklist Page.
- Click on
New checklist
. - Select the ‘temporary_run’ you created above.
- Enter a name for the first check and a priority and click
Add check
- Define a check:
- In the field next to
when
, selectmy_channel_name
. - in the next field select
>
.
- In the field next to
- you should now see the violations in the chart. Zoom in if necessary.
- click on
Publish
in the top-right corner. - From the dropdown next to the checklist name (
⌄
), copy the rid of the checklist. - Paste the rid in the code below.
Select an Integration for Notifications
A streaming checklist needs an integration to send alerts to. You can find available integrations in the Integrations Page copy the rid and paste it in the code below.
Execute the Streaming Checklist
With the checklist and asset ready, and an integration selected, you can now execute the streaming checklist:
Monitoring and Managing Streaming Checklists
- List running streaming checklists:
- Stop a running streaming checklist:
Stream More Data to Trigger Notifications
Now that your streaming checklist is active, send more data to trigger notifications. The following code continuously sends data points every 2 seconds. When conditions are met, notifications will be sent to the configured integration.
Example Alert (Slack): You should now receive real-time notifications through your chosen integration. For Slack, the messages might look like this: