6 Working with Patterns

This chapter explains the details about Patterns.

This chapter contains the following sections:

6.1 Understanding Patterns

Oracle Stream Analytics provides a feature known as patterns. A pattern provides you with the results displayed in a live output stream based on common business scenarios. A pattern is a template of an Oracle Stream Analytics application that already has the business logic built into it. The visual representation of the event stream varies from one pattern type to another based on the key fields you choose.

6.1.1 Top N

A Top N pattern is used to create a pattern of the first N events in the specified window of an event stream.

6.1.2 Bottom N

A Bottom N pattern is used to create a pattern of the last N events of an event stream. Logically, this type of pattern is the reverse of Top N pattern.

6.1.3 Up Trend

An Up Trend pattern detects when the up trend starts and continues to grow. For example, use this pattern to identify when the temperature value from a sensor device starts increasing continuously.

6.1.4 Down Trend

A Down Trend pattern detects when a numeric event field shows a change in a specified trend, lower in value. For example, use this pattern to identify when the temperature value from a sensor device starts continuously decreasing.

6.1.5 Fluctuation

A Fluctuation pattern detects when an event data field value changes in a specific upward or downward fashion within a specific time p. For example, use this pattern to identify the variable changes in Oil Pressure values within acceptable ranges.

6.1.6 Eliminate Duplicates

The Eliminate Duplicates pattern is used to build an exploration that eliminates duplicate events in a specific event stream.

6.1.7 Detect Duplicates

The Detect Duplicates pattern detects when an event data field has duplicate values within a specified period of time. For example, use this pattern when the same order is placed twice within a day.

6.1.8 Detect Missing Event

The Detect Missing Event pattern detects when an expected event does not occur within a specified time window. For example, use this pattern in circumstances when the next heartbeat event is missing.

6.1.9 W

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

6.1.10 Inverse W

The Inverse W pattern detects the inverses of W. Logically, this pattern is the reverse of the W pattern.

6.2 Creating Top N Pattern

Use this pattern to obtain the first N events in a window range.

To create a Top N pattern:

  1. Navigate to the Catalog.
  2. Select Create New Item >Pattern > Top N. You can also click Patterns and select Top N.The create pattern screen appears as shown below:

    Figure 6-1 Create Top N Pattern

    Description of Figure 6-1 follows
    Description of "Figure 6-1 Create Top N Pattern"
  3. Select an Event Stream.
  4. Enter a value for Window Range and select its unit (one of nanoseconds, milliseconds, microseconds, seconds, minutes, and hours). This number must be greater than or equal to 1.

    A Window range is the range from which the output is generated.

  5. Enter a value for Window Slide and select its unit (one of nanoseconds, milliseconds, microseconds, seconds, minutes, and hours). This is the frequency at which you want to refresh the data.
  6. Select a value in the Order by Criteria field. You can select multiple fields.
  7. Enter a value in the Number of Events field. This number must be greater than or equal to 1. This is the number that indicates the number of events to be considered for the pattern.

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

6.3 Creating Bottom N Pattern

Use the Bottom N pattern to obtain the last N events in a window range.

This section explains how to create a Bottom N pattern.

To create a Bottom N pattern:

  1. Navigate to the Catalog.
  2. Select Create New Item >Pattern > Bottom N. You can also click Patterns and select Bottom N.The create pattern screen appears as shown below:

    Figure 6-2 Create Bottom N Pattern

    Description of Figure 6-2 follows
    Description of "Figure 6-2 Create Bottom N Pattern"
  3. Select an Event Stream.
  4. Enter a value for Window Range and select its unit (one of nanoseconds, milliseconds, seconds, minutes, and hours). This number must be greater than or equal to 1.

    A Window range is the range from which the output is generated.

  5. Enter a value for Window Slide and select its unit (one of nanoseconds, milliseconds, seconds, minutes, and hours). This is the frequency at which you want to refresh the data.
  6. Select a value in the Order by Criteria field. You can select multiple fields.
  7. Enter a value in the Number of Events field. This number must be greater than or equal to 1. This is the number that indicates the number of events to be considered for the pattern.

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

6.4 Creating Up Trend Pattern

Use this pattern to detect when a numeric event field shows a specified trend change higher in value. For example, use this pattern to identify when the temperature value from a sensor device starts continuously increasing.

To create an Up Trend pattern:

  1. Navigate to the Catalog.
  2. Select Create New Item >Pattern > Up Trend. You can also click Patterns and select Up Trend.The create pattern screen appears as shown below:

    Figure 6-3 Create Up Trend Pattern

    Description of Figure 6-3 follows
    Description of "Figure 6-3 Create Up Trend Pattern"
  3. Select an Event Stream.
  4. Enter a value for Partition Criteria. This value is used for partitioning the data in the event stream.

    These are the fields in which you want to track the trend.

  5. Enter a value for Duration and select its unit (one of nanoseconds, milliseconds, seconds, minutes, and hours). This is the interval within which the application looks for a pattern match.
  6. Select a value in the Tracking Field drop-down. You can select only 1 item.

    This is a source field whose behavior follows the trend for the pattern to emit the event.

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

6.5 Creating Down Trend Pattern

Use this pattern to detect when a numeric event field shows a specified trend change lower in value. For example, use this pattern to identify when the temperature value from a sensor device starts continuously decreasing.

To create a Down Trend pattern:

  1. Navigate to the Catalog.
  2. Select Create New Item > Pattern > Down Trend. You can also click Patterns and select Down Trend. The create pattern screen appears as shown below:

    Figure 6-4 Create Down Trend Pattern

    Description of Figure 6-4 follows
    Description of "Figure 6-4 Create Down Trend Pattern"
  3. Select an Event Stream.
  4. Enter a value for Partition Criteria. This filed can be used to partition the data in the event stream.

    These are the fields in which you want to track the trend.

  5. Enter a value for Duration and select its unit (one of nanoseconds, milliseconds, seconds, minutes, and hours). This is the interval within which the application looks for a pattern match.
  6. Select a value in the Tracking Value field. You can select only 1 item.

    This is a source field whose behavior follows the trend for the pattern to emit the event.

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

6.6 Creating Fluctuation Pattern

Use this 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 create a Fluctuation pattern:

  1. Navigate to the Catalog.
  2. Select Create New Item > Pattern > Fluctuation. You can also click Patterns and select Fluctuation. The create pattern screen appears as shown below:

    Figure 6-5 Create Fluctuation Pattern

    Description of Figure 6-5 follows
    Description of "Figure 6-5 Create Fluctuation Pattern"
  3. Select an Event Stream.
  4. Enter a value for Partition Criteria. This field can be used to partition the data in the event stream.

    These are the fields in which you want to track the trend.

  5. Enter a value in the Tracking Field. This value is used to track the event data and create a pattern in the live output stream.
  6. Enter a value for Window and select its unit (one of nanoseconds, milliseconds, seconds, minutes, and hours). This is the frequency at which you want to refresh the data.
  7. Enter a value for Deviation Threshold %. This value indicates the percentage of deviation you want to be included in the pattern.

    This is the interval in which the application looks for a matching pattern.

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

6.7 Creating Eliminate Duplicates Pattern

Use this pattern to build an exploration that eliminates duplicate events in your event stream.

To create an Eliminate Duplicates pattern:

  1. Navigate to the Catalog.
  2. Select Create New Item > Pattern > Eliminate Duplicates. You can also click Patterns and select Eliminate Duplicates. The create pattern screen appears as shown below:

    Figure 6-6 Create Eliminate Duplicates Pattern

    Description of Figure 6-6 follows
    Description of "Figure 6-6 Create Eliminate Duplicates Pattern"
  3. Select an Event Stream.
  4. Enter a value for Duplicate Criteria.

    This is the field that you want to eliminate for duplicate keys.

  5. Enter a value for Window and select its unit (one of nanoseconds, milliseconds, seconds, minutes, and hours). This is the range within which the application searches for duplicates.

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

6.8 Creating Detect Duplicates Pattern

Use this pattern to detect when an event data field has duplicate values within a specified period of time. For example, use this pattern when the same order is placed twice within a day.

To create a Detect Duplicates pattern:

  1. Navigate to the Catalog.
  2. Select Create New Item > Pattern > Detect Duplicates. You can also click Patterns and select Detect Duplicates. The create pattern screen appears as shown below:

    Figure 6-7 Create Detect Duplicates Pattern

    Description of Figure 6-7 follows
    Description of "Figure 6-7 Create Detect Duplicates Pattern"
  3. Select an Event Stream.
  4. Enter a value for Duplicate Criteria.

    This is the field that you want to look for duplicate keys.

  5. Enter a value for Window and select its unit (one of nanoseconds, milliseconds, seconds, minutes, and hours). This is the interval in which the application looks for duplicates.

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

6.9 Creating Detect Missing Event Pattern

This section explains how to create a Detect Missing Event pattern.

To create a Detect Missing Event pattern:

  1. Navigate to the Catalog.
  2. Select Pattern -> Detect Missing Event under the Create New Item menu. The create pattern screen appears as shown below:

    Figure 6-8 Creating Detect Missing Event Pattern

    Description of Figure 6-8 follows
    Description of "Figure 6-8 Creating Detect Missing Event Pattern"
  3. Select an Input stream.
  4. Enter a value for Tracking Fields. You can select multiple fields.

    These are the fields with which you track and identify the missing events.

  5. Enter a value for Heartbeat Interval and select its unit (one of nanoseconds, milliseconds, seconds, minutes, and hours). This is the interval in which the application looks for an event. If the event does not appear in the specified interval, the application generates an event indicating that there is something missing, i.e., an event should have appeared here, but not.

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

6.10 Creating W 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 create a W pattern:

  1. Navigate to the Catalog.
  2. Select Create New Item > Pattern > W. You can also click Patterns and select W. The create pattern screen appears as shown below:
  3. Select an Event Stream.
  4. Enter a value for Partition Criteria. You can select multiple fields.

    These are the fields by which the data is partitioned to form a W.

  5. Enter a value for Window and select its unit (one of nanoseconds, milliseconds, seconds, minutes, and hours). This is the interval in which the application looks for a matching pattern.
  6. Select a numeric value for Tracking Value based on which variation constitutes a W-shape for the pattern-based exploration to produce event.

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

6.11 Creating Inverse W Pattern

Use this pattern to detect an inverse W pattern with live output stream.

To create an Inverse W pattern:

  1. Navigate to the Catalog.
  2. Select Create New Item > Pattern > Inverse W. You can also click Patterns and select Inverse W. The create pattern screen appears as shown below:

    Figure 6-10 Create Inverse W Pattern

    Description of Figure 6-10 follows
    Description of "Figure 6-10 Create Inverse W Pattern"
  3. Select an Event stream.
  4. Enter a value for Partition Criteria.

    This is the field by which the data is partitioned to form an inverse W.

  5. Enter a value for Window and select its unit (one of nanoseconds, milliseconds, seconds, minutes, and hours). This is the interval in which the application looks for a matching pattern.
  6. Select a numeric value for Tracking Value based on which variation constitutes an inverse W-shape for the pattern-based exploration to produce event.

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