transaction
Group events that share key values into one row per transaction, with duration and event count.
Use transaction to group events that share your chosen key values. Each result row includes the transaction's start, end, duration, and event count.
Syntax
... | transaction <field>[, <field> ...] [startswith=<condition>] [endswith=<condition>] [maxspan=<duration>] [maxevents=<n>]| Argument | Default | Description |
|---|---|---|
field | required | One or more fields that identify a transaction. Events where a key field is empty are left out. |
startswith | none | Condition that opens a transaction. Write it as (expr), "string" or a bare expression. |
endswith | none | Condition that closes a transaction. |
maxspan | none | Longest allowed transaction, for example 30m. |
maxevents | none | Most events allowed in one transaction. |
Output fields
| Field | Description |
|---|---|
| key fields | The values that identify the transaction |
transaction_start, transaction_end | Time of the first and last event |
duration | Seconds between the first and last event |
eventcount | Number of events in the transaction |
_raw_events | The events' message values (up to 1,000, or up to maxevents) |
| other fields named in the search | The value from the transaction's latest event |
Rows are ordered by transaction_start, newest first.
How it works
- Without
startswith/endswith, all events for a key value form one transaction. Withmaxspan, events are cut into fixed windows of that length aligned to the clock (for examplemaxspan=10mgives 10:00–10:10, 10:10–10:20, …), one transaction per key per window. - With
startswith, each matching event opens a new transaction for that key. Withendswith, the transaction closes at the first matching event, and only transactions that reach an end event are returned. maxspanandmaxeventsdrop transactions that are longer or larger than the limit; they don't split them.
Examples
Logon activity per user in 10-minute windows, busiest first:
class_uid=3002 | transaction user.name maxspan=10m | sort -eventcount | table user.name, transaction_start, eventcount, durationFailed logons followed by a success for the same user within 15 minutes:
class_uid=3002 | transaction user.name startswith=(status_id=2) endswith=(status_id=1) maxspan=15m | table user.name, transaction_start, duration, eventcountShort bursts of failures (at least 20 failed logons for one account in 5 minutes):
class_uid=3002 status_id=2 | transaction user.name maxspan=5m | where eventcount >= 20 | table user.name, transaction_start, eventcountConnection bursts from one host to one destination port:
class_uid=4001 | transaction device.hostname, dst_endpoint.port maxspan=1m | where eventcount > 100 | table device.hostname, dst_endpoint.port, eventcount, durationWeb sessions per client IP, capped at 200 requests:
class_uid=4002 | transaction src_endpoint.ip maxspan=30m maxevents=200 | stats avg(duration) as avg_seconds, avg(eventcount) as avg_requestsNotes
transactionreturns one row per transaction, not the events. To see events, filter on the key value and thetransaction_start/transaction_endrange.- For ordered multi-step patterns with different conditions per step, sequence is more precise.
What's next
- sequence: ordered patterns across steps
- funnel: how far entities progress through steps
- stats: aggregate without grouping into transactions
- streamstats: running statistics per event