You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求修改Kusto查询:生成Azure函数小时级成功失败时序图

修改后的Kusto查询(按小时统计成功/失败次数)

requests
| project
    timestamp,
    success,
    cloud_RoleName,
    operation_Name
| where timestamp > ago(30d)
| where cloud_RoleName =~ 'my-function-app-site' and operation_Name =~ 'FunctionName'
// 按1小时时间桶分组,统计成功、失败次数
| summarize 
    成功次数 = countif(success == true),
    失败次数 = countif(success == false)
    by bin(timestamp, 1h)
// 按时间升序排列,保证时序图逻辑正确
| sort by timestamp asc

关键说明

  • bin(timestamp, 1h):将时间戳按1小时为单位拆分,这是实现按小时统计的核心逻辑。如果需要更细粒度(比如15分钟),可以改成bin(timestamp, 15m)。
  • countif()函数:针对success字段的布尔值分别计数,直接得到每个时间桶内的成功/失败总量。
  • 精简了project字段:只保留统计必需的字段,减少数据处理量,提升查询效率。

扩展优化(可选)

如果需要区分不同的失败类型,可以结合resultCode字段扩展统计,比如:

requests
| project
    timestamp,
    success,
    resultCode,
    cloud_RoleName,
    operation_Name
| where timestamp > ago(30d)
| where cloud_RoleName =~ 'my-function-app-site' and operation_Name =~ 'FunctionName'
| summarize 
    成功次数 = countif(success == true),
    按错误码分组失败 = make_bag(pack(resultCode, countif(success == false)))
    by bin(timestamp, 1h)
| sort by timestamp asc

内容的提问来源于stack exchange,提问作者Dhawal Dhingra

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 16:57:08