A stats command is a search command that calculates aggregations such as count, sum, average, min and max over search results. In security and log analytics, it is used to summarise events by field values, such as events per user or failures per host.
How a stats command works
A stats command runs aggregations over search results, letting you turn raw event rows into concise measures such as counts, totals, averages, minimums and maximums. It is a summary operator rather than a filtering operator, so its value is in collapsing noisy telemetry into patterns that can be read quickly and compared across fields.
In security and log analytics, that usually means asking questions like how many failures happened per host, which users generated the most errors, or how event volume changes by source, action or status. The command does not change the underlying events, it reshapes them into a report-friendly view.
What a stats command is used for
The main purpose of stats is to support investigation, monitoring and reporting. Security teams use it to find concentrations, trends and outliers that are hard to see in raw logs. That makes it useful for high-level situational awareness, dashboarding and the first pass of exploratory analysis.
Because the command operates on grouped results, the choice of field is decisive. A stats query grouped by user shows behaviour by identity, while grouping by host, source or action exposes different operational patterns. The same command can answer very different questions depending on the field values you aggregate on.
Stats is especially useful when the goal is comparison rather than reconstruction. If you need the exact event sequence, you would normally rely on search and event inspection first, then use stats to summarise what the broader dataset is doing.
Common aggregations and query patterns
Most stats usage revolves around a small set of aggregate functions, including count, sum, average, minimum and maximum. These are often combined in one query so a single result set can show both scale and distribution. In practice, teams often pair those aggregations with grouping, sorting and time-based bucketing to make the output readable.
A typical pattern is to count events per category, then sort descending to surface the busiest values. Another is to compute averages and maxima to see whether a subset of systems behaves differently from the rest. When used well, stats becomes a compact way to transform event streams into operational evidence.
Its usefulness also depends on data quality. If field values are inconsistent, missing or overly free-form, the resulting summaries become less reliable. Good telemetry design therefore improves the value of stats queries even though the command itself is simple.
Why stats matters in security analysis
In security work, summarisation is not just convenience, it is a detection aid. Stats can reveal repeated authentication failures, spikes in requests, unusual error rates or activity concentrated on a single user, host or source. Those patterns often provide the first clue that something deserves deeper investigation.
It is also useful for baselining. By measuring normal volume or distribution across a field, analysts can compare current activity against expected behaviour. That does not prove maliciousness on its own, but it helps separate ordinary noise from events that merit review.
When paired with other search logic, stats can support both triage and reporting. It helps answer “how much”, “where”, and “which”, which are often the first operational questions after an alert, incident or audit request.
Risk and Threat Considerations
Stats commands can hide important detail if teams rely on summaries too early. Aggregation can flatten the very signals that distinguish normal behaviour from abuse, especially when a single high-level count masks rare but important events inside the group.
Failure mechanism: An analyst may see a benign-looking total or average and miss concentration, repetition or a low-volume pattern that only becomes visible when the underlying events are inspected. Attackers can benefit from that blind spot by spreading activity across time, users or hosts so that no single aggregate looks extreme.
Impact: Poorly chosen summary queries can delay detection, weaken triage and obscure the scope of suspicious activity, especially when the investigation depends on understanding who did what, where and how often.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
NIST CSF 2.0 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST CSF 2.0 | DE.CM-01 — Security Continuous Monitoring | Stats summaries support ongoing monitoring of event volume and anomalies. |
| ID.AM-06 — Cybersecurity Roles and Responsibilities | Field-grouped summaries help assign operational ownership by user, host or source. | |
| Recommendation — Use summary queries to monitor event patterns and flag unusual activity for follow-up. Map recurring summary outputs to the teams that own the affected systems or identities. | ||
| NIST SP 800-53 Rev 5 | AU-6 — Audit Review, Analysis, and Reporting | Stats is a core analysis pattern for turning audit data into actionable review output. |
| AU-12 — Audit Record Generation | Stats depends on sufficiently detailed logs to produce meaningful aggregates. | |
| Recommendation — Analyze audit data with aggregate queries to identify trends, anomalies, and review priorities. Generate audit records with the fields needed to support useful aggregation and review. | ||
Practitioner Guidance
Why practitioners should care: Use stats when you need an answer about distribution, frequency or magnitude, not when you need event-level reconstruction. The command is strongest as an analysis layer on top of a well-defined search, not as a replacement for one.
Common misunderstanding: A summary result is often treated as if it were the full picture. In practice, a good stats query should be easy to explain, tied to a specific question and paired with a follow-up path for drilling into the underlying events when the summary looks unusual.
Practitioner takeaway: The best stats queries are narrow enough to be meaningful and broad enough to reveal pattern, then followed by inspection of the raw records that produced the aggregate.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 16, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org