OverflowStack
OverflowStack

Reputation: 909

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?

Upvotes: 1

Views: 407

Answers (3)

Jay Gong
Jay Gong

Reputation: 23782

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.

Upvotes: 1

Jean-Sébastien
Jean-Sébastien

Reputation: 737

using Azure Stream Analytics, you can trigger the alert when the threshold is passed AND if it's the first time in the last 30s for example.

I give you the sample SQL for this example:

 SELECT *
 FROM input
 WHERE ISFIRST(second, 30) OVER (WHEN value> 90)=1

Let us know if you have any further question.

Upvotes: 1

user2667246
user2667246

Reputation: 31

I also agree with Jay's response about contradiction.

But one more way we can handle it, I also faced similar issue in one of my assignment, what I tried is keeping track of once sent alarm via cache (i.e. redi cache, memcache etc) and every time check if alarm already sent then don't sent . Obviously trade-off is that everytime we needs to check, but that's the concern that you needs to decide

We can also extend same to notify user if max temperature is reset to normal.

Hope this helps.

Upvotes: 0

Related Questions