问题
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