wearebob
wearebob

Reputation: 415

Filtering on prior events in Siddhi

Is it possible to detect if a prior event happened before a current one in Siddhi? I am trying to do something like "send alert if Y happened after X". I've gotten the inverse of that working (send alert if Y happened without X ever happening) with a query similar to this:

from s1=inStream[value == 'Y'] and  
    not inStream[value == 'X'] 
    select s1.person  
    insert into outStream  

and was hoping I would be able to make my intended query work by simply removing the "not", however that did not work.

Upvotes: 1

Views: 55

Answers (1)

suho
suho

Reputation: 912

Use the following query

from s1=inStream[value == 'X'] -> s2= inStream[value == 'Y'] 
select s1.person, s2.person   
insert into outStream;  

If you want to limit the time between X and Y (which is always recommended), Use

from s1=inStream[value == 'X'] -> s2= inStream[value == 'Y'] within 10 min
select s1.person, s2.person   
insert into outStream;  

Upvotes: 2

Related Questions