1 - Filter events based on particular properties

Filter

When processing events, we can use filter operations to select a subset that we want to use. Filtering works on individual events in the stream.

Note: To follow the step-by-step instructions in this tutorial, you can watch the video or read the instructions on the page.

Scenario : Identify orders from a specific region

The EMEA operations team wants to move away from reviewing quarterly sales reports and be able to review orders in their region as they occur.

Identifying large orders as they occur will help the team identify changes that are needed in sales forecasts much earlier. These results can also be fed back into their manufacturing cycle so they can better respond to demand.

Before you begin

The instructions in this tutorial use the Tutorial environment, which includes a selection of topics each with a live stream of events, created to allow you to explore features in IBM Event Automation. Following the setup instructions to deploy the demo environment gives you a complete instance of IBM Event Automation that you can use to follow this tutorial for yourself.

Versions

This tutorial uses the following versions of Event Automation capabilities. Screenshots may differ from the current interface if you are using a newer version.

  • Event Streams 11.3.1
  • Event Endpoint Management 11.1.5
  • Event Processing 1.1.5

Instructions

Step 1 : Discover the topic to use

For this scenario, you need a source of order events. A good place to discover sources of event streams to process is the catalog in Event Endpoint Management.

  1. Go to the Event Endpoint Management catalog.

    screenshot

    If you need a reminder of how to access the Event Endpoint Management catalog you can review Accessing the tutorial environment.

    If there are no topics in the catalog, you may need to complete the tutorial setup step to populate the catalog.

  2. Find the Orders topic.

    screenshot

  3. Click into the topic to review the information about the events that are available here.

    Look at the schema to see the properties in the order events, and get an idea of what to expect from events on this topic.

    screenshot

Tip: Keep this page open. It is helpful to have the catalog available while you work on your event processing flows, as it allows you to refer to the documentation about the events as you work. Do the following steps in a separate browser window or tab.

Step 2 : Create a flow

The next step is to start processing this stream of events, to create a custom subset that contains the events that you are interested in.

  1. Go to the Event Processing home page.

    screenshot

    If you need a reminder of how to access the Event Processing home page, you can review Accessing the tutorial environment.

  2. Create a flow, and give it a name and description to explain that you will use it to identify orders made in the EMEA region.

    screenshot

Step 3 : Provide a source of events

The next step is to bring the stream of events you discovered in the catalog into Event Processing.

  1. Update the Event source node.

    screenshot

    Hover over the node and click Edit icon Edit to configure the node.

  2. Add a new event source.

    screenshot

  3. Get the server address for the event source from the Event Endpoint Management topic page.

    screenshot

    Click the Copy button next to the Servers address to copy the address to the clipboard.

  4. Configure the new event source.

    screenshot

    Give the node a name that describes this stream of events: Orders.

    Paste in the server address that you copied from Event Endpoint Management in the previous step.

  5. Generate access credentials for accessing this stream of events from the Event Endpoint Management page.

    screenshot

    Click the “Generate access credentials” button at the top of the page, and provide your contact details.

    Did you know? Providing your contact details allows the owner of the topic to know who is accessing their stream of events.

  6. Copy the username and password from Event Endpoint Management and paste into Event Processing to allow access to the topic.

    screenshot

    The username starts with eem-.

    Did you know? The username and password you created is unique to you, and is only for accessing this topic. If you need to revoke this password, you can do it without impacting other users of this topic.

  7. Select Avro as the message format used in this topic.

    screenshot

    Did you know? The catalog page for this topic tells you that events on this topic are serialized as binary-encoded Avro data.

    Click “Next”.

  8. Get the schema for order events from Event Endpoint Management.

    screenshot

    Switch to the JSON schema view, and then click the Copy icon for the schema to copy it to the clipboard.

    You need to give Event Processing a description of the events available from the topic. The schema will enable Event Processing to give guidance for creating event processing nodes.

  9. Paste the schema into the event source config in the Avro schema box.

    screenshot

  10. Leave the event source to be saved for later reuse.

    screenshot

    Tip: Saving the connection details makes the later steps in the tutorial that use this same topic quicker. It avoids you needing to enter these details again.

  11. Click Configure to finalize the event source.

Step 4 : Define the filter

The next step is to start processing this stream of events, by creating the filter that will select the custom subset with the events that you are interested in.

  1. Create a Filter node and link it to your event source.

    screenshot

    Create a filter node by dragging one onto the canvas. You can find this in the Processors section of the left panel.

    Click and drag from the small gray dot on the event source to the matching dot on the filter node.

    Did you know? Instead of dragging the node, you can add a node onto the canvas and automatically connect it to the last added node by double-clicking a node within the palette. For example, after configuring an event source node, double-click any processor node to add and connect the processor node to your previously configured event source node.

  2. Give the filter node a name that describes the events it should identify: EMEA orders.

    screenshot

    Hover over the node and click Edit icon Edit to configure the node.

  3. Use the assistant to define a filter that matches events with a region value of EMEA.

    screenshot

  4. Click “Add to expression”.

    screenshot

  5. Click Configure to finalize the filter.

Step 5 : Test the flow

The final step is to run your event processing flow and view the results.

  1. Use the Run menu, and select Include historical to run your filter on the history of order events available on this Kafka topic.

    screenshot

    Did you know? “Include historical” is useful while you are developing your flows, as it means that you don’t need to wait for new events to be produced to the Kafka topic. You can use all of the events already on the topic to check that your flow is working the way that you want.

  2. A live view of results from your filter is updated as new events are emitted onto the orders topic.

    screenshot

  3. When you have finished reviewing the results, you can stop this flow.

Recap

You created your first event processing flow.

You have seen how to discover and request access to a topic in the catalog, and register it as a source of events for processing.

You used a filter node to specify a subset of events on the topic that you are interested in.

Next step

In the next tutorial, you will try another stateless operation to learn how to modify events in the stream.