Asset Tracking with Azure Stream Analytics

五迷三道 提交于 2020-01-17 05:32:07

问题


I have an event Hub and a stream analytics job sending data to Power BI. I was wondering what would be the best way to configure the event hub / for asset tracking?

e.g I have multiple clients sending to the event hub -> stream analytic job and I want to be able to determine if a client with a particular ID goes offline?

Cheers!


回答1:


If the list of IDs is relatively static, then you can use reference data join to output all IDs that are missing in each time window.

If you want to infer the IDs from the stream itself, and want to detect when an ID that was active in previous window is not active in current window, you can use stream join. Here is an example

with MissingAssets as
(
select
    PreviousWindowSignal.signalTime,
    PreviousWindowSignal.AssetId
from
    AssetSignalStream PreviousWindowSignal Timestamp by signalTime
left outer join
    AssetSignalStream CurrentWindowSignal Timestamp by signalTime
 on
    PreviousWindowSignal.AssetId = CurrentWindowSignal.AssetId
    and datediff(second,PreviousWindowSignal,CurrentWindowSignal) between 1 and 300
where
    CurrentWindowSignal.AssetId is null
 )

 select
    AssetId,
    max(signalTime) MostRecentSignalInWindow 

 from 
    MissingAssets 
  group by
    AssetId,
    TumblingWindow(ss,300)


来源:https://stackoverflow.com/questions/32208844/asset-tracking-with-azure-stream-analytics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!