Transforming and Analyzing Data using Patterns

The visual representation of the event stream varies from one pattern type to another based on the key fields you choose. A pattern provides you with a simple way to explore event streams, based on common business scenarios.

To access the available patterns:

To view all the available patterns:

To view a specific category of patterns:

Category Pattern
Enrichment

Reverse Geo Code: Near By

Left Outer Join

Outlier Fluctuation
Inclusion

Union

Left Outer Join

Missing Event

'A' Not Followed by 'B'

Detect Missing Event

Spatial

Proximity: Stream with Geo Fence

Geo Fence

Spatial: Speed

Interaction: Single Stream

Reverse Geo Code: Near By

Geo Code

Spatial: Point to Polygon

Interaction: Two Stream

Proximity: Two Stream

Direction

Reverse Geo Code: Near By Place

Proximity: Single Stream

Geo Filter

Filter

Eliminate Duplicates

Fluctuation

State

'A' Not Followed by 'B'

Inverse W

Detect Missing Event

W

'A' Followed by 'B'

'B' Not Preceded by 'A'

Delay Event

Time Window Snapshot

Row Window Snapshot

Current And Previous Pattern

Finance

Inverse W

W

Shape Detector

Inverse W

W

Trend

'A' Not Followed by 'B'

Top N

Change Detector

Up Trend

Detect Missing Event

Down Trend

'A' Followed by 'B'

Detect Duplicates

Bottom N

Machine Learning

Oracle Machine Learning Service

Similarity Search

Oracle Generative AI Agent

Statistical

Correlation

Quantile

Transform

Pivot

Split

ToJson

Continuos Merge

FromJson

Adding a Pattern Stage

A pattern is a template of an Oracle GoldenGate Stream Analytics application, with a business logic built into it. You can create pattern stages within the pipeline. Patterns are not stand-alone artifacts, they need to be embedded within a pipeline.

For detailed information about the various type of patterns, see Transforming and Analyzing Data using Patterns.

To add a pattern stage:

  1. Open a pipeline in the Pipeline Editor.

  2. Right-click the stage after which you want to add a pattern stage, click Add a Stage, and then select Pattern.

  3. Choose the required pattern from the list of available patterns.

  4. Enter a Name and Description for the pattern stage.

    The selected pattern stage is added to the pipeline.

  5. Click Parameters and provide the required values for the parameters.

  6. Click Visualizations and add the required visualizations to the pattern stage.

Detecting Missing Events

Use the Detect Missing Event pattern to detect missing events. For example, if a feed has multiple sensors sending readings every 5 seconds, this pattern detects sensors that have stopped sending readings. This also indicates that the sensors are either broken or disconnected.

To use this pattern, provide suitable values for the following parameters:

Outgoing Shape

The outgoing shape is the same as incoming shape. If there are no missing heartbeats, no events are output. If there is a missing heartbeat, the previous event, which was used to calculate the heartbeat interval is output.

Calculating Quantile Value

Use the Quantile pattern to calculate the value of quantile function. It returns the percentile value of all data in the specified window range. For example, a 25th percentile of a dataset is a value where 25% of data points are less than the value returned from the 25th percentile.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape is the same as the incoming shape.

Identifying Correlation between Two Numeric Patterns

Use the Correlation Pattern pattern to identify the correlation between two numeric parameters. The output will define if the two parameters are positively correlated (value of 1), or negatively correlated (-1), or not correlated(value of 0).

To use this pattern, provide suitable values for the following parameters:

The outgoing shape is same as the incoming shape.

Detecting Duplicate Events

The Detect Duplicates pattern detects duplicate events in your stream according to the criteria you specify and within a specified time window. Events may be partially or fully equivalent to be considered duplicates.

For example, when you suspect that your aggregates are offset, you can check your stream for duplicate events.

To use this pattern, provide suitable values for the following parameters:

Outgoing Shape

The outgoing shape is the same as the incoming shape with one extra field: Number_of_Duplicates. This extra field will carry the number of duplicate events that have been discovered. All the other fields will have values of the last duplicate event.

Eliminating Duplicate Events

Use the Eliminate Duplicates pattern to look for duplicate events in your stream within a specified time window, and remove all but the first occurrence. A duplicate event is an event that has one or more field values identical to values of the same field(s) in another event. You can specify what fields are analyzed for duplicate values. You can configure the pattern to compare just one field or the whole event.

For example, use it when you know that your stream contains duplicates that might offset your aggregates, such as counts.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape is the same as the incoming shape.

Detecting Event Value Changes

Use the Change Detector pattern to look for changes in the values of your event fields and report the changes once they occur within a specified range window. For example, if an event arrives with value value1 for field field1, and any of the following incoming events, within a specified range window, contains a value different from value1, an alert is triggered. You can designate more than one field to look for changes.

For example, a sensor reading that is supposed to be the same for certain periods of time and changes in readings may indicate issues.

The default configuration of this pattern stage is to alert on change of any selected fields.

To use this pattern, provide suitable values for the following parameters:

Outgoing Shape

The outgoing shape is based on the incoming shape, the difference being that all the fields except the one in the partition criteria parameter will be duplicated to carry both the initial event values and the change event values.

Example:

Your incoming event contains the following fields:

Normally, you would use sensor_id to partition your data, to look for changes in temperature. So, select sensor_id in the partition criteria parameter and temperature in the change criteria parameter. Use a range window that fits your use case. In this scenario, you will have the following outgoing shape:

The orig_ fields carry values from the initial event. In this scenario, temperature and orig_temperature values are different, while pressure and orig_pressure, location, and orig_location may have identical values.

Detecting Data Field Value Changes

Use the Fluctuation pattern to detect when an event data field value changes in a specific upward or downward fashion within a specific time window. For example, use this pattern to identify the variable changes in an Oil Pressure value are maintained within acceptable ranges.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape is same as the incoming shape.

Monitoring Sequence of Events

Use the ‘A’ Followed by ‘B’ pattern to look for particular events following one another and to output an event when the specified sequence of events occurs.

Use it when you need to be aware of a certain succession of events happening in your flow. For example, if an order status BOOKED is followed by an order status SHIPPED (skipping status PAID), you need to raise an alert.

To use this pattern, provide suitable values for the following parameters:

Outgoing Shape

The outgoing shape is based on the incoming shape. A new abInterval field is added to carry the value of the time interval between the states in nanosecond. Also, all but the partition criteria fields are duplicated to carry values from both a and b states. For example, if you have the following incoming shape:

You will get the following outgoing shape:

Outputting Highest Value Events

Use the Top N pattern to output N events with highest values from a collection of events, arriving within a specified time window. The events here are sorted the way you specify, and not in the default order of arrival.

For example, use it to get N highest values of pressure sensor readings.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape is the same as the incoming shape.

Outputting Lowest Value Events

Use the Bottom N pattern to output N events with lowest values from a collection of events, arriving within a specified time window. The events here are sorted the way you specify and not in the default order of arrival.

For example, use it to get N lowest values of pressure sensor readings.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape is the same as the incoming shape.

Monitoring Invariably Increasing Numeric Values

Use the Up Trend pattern to detect an invariably increasing numeric value, over a period of time.

Use the pattern if you need to detect situations of a constant increase in one of your numeric values. For example, detect a constant increase in pressure from one of your sensors.

To use this pattern, provide suitable values for the following parameters:

Outgoing Shape

The outgoing shape is based on the incoming shape with an addition of two new fields. For example, if your incoming event contains the following fields:

Normally, you would use sensor_id to partition your data and say you want to look for the upward trend in temperature. So, select sensor_id in the partition criteria parameter and temperature in the tracking value parameter. Use a duration that fits your use case. In this scenario, you will have the following outgoing shape:

Monitoring Invariably Decreasing Numeric Values

Use the Down Trend pattern to detect an invariably decreasing a numeric value, over a period of time.

For example, detect a constant drop in pressure from one of your sensors.

To use this pattern, provide suitable values for the following parameters:

Outgoing Shape

The outgoing shape is based on the incoming shape with an addition of two new fields. Let’s look at an example. Your incoming event contains the following fields:

Normally, you would use sensor_id to partition your data and say you want to look for the downward trend in temperature. So, select sensor_id in the partition criteria parameter and temperature in the tracking value parameter. Use a duration that fits your use case. In this scenario, you will have the following outgoing shape:

The pattern is visually represented based on the data you have entered/selected.

Identifying the Missing First Event in a Sequence

The ‘B’ Not Preceded by ‘A’ pattern will look for a missing event in a particular combination of events and will output the first event which is found where the first event is not preceded by the second event.

Use it when you need to be aware of a specific event not preceded by another event in your flow. For example, if an order status BOOKED is not preceded by an order status PAID within a certain time period, you may need to raise an alert.

To use this pattern, provide suitable values for the following parameters:

Outgoing Shape

The outgoing shape is the same as incoming shape. If the second (state B) event does not arrive within the specified time window, the first (state A) event is pushed to the output.

Identifying the Second Missing Event in a Sequence

The ‘A’ Not Followed by ‘B’ pattern will look for a missing second event in a particular combination of events and will output the first event when the expected second event does not arrive within the specified time period.

Use it when you need to be aware of a specific event not following its predecessor in your flow. For example, if an order status BOOKED is not followed by an order status PAID within a certain time period, you may need to raise an alert.

To use this pattern, provide suitable values for the following parameters:

Outgoing Shape

The outgoing shape is the same as incoming shape. If the second (state B) event does not arrive within the specified time window, the first (state A) event is pushed to the output.

Analyzing Data using Double Bottom Charts

Use the W pattern for technical analysis of financial trading markets. This pattern is also known as a double bottom chart pattern.

Use this pattern to detect when an event data field value rises and falls in “W” fashion over a specified time window. For example, use this pattern when monitoring a market data feed stock price movement to determine a buy/sell/hold evaluation.

To use this pattern, provide suitable values for the following parameters:

Outgoing Shape

The outgoing shape is based on the incoming shape with an addition of five new fields. The new fields are:

The new fields correspond to the tracking value terminal points of the W shape discovered in the feed. The original fields correspond to the last event in the W pattern.

Analyzing Data using Double Top Charts

Use the Inverse W pattern for the technical analysis of financial trading markets, and to see the financial data in a graphical form. This pattern is also known as a double top chart pattern.

To use this pattern, provide suitable values for the following parameters:

Outgoing Shape

The outgoing shape is based on the incoming shape with an addition of five new fields. The new fields are:

The new fields correspond to the tracking value terminal points of the inverse W shape discovered in the feed. The original fields correspond to the last event in the inverse W pattern.

Correlating Current and Previous Events

Use the Current and Previous Events pattern to automatically correlate the current and previous events.

To use this pattern, provide suitable values for the following parameters:

Input Schema or Payload Shape [DiskID, Usage]

Output schema/payload from this pattern for non-partitioned input is [DiskID, Usage, PREV_DiskId, PREV_Usage].

For input partitioned by DiskID, the output schema from the pattern is [DiskID, Usage, PREV_Usage].

Below is an example with values:

For non-partitioned input:

Input - [Disk1, 40gb], [Disk2, 60gb], [Disk1, 45gb]

Output - [Disk2, 60gb, Disk1, 40gb], [Disk1, 45gb, Disk2, 60gb]

For input partitioned by Disk ID :

Input - [Disk1, 40gb], [Disk2, 60gb], [Disk1, 45gb]

Output [Disk1, 45gb, 40gb]. There is no output for Disk2 until another event for Disk2 arrives.

Delaying Delivery of Events to Downstream Node

Use the Delay Event pattern to delay delivering an event to downstream node in the pipeline, for a specified number of seconds. A practical use case is to wind up a campaign event or promotion.

To use this pattern, provide suitable values for the following parameters:

Outputting Contents to Downstream Node

Use the Row Window Snapshot pattern to output entire window contents to a downstream node, on the arrival of a new event, based on the specified maximum number of events a window can hold.

For example:

To use this pattern, provide suitable values for the following parameters:

[PARTITION BY StockSymbol, ROWS 500, RANGE 1 MINUTE] will dump the entire window contents on the arrival of a new event. The window will hold a maximum of 500 events. An event will expire after a minute, allowing newer events.

Partitioning key creates separate window for each value of the key. For example, a separate window for 500 Oracle quote events, 500 Microsoft quote events and so on.

Outputting Unexpired Contents to Downstream Node

Use the Time Window Snapshot pattern to output entire window contents to a downstream node, on the arrival of a new event, based on the time window specified for each event.

To use this pattern, provide suitable values for the following parameters:

[RANGE 10 MINUTES] will dump entire window contents to downstream node on the arrival of a new event. Event will expire from the window after 10 minutes.

Note: Window will automatically dump contents either when a new event arrives or when an event expires.

Merging Two Streams having Identical Shapes

Use the Union pattern to merge two streams having identical shapes.

For example, you have two similar sensors sending data into two different streams, and you want to process the streams simultaneously, in one pipeline.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape is the same as the incoming shape.

Joining Flows with Streams and References

Use the Left Outer join pattern to join a stream or a reference, using the left outer join semantics.

The result of this pattern always contains the data of the left table even if the join-condition does not find any matching data in the right table.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape is a sum of two incoming shapes.

Transforming Events into JSON

Use the ToJson pattern to transform event(s) coming from a stage in the pipeline into a JSON text.

Use this pattern to transform multiple events into a single JSON document, and send it to a downstream system through OSA pipeline targets. For example, you can configure a Database target after the toJson pattern stage, to write the json payload (of a single or multiple events), into a database table

To use this pattern, provide suitable values for the following parameters:

Transforming Nested JSON into Simple Columns

Use the FromJSON pattern to convert nested JSON in any event field into easy-to-use columns. This pattern is specifically useful when your upstream stage produces one or more fields that contain JSON text (for example, a payload string, etc).

Add the FromJson pattern after a stage that outputs the JSON text you want to flatten. This pattern flattens nested JSON attributes into new columns while preserving all original input fields. Arrays are preserved as JSON strings (no row expansion).

To use this pattern, provide suitable values for the following parameters:

Transforming a Single Event from a Stage into Multiple Events

Use the Split pattern to transform a single event from a stage into multiple events, by splitting the value field. For example, you can flatten an array of json element or json object from the source, to individually process it and also to push it to some targets.

The output of this pattern, is one or more events, corresponding to each single event of the previous stage. The output events are a clone of the source event. The attribute of the selected field is split into an array, based on the selected type. Each value of an array correspond to an output event with the new value of the selected attribute.

To use this pattern, provide suitable values for the following parameters:

Merging Two Continuous Events into a Single Event

Use the Continuous Merge pattern to merge two or more continuous events into a single event, based on the key attributes.

The output of this pattern, is a single event corresponding to two or more merged events of the previous stage. The attribute of the selected field is merged into an array, based on the selected type. Each value of an array correspond to an output event with the new value of the selected attribute.

To use this pattern, provide suitable values for the following parameters:

Applying OML Models to get the Scoring of Events (Preview Feature)

Use the Oracle Machine Learning Service pattern to use OML models to apply the scoring on the ingested events.

To use this pattern, provide suitable values for the following parameters:

Applying Vector-Based Similarity Search

Use the Similarity Search pattern to run vector-based similarity searches in an Oracle Database, to find similar items based on input data. This is particularly useful for applications such as recommendation systems, duplicate detection, or semantic search.

The Similarity Search pattern processes batches of events, queries the database for matches, and outputs results with similarity scores.

To use this pattern, provide suitable values for the following parameters:

Integrating Generative AI Service Call Into Your Stream Explorer Pipeline

Use the Oracle Generative AI Agent pattern to integrate an Oracle Cloud Generative AI service call directly into your Stream Explorer pipeline.

You can use this new pattern for:

To use this pattern, provide suitable values for the following parameters:

Detecting Contiguous Events

Use the Segment Detector pattern to detect contiguous events (range/segment) having unchanged values for the selected attributes, over a specified period of time.

For example, to detect the range of stability over a period of time in:

To use this pattern, provide suitable values for the following parameters:

The Segment Detector pattern outputs the attribute values of the first and last event in the detected segment (range). Each of the attributes of the first event is prefixed with orig_ in the output shape, whereas the attribute of the last event name is same as in the previous stage.

Creating Pivot Columns

Use the Pivot pattern to pivot all or selected attributes of an incoming event, into new columns, based on the selected pivot value and key provided.

To use this pattern, provide suitable values for the following parameters: