Search code examples
azureazure-stream-analytics

Proper way of implementing Azure Stream Analytics notifications/alarms service


I'm working with sensor systems where each sensor sends a new reading every 15 seconds.

Each sensor type also has defined rules that when triggered will generate an alarms output - e.g. sensor of type "temperature" sends a value that is higher than MAX temperature allowed.

Lets assume sensor with ID "XXX_01" sends 2 readings in 30 seconds, each reading has higher value than MAX value allowed.

Event in: 01/10/2018 12:00:00
{ id:"XXX_01", value: 90, "temperature" } 

Event in: 01/10/2018 12:15:00
{ id:"XXX_01", value: 95, "temperature" }

Now, I want to notify the end user that there is an alarm - I have to send out some sort of a notification to end user(s). The problem and confusion is that I do not want to send out the alarms twice.

Assuming I use something like Twilio to send SMS or just send out Email notifications, I don't want to spam my end users with a new notification every 15 seconds assuming incoming sensor readings stay above MAX value allowed.

What kind of an Azure Service, architecture or design paradigm could I use to avoid such issue?


Solution

  • I have to say that A (don't want to spam users notification) and B (alarm high temperature as soon as it touches MAX line) have some contradictions. It's hard to implement it.

    In my opinion, you can send notifications to users at a fixed frequency.

    1.In that frequency period, such as 1 minute, use Azure stream analytics service to receive sensor data every 15 seconds.

    2.Then output the data to Azure Storage Queue.

    3.Then use Azure Queue Time Trigger to get latest temperature value in the Azure Storage Queue current messages every 1 minute. If it touches MAX line,then send notification to end users. If you want to notify user that it touched MAX line no matter it already dropped, then just sort the messages by value and judge it.

    4.Finally, empty the queue.