ソート演算子
入力表の行を 1 つ以上の列の順序にソートします。
events | sort by original_time desc
別名
order
構文
T | sort by 式 [asc | desc] [nulls first | nulls last] [, ...]
引数
- T: ソートする表入力。
- expression: ソートに使用するスカラー式。 値のタイプは、数値、日付、時刻、またはストリングでなければなりません。
asc昇順 (低いものから高いものへ) にソートします。 デフォルトはdescで、高いものから低いものの順に降順で表示されます。nulls first(ascオーダーのデフォルト) は NULL 値を先頭に配置し、nulls last(descオーダーのデフォルト) は NULL 値を末尾に配置します。
例
この例では、名前でソートされた、 'Swizzor Botnet Traffic'ではない name を持つ events 内のすべてのレコードを検索します。 name 列に NULL 値が含まれている場合、それらの値は結果の最初の行に表示されます。
events
| project name, original_time
| where original_time > ago(5m)
| where name != 'Swizzor Botnet Traffic'
| distinct name
| sort by name asc nulls first
| limit 5
結果
name |
|---|
NULL |
(Primary) Failover cable OK |
(Primary) Failover cable Not OK |
(Primary) Failover message block alloc failed |
30419 Internet Explorer 8 XSS Attack |
A fatal alert was generated and sent to the remote endpoint |
結果から NULL 値を除外するには、ソートの呼び出しの前にフィルターを追加します。
events
| project name, original_time
| where original_time > ago(5m)
| where name != 'Swizzor Botnet Traffic' and isnotnull(name)
| distinct name
| sort by name asc
| limit 5
結果
name |
|---|
(Primary) Failover cable OK |
(Primary) Failover cable Not OK |
(Primary) Failover message block alloc failed |
30419 Internet Explorer 8 XSS Attack |
A fatal alert was generated and sent to the remote endpoint |