Count and aggregate require the
search.aggregate scope.Inspect results first
Start with a normal search to confirm the query matches the intended infrastructure:pagination.total_relation:
eq:totalis exact.gte:totalis a lower bound.
Request an exact count
Call count only when the exact total matters:Group the population
This request groups matching hosts by country and observed service port:field: the public field that was grouped.count_unit: what each bucket count represents.buckets: typed values and counts.relation: whether counts are exact or lower bounds.has_more: whether more buckets exist.sampled: whether sampling affected the group.
hosts dataset groups by eight fields: services.port,
services.protocol, country_code, asn, tags, service_ports,
service_protocols, and service_transports.
Measure a single host
Those same counters answer questions in one clause, without an aggregation at all. Each summarizes the host’s current services:Host-level counters measure spread across what a host exposes now. The
service-level
distinct_* fields, reached as services.distinct_banners and
similar, measure churn on a single service over time. Reach for the first to
find sprawl, and the second to find something that keeps changing.Build a service hunt
Turn a detection hypothesis into a reviewed search before measuring it.
Aggregation contract
Browse request limits, bucket schemas, and endpoint responses.