获得X彼此X时间内收到的事件期间
给定以下输入:
[
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:00:00", "Event" : 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:01:00", "Event" : 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:05:00", "Event" : 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:10:00", "Event" : 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:15:00", "Event" : 1}
]
我想创建输出:
[
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:00:00", "Event" : 1, "Value": 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:05:00", "Event" : 1, "Value": 0}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:10:00", "Event" : 1, "Value": 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:11:00", "Event" : 1, "Value": 0}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:15:00", "Event" : 1, "Value": 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:16:00", "Event" : 1, "Value": 0}
]
当首次需要开始时需要开始事件1时(在输出事件中值= 1)。当在5秒内收到下一个事件时,延长了周期,直到未收到5秒的事件,则需要停止(在输出事件中值= 0)。该周期不能比1秒更小。
我该如何实现这种行为?我正在考虑在结果上使用HoppingWindow
lag ,但无法正常工作。你有线索吗?
我还想将规则“下一个事件进行5秒钟”,每个设备的灵活性。由于窗口功能具有编译时间持续时间,因此不确定是否可以使用。
感谢您的帮助!
Given the following input:
[
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:00:00", "Event" : 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:01:00", "Event" : 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:05:00", "Event" : 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:10:00", "Event" : 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:15:00", "Event" : 1}
]
I want to create the output:
[
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:00:00", "Event" : 1, "Value": 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:05:00", "Event" : 1, "Value": 0}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:10:00", "Event" : 1, "Value": 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:11:00", "Event" : 1, "Value": 0}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:15:00", "Event" : 1, "Value": 1}
{ "DeviceId" : "AA" : "Date": "2022-04-25 00:16:00", "Event" : 1, "Value": 0}
]
When event 1 is received for the first time a period needs to start (Value = 1 in the output events). When the next event is received within 5 seconds the period is extended until no event is received for 5 seconds then the period needs to stop (Value = 0 in the output events). The period cannot be smaller then 1 second.
How can I achieve this behaviour? I was thinking about using a HoppingWindow
with a Lag
over the result but couldn't get this working. Do you have any clues?
I also want to make the rule "next event withing 5 seconds" flexible per device. Not sure if this is even possible since the Window functions have a compile time duration.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试
lag
分析操作员或最后
分析操作员。感谢
@sivamuthu kumar
在 Azure流分析 - 警报。就像上述所述,借助
子句(CTE)分区(由DeviceID)按照方案进行时间间隔。
You can try with
LAG
analytic operator orLAST
analytic operator.Thanks to
@Sivamuthu Kumar
for his blog on Azure Stream Analytics - Alerts.Like in the above said, with the help of
WITH
clause (CTE) partition by the deviceId and the time interval as per the scenario.