tail
Keep the last N rows of a sorted result, or the newest N events in time order.
Use tail to keep the last N rows of an ordered result. On raw events, it returns the newest N events in ascending time order.
Syntax
... | tail [<count>]| Argument | Default | Description |
|---|---|---|
count | 10 | Number of rows to keep. |
How it works
- On raw events,
tailkeeps the newest N events and shows them in ascending time order (oldest of the N first). That reads like the end of a log file. - After
sort time,tail Nis the same thing: the N newest events, oldest first. It is not the oldest events; for those usesort time | head N. - After
sorton another field, or afterstats,tailkeeps the last N rows of that order. Sincestatsorders bycountdescending,stats count by f | tail 10gives the ten smallest groups.
Examples
The last ten events from a source, in reading order:
metadata.log_source=windows_event | tailThe 50 most recent process launches, oldest of them first:
class_uid=1007 | sort time | tail 50 | table time, device.hostname, process.cmd_lineThe ten least common processes by host count:
class_uid=1007 | stats dc(device.hostname) as hosts by process.name | sort -hosts | tail 10Notes
tailalso runs after a nano-side stage (lookup,prevalence,inputlookup,resolve_identity,ai,lateral).- For rare values with counts and percentages in one step, use rare.