Werk #16149: New OderBy header in livestatus

Component Livestatus
Title New OderBy header in livestatus
Date Jan 29, 2024
Checkmk Edition Checkmk Raw (CRE)
Checkmk Version 2.3.0b1 2.4.0b1
Level Trivial Change
Class New Feature
Compatibility Compatible - no manual interaction needed

We provide a new header for livestatus that returns the rows in sorted order.

For example, to sort host names in descending order

$ lq 'GET hosts\nColumns: name\nOrderBy: name desc'
zhost
yhost
xhost
...

in ascending order

$ lq 'GET hosts\nColumns: name\nOrderBy: name asc'
ahost
bhost
...

or, alternatively without asc,

$ lq 'GET hosts\nColumns: name\nOrderBy: name'
ahost
bhost
...

The OrderBy header can be combined with the Limit header to limit the number of results as expected.

$ lq 'GET hosts\nColumns: name\nOrderBy: name\nLimit: 1'
ahost

Furthermore, it is possible to sort on dictionary keys with the following syntax

$ lq << EOF
GET services
Columns: host_name description performance_data
OrderBy: performance_data.user_time
EOF
...

To the list of all Werks