【问题标题】:Get the period of events that are received within x time from each other获取彼此在x时间内收到的事件的周期
【发布时间】:2022-07-05 17:45:25
【问题描述】:

给定以下输入:

[
    { "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 秒。

我怎样才能实现这种行为?我正在考虑在结果上使用HoppingWindowLag,但无法正常工作。你有什么线索吗?

我还想让每个设备的规则“5 秒内的下一个事件”灵活。不确定这是否可能,因为 Window 函数具有编译持续时间。

谢谢你的帮助!

【问题讨论】:

    标签: azure azure-stream-analytics stream-analytics


    【解决方案1】:

    您可以尝试使用LAG 解析运算符或LAST 解析运算符。

    落后:它允许在特定约束内的事件流中查找previous 事件。

    最后的:它允许在定义的约束内的事件流中查找most recent 事件。

    感谢@Sivamuthu KumarAzure Stream Analytics - Alerts 上的博客。

    就像上面所说的,在WITH 子句(CTE)的帮助下,设备ID 和时间间隔根据场景进行分区。

    【讨论】:

      猜你喜欢
      • 2022-01-07
      • 1970-01-01
      • 2021-05-19
      • 1970-01-01
      • 2022-01-17
      • 2021-01-14
      • 2017-10-21
      • 1970-01-01
      • 2019-02-22
      相关资源
      最近更新 更多