azure-application-insights - 使用始终返回 0 的 Kusto 查询语言返回十进制值

标签 azure-application-insights kql

我有一个用于查询 Application Insights 的 Kusto Query。目标是获取 5 分钟存储桶中的失败请求数/并将其除以同一 5 分钟存储桶中的请求总数。如果这个百分比大于某个值,我最终会建立一个警报来触发。但是,我似乎无法正确查询。

在下面的示例中,我硬编码了一个特定的时间戳,以确保我得到一些失败。

这里是查询:

let fn = "APP_NAME";
requests
| where success == "False" and cloud_RoleName == fn
| summarize failed=sum(itemCount) by bin(timestamp, 5m)
| where timestamp == "2021-05-17T20:20:00Z"
| join (
    requests
    | where cloud_RoleName == fn
    | summarize reqs=sum(itemCount) by bin(timestamp, 5m)
    | where timestamp == "2021-05-17T20:20:00Z"
  ) on timestamp
| project timestamp, failed, reqs
| extend p=round(failed/reqs, 2)

目前返回:

timestamp [UTC]             |p  |failed  |reqs
5/17/2021, 8:20:00.000 PM   0   1,220   6,649

如果有人可以让我深入了解如何获得我期望 p 的十进制值 (~0.18)?

最佳答案

必须将值转换为 Doubles 以使其返回 0 以外的值。

let fn = "APP_NAME";
requests
| where success == "False" and cloud_RoleName == fn
| summarize failed=sum(itemCount) by bin(timestamp, 5m)
| join (
    requests
    | where cloud_RoleName == fn
    | summarize reqs=sum(itemCount) by bin(timestamp, 5m)
  ) on timestamp
| project timestamp, failedReqs=failed, totalRequests=reqs, percentage=(todouble(failed)  / todouble(reqs) * 100)

关于azure-application-insights - 使用始终返回 0 的 Kusto 查询语言返回十进制值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67578511/

相关文章:

kql - 库斯托 |计算按 2 列分组的百分比

azure - 使用 `make-series` 运算符而不定义确切的日期范围

azure - 应用程序洞察不记录请求、页面 View 、自定义事件

.net - 遥测采样而不影响错误/故障

azure - .Net Core - Azure Application Insights 未显示异常

kql - Kusto 设置查询的变量输出

azure - 使用 Azure Application Insights REST API (https ://dev. applicationinsights.io) 读取自定义事件/指标

azure - UserContext类的AccountId、AuthenticatedUserId和Id有什么区别?

azure - 外部应用于 kusto/Azure AppInsights