如何使 Application Insights kusto 查询在 performanceBucket 上正确排序?

How to make an Application Insights kusto query sort correctly on performanceBucket?

有没有办法让 Application Insights kusto 查询按 performanceBucket 'correctly' 排序,即按存储桶持续时间排序?当我使用 performanceBucket 进行总结或排序并且未指定排序时,我得到类似这样的结果(例如,请注意 1-3sec 与 3-7sec 不相邻):

如果我按 performanceBucket 添加排序,则按字母数字顺序完成:

我希望按此顺序(或相反)

您需要人为添加一个表示您喜欢的排序顺序的列,然后按它排序,然后投影出去:

// Synthetic data - don't copy this
let YourResult = datatable(perfBucket:string, count_:long) [
    "250ms-500ms", 14000,
    "7sec-15sec", 600,
    "1sec-3sec", 9700
];
// This is the actual query
YourResult
| extend sortOrder =
    case(perfBucket == "<250ms", 1,
         perfBucket == "250ms-500ms", 2,
         perfBucket == "500ms-1sec", 3,
         perfBucket == "1sec-3sec", 4,
         perfBucket == "3sec-7sec", 5,
         perfBucket == "7sec-15sec", 6,
         perfBucket == "15sec-30sec", 7,
         perfBucket == "30sec-1min" ,8,
         perfBucket == "1min-2min", 9,
         10)
| order by sortOrder asc
| project-away sortOrder

结果:

perfBucket count_
250ms-500ms 14000
1sec-3sec 9700
7sec-15sec 600