Search code examples
apache-flink

Is it possible to group the events based on certain parameter and running Flink CEP pattern in each group?


I have event like { "hostname":"abc.com", "data":{}} in a kafka topic. The events are json objects. My flink-kafka consumer is accessing these events. Now Inside flink CEP can I group these events based on hostname and on each group can I check for pattern?


Solution

  • To accomplish this you should key the stream by the hostname, with something like stream.keyBy(e -> e.hostname), and then apply the pattern to the keyed stream.

    Also of interest is that Flink 1.7 has added support for using MATCH_RECOGNIZE to do pattern detection. You might find it easier to express what you are trying to do with stream SQL and MATCH_RECOGNIZE.