【问题标题】:Siddhi query with conditions within multiple occurrences具有多次出现条件的 Siddhi 查询
【发布时间】:2020-04-01 11:33:15
【问题描述】:

我们可以编写 Siddhi 查询,在某些条件下很少发生事件,例如

对于 customerId 'xyz' 和 source 为 'log' 的 3 个事件,我们可以使用

from every (e1 = CargoStream[e1.customerId == 'xyz' AND e1.source = 'log']<3>)

但是我们需要做的是在这 3 个事件之间添加条件。 像所有这三个元素这样的东西应该具有相同的来源,而不是特定的值。

from every (e1 = CargoStream[e1.customerId == 'xyz' AND all these 3 events have same source does not matter the value]<3>)

我们尝试了访问索引事件的查询,但似乎不能很好地触发事件。

from every (e1 = CargoStream[e1.customerId == 'xyz' AND (e1[0].source == e1[1].sourse AND e1[1].source == e1[2].source)]<3>)

这甚至可以通过 Siddhi Query 实现吗?如果是,那么如何?

【问题讨论】:

    标签: complex-event-processing siddhi


    【解决方案1】:

    对于您的问题,在事件中具有相同的条件。你可以使用分区

    https://siddhi.io/en/v5.1/docs/query-guide/#partition

    另外,请查看这个问题 - https://github.com/siddhi-io/siddhi/issues/1425

    查询会像 -

    define stream AuthenticationStream (ip string, type string);
    @purge(enable='true', interval='15 sec', idle.period='2 min') 
    partition with (ip of AuthenticationStream) 
    begin
       from every (e1=AuthenticationStream[type == 'FAILURE' ]<1:> -> 
            e2=AuthenticationStream[type == 'SUCCESS' ]) within  1 min 
            select e1[0].ip as ip, e1[3].ip as ip4
            having not(ip4 is null)
            insert into BreakIn 
    end;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-18
      • 2017-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-08
      • 2021-07-26
      相关资源
      最近更新 更多