Sorting functions
These functions sort the series of an instant vector by sample value. Ordering is observable only on instant queries. Range queries return the series in their input order, without applying the requested ordering.
Sorts instant-vector series by sample value in ascending order. NaN values are sorted last.
Ordering is observable only on instant queries. Range queries return the series in their input order, without applying the requested ordering.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
sort(http_requests_total)
Differences from Prometheus
Supported in this version only as the outermost function of the query. Prometheus also applies an ordering requested inside an enclosing function call. On a range query the ordering is discarded either way, but Prometheus returns the series ordered by their labels, where Elasticsearch returns them in input order.
Sorts instant-vector series by sample value in descending order. NaN values are sorted last.
Ordering is observable only on instant queries. Range queries return the series in their input order, without applying the requested ordering.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
sort_desc(http_requests_total)
Differences from Prometheus
Supported in this version only as the outermost function of the query. Prometheus also applies an ordering requested inside an enclosing function call. On a range query the ordering is discarded either way, but Prometheus returns the series ordered by their labels, where Elasticsearch returns them in input order.