Search code examples
complex-event-processingsiddhi

Siddhi absence of events


I am trying to write a query for a situation like "If you see value 10 and you do not see value 20 in the next 10 seconds trigger an alert" but have not been able to make the syntax work. According to this pull request this functionality was implemented over a year ago. My attempt at the query is:

define stream inStream(value int); 
            from every s1=inStream[value == 10]  
            -> not s2=inStream[value == 20] for 10 sec  
            select s2.value  
            insert into outStream

Looking at the grammar file in the Siddhi project this looks like it should be a valid query, however when I try and run it I get "Syntax error in SiddhiQL, no viable alternative at input". I am running this with siddhi-core 4.2.18. Is my syntax incorrect or do I have a different issue?


Solution

  • Found a solution to my issue at the tutorial site from the creator of the absence pattern PR. The issue was my syntax, the absence pattern's stream can not be named. So changing the query to

    define stream inStream(value int); 
            from every s1=inStream[value == 10]  
            -> not inStream[value == 20] for 10 sec  
            select s1.value  
            insert into outStream
    

    made it work perfectly.