sequence_detect plugin

Learn how to use the sequence_detect plugin to detect sequence occurrences based on provided predicates.

Detects sequence occurrences based on provided predicates. The plugin is invoked with the evaluate operator.

Syntax

T | evaluate sequence_detect (TimelineColumn, MaxSequenceStepWindow, MaxSequenceSpan, Expr1, Expr2, …, Dim1, Dim2,)

Parameters

NameTypeRequiredDescription
Tstring✔️The input tabular expression.
TimelineColumnstring✔️The column reference representing timeline, must be present in the source expression.
MaxSequenceStepWindowtimespan✔️The value of the max allowed timespan between 2 sequential steps in the sequence.
MaxSequenceSpantimespan✔️The max timespan for the sequence to complete all steps.
Expr1, Expr2, …string✔️The boolean predicate expressions defining sequence steps.
Dim1, Dim2, …string✔️The dimension expressions that are used to correlate sequences.

Returns

Returns a single table where each row in the table represents a single sequence occurrence:

  • Dim1, Dim2, …: dimension columns that were used to correlate sequences.
  • Expr1TimelineColumn, Expr2TimelineColumn, …: Columns with time values, representing the timeline of each sequence step.
  • Duration: the overall sequence time window

Examples

The following query looks at the table T to search for relevant data from a specified time period.

T | evaluate sequence_detect(datetime_column, 10m, 1h, e1 = (Col1 == 'Val'), e2 = (Col2 == 'Val2'), Dim1, Dim2)

Exploring Storm Events

The following query looks on the table StormEvents (weather statistics for 2007) and shows cases where sequence of ‘Excessive Heat’ was followed by ‘Wildfire’ within 5 days.

StormEvents
| evaluate sequence_detect(
               StartTime,
               5d,  // step max-time
               5d,  // sequence max-time
               heat=(EventType == "Excessive Heat"), 
               wildfire=(EventType == 'Wildfire'), 
               State
           )

Output

Stateheat_StartTimewildfire_StartTimeDuration
CALIFORNIA2007-05-08 00:00:00.00000002007-05-08 16:02:00.000000016:02:00
CALIFORNIA2007-05-08 00:00:00.00000002007-05-10 11:30:00.00000002.11:30:00
CALIFORNIA2007-07-04 09:00:00.00000002007-07-05 23:01:00.00000001.14:01:00
SOUTH DAKOTA2007-07-23 12:00:00.00000002007-07-27 09:00:00.00000003.21:00:00
TEXAS2007-08-10 08:00:00.00000002007-08-11 13:56:00.00000001.05:56:00
CALIFORNIA2007-08-31 08:00:00.00000002007-09-01 11:28:00.00000001.03:28:00
CALIFORNIA2007-08-31 08:00:00.00000002007-09-02 13:30:00.00000002.05:30:00
CALIFORNIA2007-09-02 12:00:00.00000002007-09-02 13:30:00.000000001:30:00