Create a telemetry rule and set up notifications in your Microsoft IoT Central application
You can use Microsoft IoT Central to remotely monitor your connected devices. Microsoft IoT Central rules enable you to monitor your devices in near real time and to automatically invoke actions, such as sending an email, when the rule triggers. In just a few clicks, you can define the condition to monitor your device data and configure the action to invoke. This article explains telemetry rule in detail.
Microsoft IoT Central uses telemetry measurements to capture device data. Each type of measurement has key attributes that define the measurement. You can create rules to monitor each type of device measurement and generate alerts when the rule triggers. A telemetry rule triggers when the selected device telemetry crosses a specified threshold.
Create a telemetry rule
This section shows you how to create a telemetry rule. This example uses a connected air conditioner device that sends temperature and humidity telemetry. The rule monitors the temperature reported by the device and sends an email when it goes above 80 degrees.
To create and configure a rule for a device template, Builder mode must be on.
When Builder mode is on, navigate to the device details page for the device you are adding the rule to.
If you haven’t created any rules yet, you see the following screen:
On the Rules tab, choose + New Rule to see the types of rules you can create.
Choose the Telemetry tile to open the form to create the rule.
Choose a name that helps you to identify the rule in this device template.
To immediately enable the rule for all the devices created from this template, toggle Enable rule.
Configure the rule condition
This section shows you how to add a condition to monitor the temperature telemetry.
Choose the + next to Condition.
Choose the Temperature telemetry type from the dropdown. Then choose the operator and provide a threshold value. You can add multiple telemetry conditions. When multiple conditions are specified, all the conditions must be met for the rule to trigger.
Select at least one telemetry measurement when you define a telemetry rule condition.
Configure the action
This section shows you how to specify what the rule does when the condition matches by adding an action.
Choose the + next to Actions. Here you see the list of available actions. During public preview, Email is the only supported action.
Choose the Email action, enter a valid email address in the To field, and provide a note to appear in the body of the email when the rule triggers.
Emails are only sent to the users that have been added to the application and have logged in at least once. Learn more about user management in Microsoft IoT Central.
To save the rule, choose Save. The rule goes live within a few minutes and starts monitoring telemetry being sent to your application. When the condition specified in the rule matches, the rule triggers the configured email action.
Parameterize the rule
Rules can derive certain vales from Device Properties as parameters. Using parameters is helpful in scenarios where telemetry thresholds vary for different devices. When you create the rule, choose a device property that specifies the threshold, such as Maximum Ideal Threshold, instead of providing an absolute value, such as 80 degrees. When the rule executes, it matches the device telemetry with the value provided in the device property.
Using parameters is an effective way to reduce the number of rules to manage per device template.
Actions can also be configured using Device Property as a parameter. If an email address is stored as a device property, then it can be used when you define the To address.
Delete a rule
If you no longer need a rule, delete it by opening the rule and choosing Delete. Deleting the rule removes it from the device template and all the associated devices.
Enable or disable a rule for a device template
To enable or disable a rule for a device template, first switch Builder Mode on. Toggling the Enable button in the rule enables or disables the rule for all devices associated with the device template.
Enable or disable a rule for a device
To enable or disable a rule for a specific device, first switch off the Builder Mode. Navigate to the device and choose the rule you want to enable or disable. Toggle the Enable button to either enable or disable the rule for that device.
Now that you have learned how to edit rules in your Microsoft IoT Central application, here is the suggested next step: