How can I trigger an alert based on the content of messages sent from a device to IoT Hub?

KURAMOTOAHUJATAIRA-3118 250 Reputation points
2023-06-22T03:46:27.55+00:00

I would like to send messages from a device to IoT Hub using an SDK and trigger alert emails based on the content of those messages (JSON). I have considered several methods and would appreciate it if you could suggest the optimal approach.
The crucial point is that I need to monitor the value of a particular key within a JSON message with a hierarchical structure and trigger an alert based on that value.

It would be greatly appreciated if you could also provide links for reference.

Method 1: Output the message content to IoT Hub logs (if possible) and create an alert rule based on that.

Method 2: Add the elements to be alerted on to the device twin, monitor updates to it, and trigger alerts accordingly.

Method 3: Send on the messages from IoT Hub to Event Hub, execute Functions using EventHubTrigger, and internally trigger alerts based on conditional branching within the Function.

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,271 questions
{count} votes

Accepted answer
  1. AshokPeddakotla-MSFT 35,971 Reputation points Moderator
    2023-06-22T06:50:27.08+00:00

    KURAMOTOAHUJA TAIRA (倉本A 平) Greetings!

    Your scenario looks interesting!

    Method 1: Output the message content to IoT Hub logs (if possible) and create an alert rule based on that.

    The IoT Hub logs are not designed for real-time monitoring and alerting. They are more suitable for long-term storage and analysis of device-to-cloud messages.

    Method 2: Add the elements to be alerted on to the device twin, monitor updates to it, and trigger alerts accordingly.

    You need to manage the device twin and monitor updates. Not be suitable if you have a large number of devices and need to monitor multiple keys within the JSON messages.

    Method 3: Send on the messages from IoT Hub to Event Hub, execute Functions using EventHubTrigger, and internally trigger alerts based on conditional branching within the Function.

    This is a recommended approach for real-time monitoring and alerting based on the content of JSON messages. You can use IoT Hub message routing to route the messages to an Event Hub, and then use Azure Functions with EventHubTrigger to process the messages and trigger alerts based on the content of the messages. This approach provides flexibility in terms of the types of alerts you can trigger and the actions you can take based on those alerts.

    Here are some references you might want to take a look for more details.

    Also, please refer below asks and lets us know if you have any other queries.

    IoTHub Alert based on message content

    How to configure alerts on Azure IOT hub device Data

    Hope this helps. Please let us know if you have any additional questions or need further assistance. We would be glad to help you.


    If the response helped, please do click Accept Answer and Yes . Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.