获得X彼此X时间内收到的事件期间

发布于 2025-02-11 16:03:19 字数 1185 浏览 1 评论 0原文

给定以下输入:

[
    { "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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遮云壑 2025-02-18 16:03:19

您可以尝试lag分析操作员或最后分析操作员。

滞后: 它允许在某些约束中的事件流中查找上一个事件。

最后一个: 它允许在定义约束中的事件流中查找最新的事件。

感谢@sivamuthu kumar Azure流分析 - 警报

就像上述所述,借助子句(CTE)分区(由DeviceID)按照方案进行时间间隔。

You can try with LAG analytic operator or LAST analytic operator.

LAG: It allows to look up previous event in an event stream within certain constraints.

LAST: It allows to look up the most recent event in an event stream within defined constraints.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文