通过设备ID收集事件 [英] Collect events by device id

查看:67
本文介绍了通过设备ID收集事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

流分析中是否有可能根据事件的到来触发?例如,某设备具有事件X,Y和Z.如果事件Y到达,我希望SA等待20秒以查看该设备ID的事件X和Z是否也到达(同样,如果Z到达 首先,然后寻找X和Y).然后,它应该仅合并它已观察到的事件.

Is it possible in Stream analytics to trigger based on the arrival of an event? For example, a device has events X,Y and Z. If event Y arrives I want SA to wait for 20 seconds to see if events X and Z for that device id also arrives (likewise if Z arrives first then look for X and Y). It should then only combine the events that it has observed.

有什么建议吗?

推荐答案

为此,您可以使用

For this, you can use the LAG operator. However the logic will look backwards in the stream of events.

这里是一个示例:以下查询将等待事件Z,并检查事件X和Y是否较早到达.

Here's an example: the following query will wait for event Z, and check that events X and Y arrived earlier. 

SELECT deviceID, System.timestamp AS time FROM blobtest

WHERE eventType ="Z" AND LAG(读取)超过(eventType ="X"时按设备ID限制时长划分的部分(秒,20))不为空 AND LAG(读取)超过(eventType ="Y"时按设备ID限制持续时间(秒,20)划分的部分)不为空

WHERE eventType="Z" AND LAG(reading) OVER (PARTITION BY deviceID LIMIT DURATION(second, 20) when eventType="X") is not null AND LAG(reading) OVER (PARTITION BY deviceID LIMIT DURATION(second, 20) when eventType="Y") is not null

让我知道您是否还有其他问题.

Let me know if you have any further question.

谢谢

JS


这篇关于通过设备ID收集事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆