Werk 16149 was adapted. The following is the new Werk, a diff is shown at the end of the
message.
[//]: # (werk v2)
# New OderBy header in livestatus
key | value
---------- | ---
date | 2024-01-29T10:12:24+00:00
version | 2.3.0b1
class | feature
edition | cre
component | livestatus
level | 1
compatible | yes
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
...
```
------------------------------------<diff>-------------------------------------------
[//]: # (werk v2)
# New OderBy header in livestatus
key | value
---------- | ---
date | 2024-01-29T10:12:24+00:00
version | 2.3.0b1
class | feature
edition | cre
component | livestatus
level | 1
compatible | yes
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\OrderBy: name\Limit: 1'
+ $ 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
...
```