I could use some help conceptualizing the right wa...
# troubleshooting
n
I could use some help conceptualizing the right way to frame a problem in Flink. I can’t use the complex event processing system due to the nature of other requirements. Anyway, say I have a data stream of events where each event has an event time and a Boolean field (call it A for simplicity). I’d like to send an alert out if we ever see a continuous stretch of events where A is true for at least five seconds. Put another way, alert if we did not see an event where A was false within five seconds of an event where A was true. My gut tells me that some combination of a sliding window and custom trigger is what this calls for, but I can’t quite nail it down.
👍 1
s
Since its more than one dimension, check this Flink-CEP (Complex Event Processing) - https://nightlies.apache.org/flink/flink-docs-master/docs/libs/cep/
n
I don’t believe I can use complex event processing. I’m making a system for users to configure dynamic rules to monitor data from our systems.
Also, is CEP supported for pyflink?
s
not sure of pyflink
sliding window should work, curious on how users will configure rules , sql?
n
Rules enter the system as part of a control stream that is broadcasted and then connected to the input stream of data to process. The motivation for this pattern is similar to what was developed in https://github.com/brggs/dynamic-flink
👍 1
So the idea is you make a broadcast process function to update rules when new broadcast elements arrive or run data against the existing rules in the system when input elements arrive.
That lets me say whether or not rule N is violated and I could generate a side output saying so. But I’m interested in making sure rule N is violated continuously (at least as we know based on input data) for a certain time.
My concern with using sliding windows is that I don’t want to miss alerts just because of poorly tuning the window slide amount.
s
saw this video few months back, hope it help -

https://www.youtube.com/watch?v=7-3PkL_cYeI▾

n
Thanks, I’ll check it out! I think the problem is much easier if we only cared about the latest data with respect to event time and then gets more challenging if we want to alert on older data coming in out of order.
s
smaller windows should be ok, like temp > 100C for 10 min , if you are watching for 1-2 hrs, its tricky
n
Do you think session windowing would make more sense to more dynamically handle the variable nature of the throughput?
Eh probably not. Probably better to have sliding with a length around the time of persistence we want for a condition.
s
Yeah, Sliding is best bet, depends on time interval
d
Sliding windows aren’t ideal for this — because their behavior doesn’t precisely match your requirements. The issue is that sliding windows are aligned to the epoch, whereas in your example, you’d like to consider an interval of 5 seconds relative to the first event where A is true. You could implement custom windowing that handles this, but this will be rather more straightforward to implement using a process function.
n
Yes, that was my concern. Getting the windows right felt like it could miss things.
Windows seemed like the natural choice because it would let me focus on a collection of the historical data at a time rather than globally observing all recent history.
d
If you try to use windows, you’ll basically end up in the same place. I think you’f need to use GlobalWindow with a custom Trigger and Evictor — which is a mess to deal with. A KeyedBroadcastProcessFunction will probably lead to a cleaner implementation — and besides, you can’t broadcast into a window.