Overview

Chapter 8. Filtering and transformation

Event processing networks rely on filtering and transformation to shape large streams of incoming events into useful forms before deeper analysis or delivery to consumers. Filtering is used to remove irrelevant events, route events to different downstream paths, or restrict what an agent can accept, while transformation changes event content by projecting, translating, enriching, splitting, aggregating, or composing events. The chapter emphasizes that these operations can be stateless, where each event is handled independently, or stateful, where the result depends on context, accumulated history, or related events from other streams.

A central theme is that filtering can be expressed in several places and at several levels. An input terminal filter provides a simple, stateless pass/fail gate; a dedicated Filter agent can also produce separate filtered-in and filtered-out streams, making it useful for branching logic and sampling; and a context definition can implicitly filter events by determining which ones belong to a partition. The chapter uses XPath as a practical example of a filter language, showing how event types, attribute presence, comparisons, logical operators, and built-in functions can be used to test event content and structure. It also explains stateful filtering patterns such as first, last, and random sampling over temporal windows.

On the transformation side, the chapter explains how agents can create derived events from one or more inputs, often using XSLT, scripting, or other expression languages. Project removes unwanted attributes, Translate modifies or adds attributes, and Enrich combines event data with external reference data from global state, including handling multiple query results through policies such as first, last, every, or combine. Split breaks one event into many, Aggregate combines many events into summarized output using derivation functions like count, sum, and avg, and Compose performs a join between two streams using match conditions, buffers, and unmatched-event policies. The discussion concludes by addressing event header behavior, validation, and how these concepts are used in the Fast Flower Delivery application and in practical event processing tools.

In this example the event processing agent has a filter expression on its input terminal that allows in only a subset of the events emitted by the event producer.
A schematic view of the Filter event processing agent
Using two successive Filter agents to divide an incoming event stream into three substreams
A Filter EPA showing the logical position of the partition filter, after the input terminal and before the internal filter step
Classification of the different types of Transformation agents. The triangles represent event instances; the arrows show the number of input and output streams for each type.
Internal logic of a transformation agent
A Project agent can be used to simplify an event by removing one or more of its attributes.
A Translate event processing agent can be used to insert new attributes into the output event.
The Enrich agent augments the output event with attribute values derived by querying a global state element.
The Request enrichment agent from the Fast Flower Delivery application. This agent uses the store attribute of the input event to find the flower store’s neighborhood and the minimum driver ranking that is acceptable to it, and adds these values as attributes to the output event.
A Split event processing agent
An Aggregate EPA, showing the state accumulation step
The Daily assignments calculator agent from the Fast Flower Delivery application. This shows how an Aggregate agent can be used to count the number of Assignment events associated with a given driver on any one day.
The Compose event processing agent
Use of a Compose event processing agent to match up vehicle arrival and departure times
Locating a Fast Flower delivery driver in the city of Florence
Listing 8.2. JavaScript implementation of a simple reverse geocode translation
The Bid Request creator agent from the Fast Flower Delivery application. This agent queries the Driver status table to find suitable drivers and creates a Bid Request event containing the names of these drivers in its drivers list attribute.
The Assignment manager agent monitors incoming delivery bids. It rejects them if the committed pickup time is too far out. If no bids are received it raises a No Bidders alert.
The Delivery Bid event is first enriched with the store’s automatic/manual assignment preference and then routed using a Filter agent.
The Daily statistics creator agent. This runs once a day to calculate statistics for the whole cohort of drivers, so that the performance of an individual driver can be assessed.
Example of a filter from the StreamBase product
A transformation example in MonitorScript

FAQ

What is event filtering in an event processing network?Event filtering is an operation that takes an event instance as input and decides whether that event should be selected for further processing. Events that pass are filtered in; events that fail are filtered out.
Where can filters be specified in an event processing network?Filters can be specified in three places: on an input terminal, as part of a dedicated Filter event processing agent, or as part of an event processing context definition.
What kinds of filter expressions can be used on an input terminal?Input terminal filters can use event type filter expressions, event header filter expressions, and event content filter expressions. These can be combined on the same terminal.
How does XPath support filtering event instances?XPath can be used as a filter by treating event attributes as XML-like nodes. A path expression passes an event if it returns a non-empty node-set, while comparison or Boolean expressions pass an event when they evaluate to true.
What is the role of the Filter EPA?The Filter EPA performs filtering as part of the agent itself. It can route passing events to a Filtered-in output, failing events to a Filtered-out output, and incompatible events to a Non-filterable output.
What is stateful filtering, and when is it used?Stateful filtering depends on context and prior events. It is used mainly in Filter EPAs for tasks such as sampling or rate limiting, for example passing the first m events, last m events, or a random m events in a context window.
What is the difference between Project, Translate, and Enrich transformation agents?Project copies a subset of input attributes to the output. Translate can copy, modify, or add attributes based on the input event. Enrich does the same as Translate but can also use reference data from a global state element.
What is a Split EPA used for?A Split EPA takes one input event and produces multiple output events. It can do this statically with fixed derivation expressions, iteratively for variable-length structures, or by decomposing a composite event type.
How does an Aggregate EPA work?An Aggregate EPA collects events within a context partition and derives output from multiple input events. It commonly runs when a temporal window closes, and it can use functions like count, sum, avg, min, max, and distinct.
What does a Compose EPA do?A Compose EPA joins two input streams, called left and right, by matching event instances according to a match condition. It buffers events, applies a join-like comparison, and can emit output for matched pairs or handle unmatched events depending on policy.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Event Processing in Action Event Processing in Action ebook for free