I have an event stream which contains the values for some variables. The values change every second. Each variable has high limit, low limit and a threshold period defined.
For example, say Variable1 has high limit = 95, low limit = 5 and threshold = 5 seconds.
So if the values for Variable1 stay above 95 (high limit) for the threshold period (5 seconds), then we should create an output event.
I am able to create query for checking the individual events (if they have crossed the limits), but I am not sure how to create a windowed query to check if the limits were violated for the threshold period.
Thanks,
Well, not entirely a Linq query, but should do the trick:
Basically:
The you can use it like this:
Note: If your events come in as a potentially infinite stream and your event windows can get very large then you won’t get the window returned until it’s fully consumed which might take some time and memory. You could break the
TakeWhilepart after having seen 5 elements and then yield there and simply skip the rest of the window afterwards. It depends a bit of what you want to do exactly.