确定 Kusto 中事件的持续时间?

Determine duration of events in Kusto?

如何在以下示例中使用 Kusto 计算持续时间?

目标: 确定 Azure Blob 存储中 blob 的总“处理时间”

背景:

所以现在我结合了这两个查询来显示对给定 blob 执行的所有 OperationNames

//==================================================//
// Assign variables
//==================================================//
let varStart = ago(2d);
let varEnd = now();
let varStorageAccount = 'stgaccountname';
let varSampleUploadUri = 'https://stgaccountname.dfs.core.windows.net/containername/filename.csv';
let varSampleDownloadUri = replace(@'%2F', @'/', replace(@'.dfs.', @'.blob.', tostring(varSampleUploadUri)));
//==================================================//
// Filter table
//==================================================//
StorageBlobLogs
| where TimeGenerated between (varStart .. varEnd)
  and AccountName == varStorageAccount
  //and StatusText == varStatus
  and split(Uri, '?')[0] == varSampleUploadUri
  or split(Uri, '?')[0] == varSampleDownloadUri
//==================================================//
// Group and parse results
//==================================================//
| summarize 
  count() by OperationName,
  TimeGenerated,
  UserAgent = tostring(split(UserAgentHeader, ' ')[0]),
  ChunkSize = iif(OperationName == 'GetBlob', format_bytes(ResponseBodySize, 2, 'MB'), format_bytes(RequestBodySize, 2, 'MB')),
  StatusCode,
  StatusText
| order by TimeGenerated asc

问题是:

试试这个:

YourQuery
| summarize Duration = max(TimeGenerated) - min(TimeGenerated)

这是一个包含一些数据表格式的合成数据的示例:

datatable(Timestamp:datetime, SomeGuid:string)
[
    datetime(2021-05-27T06:03:59.5708689Z), "2e76bf18-04ed-4d3f-afe3-cff87c532b10", 
    datetime(2021-05-27T06:04:03.3834404Z), "27a7f8ec-f0a7-4fad-9784-996051d2a9f9", 
    datetime(2021-05-27T06:05:06.1334979Z), "568ab8a4-2ed2-486f-a7b9-1d27379b52db", 
    datetime(2021-05-27T06:06:20.3212560Z), "edd1f7d2-5fc5-482f-88d3-6ad16a1ae000", 
    datetime(2021-05-27T06:07:30.6034174Z), "cf5cb66b-05b1-43f3-ad04-23c56f96687e", 
]
| summarize Duration = max(Timestamp) - min(Timestamp)

输出:

00:03:31.0325485