How to count the number of events in a single window with Stream analytics?

301 Views Asked by At

I am trying to create a query that uses StreamAnalytics's SlidginWindow function and outputs more than five events in 5 minutes

Although it is possible to count if there is a record with the following code, this case is 1 record 5 events so it can not be used

SELECT
   COUNT(*)
FROM
   TABLENAME
GROUP BY 
   SlidingWindow(minute, 5) 
HAVING COUNT
   (*) >= 4 
1

There are 1 best solutions below

0
On

What do you mean "1 record 5 events"? If you have a complex property on your event that has an array, you can use CROSS APPLY and GetArrayElements to expand each item and perform your calculation. Here is the MS documentation:

CROSS APPLY - https://msdn.microsoft.com/en-us/library/azure/dn706229.aspx

GetArrayElements - https://msdn.microsoft.com/en-us/library/azure/mt298451.aspx