Create a telemetry rule and set up notifications in your Azure IoT Central application

This article applies to operators, builders, and administrators.

Note

You're currently viewing the IoT Central documentation for application templates that use generally available features. To view the documentation for application templates that use preview features, go to What is Azure IoT Central (preview features)?.

You can use Azure IoT Central to remotely monitor your connected devices. Azure IoT Central rules enable you to monitor your devices in near real time and automatically invoke actions, such as send an email or trigger Microsoft Flow. In just a few clicks, you can define the condition for which to monitor your device data and configure the corresponding action. This article explains how to create rules to monitor telemetry sent by the device.

Devices can use telemetry measurement to send numerical data from the device. A telemetry rule triggers when the selected device telemetry crosses a specified threshold.

Create a telemetry rule

To create a telemetry rule, the device template must have at least one telemetry measurement defined. This example uses a refrigerated vending machine device that sends temperature and humidity telemetry. The rule monitors the temperature reported by the device and sends an email when it goes above 70° F.

  1. Using the Device Templates page, navigate to the device template for which you are adding the rule for.

  2. If you haven’t created any rules yet, you see the following screen:

    No rules yet

  3. On the Rules tab, select + New Rule to see the types of rules you can create.

  4. Select Telemetry to create a rule to monitor device telemetry.

    Rule Types

  5. Enter a name that helps you to identify the rule in this device template.

  6. To immediately enable the rule for all the devices created for this template, toggle Enable rule for all devices of this template.

    Rule Detail

    The rule automatically applies to all the devices under the device template.

Configure the rule conditions

Condition defines the criteria that is monitored by the rule.

  1. Select + next to Conditions to add a new condition.

  2. Select the telemetry you want to monitor from the Measurement dropdown.

  3. Next, choose Aggregation, Operator, and provide a Threshold value.

    • Aggregation is optional. Without aggregation, the rule triggers for each telemetry data point that meets the condition. For example, if the rule is configured to trigger when temperature is above 70° F then the rule triggers almost instantly when the device reports temperature > 70.

    • If an aggregate function like Average, Min, Max, Count is chosen then, the user must provide an Aggregate time window over which the condition needs to be evaluated. For example, if you set the period as "5 minutes" and your rule looks for Average temperature above 70, the rule triggers when the average temperature is above 70° F for at least 5 minutes. The rule evaluation frequency is the same as the Aggregate time window, which means, in this example, the rule is evaluated once every 5 minutes.

      Condition

      Note

      More than one telemetry measurement can be added under Condition. When multiple conditions are specified, all the conditions must be met for the rule to trigger. Each conditon gets joined by an 'AND' clause implicitly. When using aggregate, every measurement must be aggregated.

Configure actions

This section shows you how to set up actions to take when the rule is fired. Actions get invoked when all the conditions specified in the rule evaluate to true.

  1. Choose the + next to Actions. Here you see the list of available actions.

    Add Action

  2. 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.

    Note

    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 Azure IoT Central.

    Configure Action

  3. 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 is met, the rule triggers the configured email action.

You can add other actions to the rule such as Microsoft Flow and webhooks. You can add up to 5 actions per rule.

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 70° F. When the rule executes, it matches the device telemetry with the value set 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 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

Navigate to the device and choose the rule you want to enable or disable. Toggle the Enable rule for all devices of this template button in the rule to enable or disable the rule for all devices that are associated with the device template.

Enable or disable a rule for a device

Navigate to the device and choose the rule you want to enable or disable. Toggle the Enable rule for this device button to either enable or disable the rule for that device.

Next steps

Now that you have learned how to create rules in your Azure IoT Central application, here are some next step: