nano SIEM
Search Commands

head

Supported in:Self-hosted

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>]
ArgumentDefaultDescription
count10Number of rows to keep.

How it works

  • On raw events, head keeps the newest N events. Event searches are ordered newest first (time descending) unless you sort.
  • After sort, head keeps the first N rows in that order.
  • After stats, top or rare, head keeps the first N aggregated rows. stats output is ordered by count descending when it has a count column, so stats count by f | head 10 gives the ten largest groups.

Examples

Inspect the ten most recent failed logons:

class_uid=3002 status_id=2 | head

Look at one raw CloudTrail event to see which fields it carries:

metadata.log_source=aws_cloudtrail | head 1

Ten source IPs with the most denied connections:

class_uid=4001 action_id=2 | stats count by src_endpoint.ip | sort -count | head 10

The oldest event in the time range:

metadata.log_source=windows_event | sort time | head 1

Five 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, duration

Notes

  • head early 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.

What's next

  • tail: the last N rows
  • sort: order rows before head
  • top: most common values with counts and percentages
  • sample: random rows

On this page