I want to do the following statistic in WSO2 CEP:
get the count() of all events that arrive in a stream. And I want to do it for the following windows: 5 min, 10 min, 30 min, 60 min. For this I am doing the following code:
from stream#window.time(5 min)
select count() as numEvents
insert into stats;
from stream#window.time(10 min)
select count() as numEvents
insert into stats;
from stream#window.time(30 min)
select count() as numEvents
insert into stats;
from stream#window.time(60 min)
select count() as numEvents
insert into stats;
Is this the correct way of getting this data? This seems like a huge replication of code when the only thing that I want to achieve is to increment the timewindow. Is there any other possibility on doing this in only 1 query? or at least less queries then 4.
What you have figured out (that is, by using 4 queries, each having a window) is the only possible way to achieve your requirement, as far as I know.
According to Siddhi language, a window is defined in-line in a query. According to your requirement, you need four windows; hence you need to write four queries.