azure - 确定 Kusto 事件的持续时间?

标签 azure azure-log-analytics kql

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

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

背景:

  • 使用 Azure 数据工厂 (ADF) 将 Blob 上传到存储帐户。
    • 这由多个 API 调用和方法组成(CreatePathFileLeaseFileAppendFileFlushFileLeaseFile) 到存储帐户。
    • 大文件的典型端到端 ADF 上传如下所示: enter image description here enter image description here
  • 然后使用 Azure 函数从存储帐户下载 Blob
    • 这还包含多个 API 调用(但仅限 GetBlob 方法)
    • 看起来基本相同 enter image description here

现在我将这两个查询组合起来,以显示在给定 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
  • 结果:一个不错的组合表 enter image description here

问题是:

  • 如何调整查询以显示从最早的 TimeGenerate 事件到最后一个 TimeGenerate 事件的持续时间?
    • 这将显示第一次上传 API 调用和最终下载 API 调用之间的持续时间。

最佳答案

试试这个:

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

关于azure - 确定 Kusto 事件的持续时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67713149/

相关文章:

azure - 合并两个 Application Insights 资源时出现未知功能应用

c# - .Net Micro 与 Microsoft Azure

c# - ASP.NET Core 上 CloudTableClient 类的最佳 DI 注册范围是哪个

azure - 将 SQL Server 数据库从 Rackspace 云迁移到 Microsoft Azure

azure - 在 azure 中,如何在汇总语句中连接字符串?

azure - `where * contains ` 和 `search` 在 KQL 中是同一个运算符吗?

azure - 如何配置逻辑应用以登录到 ARM 模板中的 Log Analytics?

azure - 是否可以在 Azure 警报中显示 KQL 查询结果?

database - 什么是表格表达式语句?

azure - 我在 ADO 管道中使用 Azure Bicep 生成了资源。需要创建一个新的管道,用代码填充资源。不知道如何