Search code examples
esper

How to track esper query state and all window events?


For example

select * from eventWindow.win.time(5 sec) group by attr1 having count(*) > 10;

want to track current state of the above query after every 1 second. Am use

output all every 1 sec

but it output when query meet all the conditions.

Thanks in advance.


Solution

  • You could do it like this:

    insert into CountPerAttr1 select count(*) as cnt, * from eventWindow.win.time(5 sec) group by attr1
    

    ... and then

    select * from CountPerAttr1(cnt > 10) // detect threshold
    

    When you want to have the current count you can use "safeIterator" or "iterator" on the first statement. If you also want to output every 1 sec you could do:

    select * from CountPerAttr1.std:unique(attr1) output snapshot every 1 sec
    

    I think you could also play with the Esper "table" feature for sharing aggregation state in different ways.