Kusto 自定义排序顺序?

eri*_*ine 7 azure-log-analytics kql azure-data-explorer

如何在 Kusto 中执行自定义排序顺序?

查询示例:

//==================================================//
// Assign variables
//==================================================//
let varStart = ago(2d);
let varEnd = now();
let varStorageAccount = 'stgacctname';
//==================================================//
// Filter table
//==================================================//
StorageBlobLogs
| where TimeGenerated between (varStart .. varEnd)
  and AccountName == varStorageAccount
| sort by OperationName
Run Code Online (Sandbox Code Playgroud)

需要:

  • 我想将各种OperationNamesGetBlobAppendFile等)放入自定义订单中。
  • 就像是: | sort by OperationName['GetBlob'], OperationName['AppendFile'], OperationName asc
  • 理想情况下,我想指定排序依据的值,然后允许 Kusto 使用asc/对剩余的进行排序desc

这可能吗?

Sla*_*k N 8

使用辅助列,如下所示:

datatable(OperationName:string, SomethingElse:string)
[
    "AppendFile", "3",
    "GetBlob", "1",
    "AppendFile", "4",
    "GetBlob", "2"
]
| extend OrderPriority =
    case(OperationName == "GetBlob", 1,
         OperationName == "AppendFile", 2,
         3)
| order by OrderPriority asc, SomethingElse asc 
| project-away OrderPriority
Run Code Online (Sandbox Code Playgroud)

输出:

操作名称 其他的东西
获取Blob 1
获取Blob 2
追加文件 3
追加文件 4