IoTHub Alert based on message content

Lucas 41 Reputation points
2020-12-30T20:13:26.587+00:00

Hello,

One of my modules constantly reports data up to IoTHub as messages periodically. If two data metrics do not match (which in our case means something is wrong), my module also sends a different message to IoTHub called "ALERT". I know IoTHub has its own system of alerts and I would like to receive an email every time this ALERT message is sent so that I am notified that the equipment is malfunctioning. What is the best way to do this?

I have looked into the Alert functionality of IoTHub and all conditions seem to be linked to a quantitative number (such as failed messages, connected devices, etc) instead of letting me set something like if message == "ALERT" or something in those lines. Any advice would be appreciated, thanks.

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
598 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,272 questions
{count} votes

Accepted answer
  1. Sander van de Velde | MVP 36,761 Reputation points MVP Volunteer Moderator
    2020-12-31T01:29:03.273+00:00

    Hello @Lucas ,

    The IoT Hub supports alerts which can be triggered based on 'meta' conditions.

    You can eg. trigger an action group (for eg. email or SMS) based on conditions that are not related to single messages but related to the IoT Hub itself. The IoT Hub collects metrics. These metrics can trigger actions.

    See also this MS Learn module.

    If you want to send emails based on your own logic, you have to rely on email functionality in Azure resources like sending a message with eg. the SendGrid API (using a SendGrid account and an Azure function) or a logic app.

    For example, I used the IoTHub message routing feature to send alerts to an Event Hub. These alert messages in the Event Hub were picked up by a Logic app:

    52364-image.png

    To enrich the messages or make the alerting smarter (eg. sending a maximum of 1 message each X minutes) you can add Azure Stream Analytics in between the IoT Hub and the EventHub. (ASA then acts as a rule engine).

    1 person found this answer helpful.
    0 comments No comments

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.