Chapter 9. Detecting event patterns
The chapter explains event pattern detection as a core capability of event processing, where meaningful combinations of events are identified rather than just individual occurrences. It introduces a Pattern detect agent that filters incoming events, selects the relevant ones as participant events, and then applies a pattern signature made up of a pattern type, relevant event types, optional parameters, and policies. The result of matching is a pattern matching set, which may be a single event, a subset of the participants, or even an empty set in cases such as absence patterns.
A major part of the chapter classifies common pattern types. Basic patterns include logical operators like all, any, and absence, threshold-based patterns such as count and value max/min/average, subset-selection patterns like first n, last n, and top-n variants, and modal patterns like always and sometimes. Dimensional patterns extend this idea into time, space, and combined spatiotemporal behavior, covering sequence, trends over time, distance-based checks, and movement patterns such as stationary, moving toward, or moving in a constant direction. Throughout these definitions, the text emphasizes how the meaning of a match depends on what portion of the participant set must satisfy the condition.
The chapter also shows that pattern matching is shaped by policies that resolve ambiguity and control runtime behavior. Evaluation policies decide whether matching happens immediately or only when a context closes, cardinality policies limit how many matching sets are produced, repeated type policies choose which instances are used when more than one event of a type is available, consumption policies determine whether matched events can be reused, and order policies define how temporal order is interpreted. The Fast Flower Delivery application is used repeatedly to illustrate these ideas in practice, showing how different patterns can support assignment, alerts, performance evaluation, and trend detection across multiple event-processing languages.
The logical structure of a Pattern detect agent, showing its three logical parts, with the “pattern signature” that controls the pattern detection process. The triangular objects represent event instances.
Illustration of the all pattern—an instance of every event type listed as a relevant event type must be present for the pattern to be matched. In this case there are three relevant event types (flight reservation, car reservation, and hotel reservation), and you can see that the participant event set includes an instance of each type.
A used book selling application that shows use of the Not-selected terminal. Book offer events are shown at the top, and book orders at the bottom. Two orders and one offer are left unpaired, and these will be routed through the agent’s Not-selected output terminal.
A count pattern where three instances of the same event type—customer complaint—match the pattern and suggest the likelihood of a frustrated customer
A trading example where the participant event set contains three events (two buy events and one sell event). The value max pattern will detect a match as the third event exceeds the $10M threshold.
This example illustrates modal patterns. The problems are assigned to a particular service representative, during the morning shift from 9:00 – 12:00.
A sequence pattern example—a patient who is readmitted to the hospital within 48 hours of having been discharged
A health monitor example used to illustrate various temporal trend patterns
An example showing the location of two delivery vans and three flower stores in the Fast Flower Delivery application. This demonstrates absolute distance patterns.
Examples that demonstrate three relative distance patterns. Going clockwise from the top right they are relative max distance, relative min distance, and relative average distance.
Spatiotemporal patterns where the events are reports of aircraft location
An example of the all pattern where there are multiple events of the same type
The effect of different evaluation and cardinality policies, when the repeated type policy is last. The events shown at the top of the figure give rise to the matching sets shown at the bottom.
An Apama example that shows the code for the Ranking increase and Improving note Pattern detect agents from the Fast Flower Delivery application
StreamBase implementation of the Automatic assignment pattern
IBM WebSphere Business Events example showing some patterns from the Fast Flower Delivery example
Event Processing in Action ebook for free