Search code examples
apache-stormcomplex-event-processingesper

Esper - Can we do pipelined fashion processing using esper?


I want to do some event processing using Esper in a pipelined fashion. I need to check for multiple cases for every event. For instance, say, i want to run my incoming data against following cases. How would I do it? What is the best way of doing it?

case 1 = "If the current level is 400% greater than the average of last 5 consecutive values then mark the event with Exception-1"
case 2 = "If the current level value is null then mark as Exception-2"
case 3 = "If case 2 and case 3 are not matched, then the data is marked as 'safe'"

Following is the rough representation of what I want to do

     if (case1) { 
       mark with Exception 1 
     }

     if (case2) {
       mark with Exception 2 
     }

     if (none of the above cases matches) {
         mark as safe 
     }

Solution

  • Something like this

    on Event 
    insert into OutputStream select 'Exception 1' as label, * where level_detected > 400
    insert into OutputStream select 'Exception 2' as label, * where level_detected = null
    insert into OutputStream select 'safe' as label, *
    

    You didn't ask how to do the detection for "If the current level is 400% greater than the average of last 5 consecutive values" so this is not part of my answer.

    Esper docs for split stream