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
A call below the top level of the query, such as abs(sort(x)), isn't supported yet. Prometheus applies the ordering there too. On a range query the ordering is discarded in both, 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
A call below the top level of the query, such as abs(sort(x)), isn't supported yet. Prometheus applies the ordering there too. On a range query the ordering is discarded in both, but Prometheus returns the series ordered by their labels, where Elasticsearch returns them in input order.