complex-event-processing - 具有多次出现条件的 Siddhi 查询
问题描述
我们可以编写 Siddhi 查询,其中很少发生具有某些条件的事件,例如
对于 customerId 'xyz' 和 source 作为 'log' 的 3 个事件,我们可以使用
from every (e1 = CargoStream[e1.customerId == 'xyz' AND e1.source = 'log']<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甚至可以做到这一点吗?如果是,那么如何?
解决方案
对于您的问题,在事件中具有相同的条件。你可以使用分区
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;
推荐阅读
- android - android回收器中的适配器未连接错误
- bash - 使用 Seq 和变量遍历列表
- vue.js - 组件中的 Vue i10n
- github - AWS CloudFormation CodePipeline:无法从 GitHub 获取存储库的内容
- wso2 - WSO2 API Manager 2.1 升级到 2.6
- android - Firebase 取消链接不会完全取消链接 Facebook 提供商
- amazon-web-services - 使用自定义文件夹而不是 ~/.aws
- javascript - 这是什么日期时间格式?即:“1551927028”
- python - 内存核心转储 C++
- apache-kafka - 有没有办法使用 Kafka Confluent REST API 生成带有标头的 Kafka 消息?