head
Keep the first N rows of a result: the newest events, or the top rows after a sort or aggregation.
Use head to keep the first N rows of your results. Apply it after a sort or aggregation to limit the rows you review.
Syntax
... | head [<count>]| Argument | Default | Description |
|---|---|---|
count | 10 | Number of rows to keep. |
How it works
- On raw events,
headkeeps the newest N events. Event searches are ordered newest first (timedescending) unless you sort. - After
sort,headkeeps the first N rows in that order. - After
stats,toporrare,headkeeps the first N aggregated rows.statsoutput is ordered bycountdescending when it has acountcolumn, sostats count by f | head 10gives the ten largest groups.
Examples
Inspect the ten most recent failed logons:
class_uid=3002 status_id=2 | headLook at one raw CloudTrail event to see which fields it carries:
metadata.log_source=aws_cloudtrail | head 1Ten source IPs with the most denied connections:
class_uid=4001 action_id=2 | stats count by src_endpoint.ip | sort -count | head 10The oldest event in the time range:
metadata.log_source=windows_event | sort time | head 1Five slowest HTTP responses, with context:
class_uid=4002 | sort -duration | head 5 | table time, src_endpoint.ip, http_request.url.url_string, http_response.code, durationNotes
headearly in a pipeline limits the rows every later command processes.- To sample events from the whole time range instead of the newest ones, use sample.