WSO2 CEP : Siddhi QL: Creating a unique stream with similar event records

*爱你&永不变心* 提交于 2020-01-07 03:11:30

问题


I am pretty new to WSO2 CEP Siddhi QL, I got a requirement to analyze the events coming to a stream.

For ex: I have data coming in like this [id,value]:

InputStream=[1001,90]
InputStream=[1001,85]
InputStream=[1002,70]
InputStream=[1001,85]
InputStream=[1003,70]
InputStream=[1003,85]
InputStream=[1002,70]
InputStream=[1003,70]
InputStream=[1003,85]
InputStream=[1002,70]
InputStream=[1001,95]
InputStream=[1001,65]

In this, I want to segregate each records and group based on the id 1001, 1002 and 1003 records and create a new temp stream for each one of the id's grouped and check the highest value in that and alert it. Tried different patterns and joins, however not able to zero-in to an exact solution.

Any help / guidance towards the solution would be greatly appreciated. Thank you.


回答1:


In Siddhi its not possible to create new streams based on the event values. However since your requirement is to have groups based on the id and alert the highest value of each group. We could achieve that with a single output stream. What we need to do is maintain a window (time or length window) for a duration, then group by on id and select max(temp) and insert into alert stream. Please refer following sample siddhi query.

from TempStream#window.time(2 min)
select max(temp) as highestTemperature
group by id
insert into alertStream;


来源:https://stackoverflow.com/questions/43186895/wso2-cep-siddhi-ql-creating-a-unique-stream-with-similar-event-records

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!