WSO2 CEP:Siddhi QL:如何在匹配特定条件后持续提醒事件
WSO2 CEP : Siddhi QL: How to alert events consistently after matching certain condition
从下面的流中,我想提醒温度超过 90 时发生两次的事件(比如每 2 个温度 > 90 的事件都需要提醒)。
InputStream=[1001,91]
InputStream=[1001,86]
InputStream=[1002,70]
InputStream=[1001,85]
InputStream=[1003,70]
InputStream=[1003,85]
InputStream=[1002,70]
InputStream=[1003,70]
InputStream=[1003,87]
InputStream=[1002,70]
InputStream=[1001,95]
InputStream=[1001,96]
InputStream=[1001,97]
InputStream=[1001,98]
InputStream=[1001,98]
我写过这样的东西:
@Plan:name('TestExecutionPlan')
define stream InputStream (id string, temp int);
partition with (id of InputStream)
begin
from InputStream
select id, temp
having temp > 90
insert into CriticalStream
end;
from CriticalStream[count(id) == 2]
select id, temp
group by id
--having count(id) == 2
insert into EventReporter;
但是它只在 EventReporter 流中提醒 1 个事件。
Below is the screen shot from Try It
我希望 EventReporter 流也有 [1001,97] 和 [1001,98],现在它只有 [1001,95] 的记录。有人可以指出我在这里做错了什么。分组后如何循环事件?我尝试添加 window.time 和 window.length,但没有得到所需的输出。任何帮助/指导将不胜感激。谢谢。
那里不需要分区。您可以简单地使用过滤器和 lengthBatch window 来获得所需的输出。尝试以下执行计划;
@Plan:name('ExecutionPlan')
@Import('InputStream:1.0.0')
define stream InputStream (id string, temp int);
/* Filter events with temp > 90 */
from InputStream[temp > 90]
insert into CriticalStream;
/* Aggregate within a lengthBatch window, while group by id*/
from CriticalStream#window.lengthBatch(2)
select id, temp, count() as count
group by id
insert into EventReporter;
/* Just for logging the result in the cosole */
from EventReporter#log("Logging EventReporter : ")
insert into #temp;
从下面的流中,我想提醒温度超过 90 时发生两次的事件(比如每 2 个温度 > 90 的事件都需要提醒)。
InputStream=[1001,91]
InputStream=[1001,86]
InputStream=[1002,70]
InputStream=[1001,85]
InputStream=[1003,70]
InputStream=[1003,85]
InputStream=[1002,70]
InputStream=[1003,70]
InputStream=[1003,87]
InputStream=[1002,70]
InputStream=[1001,95]
InputStream=[1001,96]
InputStream=[1001,97]
InputStream=[1001,98]
InputStream=[1001,98]
我写过这样的东西:
@Plan:name('TestExecutionPlan')
define stream InputStream (id string, temp int);
partition with (id of InputStream)
begin
from InputStream
select id, temp
having temp > 90
insert into CriticalStream
end;
from CriticalStream[count(id) == 2]
select id, temp
group by id
--having count(id) == 2
insert into EventReporter;
但是它只在 EventReporter 流中提醒 1 个事件。
Below is the screen shot from Try It
我希望 EventReporter 流也有 [1001,97] 和 [1001,98],现在它只有 [1001,95] 的记录。有人可以指出我在这里做错了什么。分组后如何循环事件?我尝试添加 window.time 和 window.length,但没有得到所需的输出。任何帮助/指导将不胜感激。谢谢。
那里不需要分区。您可以简单地使用过滤器和 lengthBatch window 来获得所需的输出。尝试以下执行计划;
@Plan:name('ExecutionPlan')
@Import('InputStream:1.0.0')
define stream InputStream (id string, temp int);
/* Filter events with temp > 90 */
from InputStream[temp > 90]
insert into CriticalStream;
/* Aggregate within a lengthBatch window, while group by id*/
from CriticalStream#window.lengthBatch(2)
select id, temp, count() as count
group by id
insert into EventReporter;
/* Just for logging the result in the cosole */
from EventReporter#log("Logging EventReporter : ")
insert into #temp;