nano SIEM
Search Commands

sequence

Supported in:Self-hosted

Find entities whose events match a list of conditions in order, optionally within a time limit.

Use sequence to find users, hosts, or IPs whose events match your conditions in order. You can set a maximum span for patterns such as failed logons followed by success, or process launch followed by an outbound connection.

Syntax

... | sequence by <field>[, <field> ...] [maxspan=<duration>] [fields(<field>, ...)] [<condition 1>] [<condition 2>] ...

The parts must come in this order: by, maxspan, fields(...), then the conditions.

ArgumentDefaultDescription
byrequiredFields that identify the entity. Events where a by field is empty are left out.
maxspanno limitLongest time from the first step to the last, for example 5m, 1h, 24h.
fields(...)noneExtra fields to capture from each step's event.
[condition]at least oneA filter in square brackets. Conditions use the where expression syntax (NOT > AND > OR): comparisons, IN, LIKE, regex (field=/pattern/), IN CIDR(...) and functions.

maxgap= is accepted for compatibility and ignored.

Output fields

One row per entity that completed every step:

FieldDescription
by fieldsThe entity
step<N>_timeTime of the event that matched step N
step<N>_event_idThat event's metadata.uid, for drill-down
step<N>_<field>Fields named in step N's condition and in fields(...), captured from that event. Dots become underscores: process.cmd_line → step1_process_cmd_line.
sequence_duration_secondsSeconds from step 1 to the last step
maxspan_secondsThe maxspan value, when set
sequence_countNumber of completed sequences for this entity

Rows are ordered by step1_time, newest first.

How it works

  • The reported step columns describe one run that completes every condition in order and satisfies maxspan, when set. Ordering uses event timestamps at millisecond resolution.
  • Entities that stop partway are left out. Use funnel to see where they stop.
  • The base search limits which events are considered. Filter it to the log sources and classes your conditions need.

Examples

Failed logons followed by a successful logon for the same account within 5 minutes:

class_uid=3002 | sequence by user.name maxspan=5m [status_id=2] [status_id=1]

The same, per account and source IP, keeping the target host:

class_uid=3002 | sequence by user.name, src_endpoint.ip maxspan=10m fields(device.hostname) [status_id=2] [status_id=1]

PowerShell started, then PowerShell made an outbound connection from the same host within 10 minutes:

metadata.log_source=windows_sysmon | sequence by device.hostname maxspan=10m fields(process.cmd_line, dst_endpoint.ip) [class_uid=1007 process.name="powershell.exe"] [class_uid=4001 actor.process.name="powershell.exe"]

Download from a file-sharing site, then a request for an executable from the same client:

class_uid=4002 | sequence by src_endpoint.ip maxspan=10m fields(http_request.url.url_string) [http_request.url.hostname=/file[-_]?(share|drop|transfer)/] [http_request.url.path=/\.(exe|scr|hta|ps1|msi)$/]

A process writes a file under a temp folder, then a process starts from that host within 5 minutes:

metadata.log_source=windows_sysmon | sequence by device.hostname maxspan=5m fields(file.path, process.cmd_line) [class_uid=1001 file.path LIKE "%\\temp\\%"] [class_uid=1007]

Failure-then-success patterns, slowest first:

class_uid=3002 | sequence by user.name maxspan=5m [status_id=2] [status_id=1] | table user.name, step1_time, step2_time, sequence_duration_seconds | sort -sequence_duration_seconds

Notes

  • In a scheduled detection rule, set the rule's lookback to at least maxspan. Otherwise the first steps of a pattern can fall outside the window. See Detections.
  • Shorter maxspan values and narrower base searches run faster.

What's next

  • funnel: how many entities reach each step, and where they drop off
  • transaction: group events by key without ordered conditions
  • where: condition syntax
  • lateral: trace movement between hosts

On this page