You can trigger just about anything on any app with a DataSet Alert. If you want to know more about how powerful our timeseries database built upon our Event Data Store can be or want to know more about how to set up alerts, check out our alerting video series here: https://www.youtube.com/watch?v=dUIwVyrF33I&list=PL-cmxw5jVDx-Jt2WYVCCZAiP8-WPaMi77
The following will show you how to trigger a workflow in Azure Logic Apps. This will enable you to initiate custom logic in the Internet of Things and Azure.
What you will do
- Create a DaaSet Alert
- Trigger an IoT workflow
- Create Zendesk ticket from DataSet Alert
Prerequisites
- DataSet (Paid)
- Azure (Paid)
1. Azure
- Create a Logic App
- Click into your app with the resource is available.
- Select "When a HTTP request is received" under the common triggers.
- Define your schema. In my case it is this, but this is flexible depending on the body you send in the alert.
{
"type": "object",
"properties": {
"key": {
"type": "string"
},
"trigger": {
"type": "string"
},
"description": {
"type": "string"
},
"title": {
"type": "string"
},
"link": {
"type": "string"
},
"id": {
"type": "string"
}
}
} - Press save
- Copy HTTP POST URL you will need this for the DataSet Alert
- Skip to the DataSet section (2) and continue those instructions. Resume Step 8 AFTER you have completed the DataSet section (2).
-
Once you have set up the DataSet Alert, You can trigger anything you want from here including writing to any database, pub/sub, Functions, Event Hub, or external APIs. In this case, we will create a Zendesk ticket.
- Authenticate into Zendesk
- Create Item
- Tickets
- Enter a description with the alert fields
- Enter a requester_id
- Save and backout.
2. DataSet
- Create a new alert. (Check out our alerting series for a comprehensive tutorial of how DataSetAlerts work)
- We can modify the alert via the UI or JSON. For this example, we will use JSON. This will alert if the latency defined in
timeMs
exceeds 7500ms)
{
A video explanation of DataSet Alerts JSON configuration file can be found here
alertAddress: "webhook-trigger:POST URL[[BODY]]&content-type=application/json",
description: "Delays over 7.5s",
renotifyPeriodMinutes: 60,
resolutionDelayMinutes: 5,
trigger: "count:2 minutes(timeMs > 7500) > 0",
gracePeriodMinutes: ""
}, - For the
alertAddress
, add the webhook address we copied from step 1.4
{
alertAddress: "webhook-trigger:POST https://prod-31.eastus.logic.azure.com:443/workflows/xxxx/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=xxxxxxxxxxxxxxxxxxxxxxxxx[[{\"key\":\"value1\",\"trigger\":\"#trigger#\",\"description\":\"#description#\", \"title\":\"#title#\", \"link\": \"#link#\", \"id\": \"#id#\"}]]&content-type=application/json",
description: "Delays over 7.5s",
renotifyPeriodMinutes: 60,
resolutionDelayMinutes: 5,
trigger: "count:1 minutes(timeMs > 7500) > 0",
gracePeriodMinutes: 0
}, - In the [[BODY]] section, add static data like
"key":"value"
or dynamic data including Template Parameters or Substitution Tokens. You can send text, but I am formatting JSON
Token Replaced by #trigger# The trigger expression that determines when the alert fires. #description# The description you've specified for the alert. If absent, the trigger expression is used. #title# The first line of the description. #link# A link to the alert. #id# A short token identifying the alert. - Trigger the alert. - You need to trigger to provide Zapier with test data. In my test, I changed the trigger to something that will always be true (like timeMs > 1) to get test data, then changed it back to the original threshold once I confirmed that everything worked as expected.
- Finish configuring Zapier. Go to step 1.6
Comments
0 comments
Please sign in to leave a comment.