SPL語句
-- SPL處理結果定義為命名資料集src,作為後續SPL運算式的輸入
.let src = *
| where status=cast(status as BIGINT);
-- 以命名資料集src作為輸入,篩選status欄位為5xx的資料,定義資料集err,不輸出
.let err = $src
| where status >= 500
| extend msg='ERR';
-- 以命名資料集src作為輸入,篩選status欄位為2xx的資料,定義資料集ok,不輸出
.let ok = $src
| where status >= 200 and status < 300
| extend msg='OK';
-- 輸出命名資料集err和ok
$err;
$ok;輸入資料
# 條目1
status: '200'
body: 'this is a test'
# 條目2
status: '500'
body: 'internal error'
# 條目3
status: '404'
body: 'not found'輸出結果
# 條目1: 資料集為err
status: '500'
body: 'internal error'
msg: 'ERR'
# 條目2: 資料集為ok
status: '200'
body: 'this is a test'
msg: 'OK'