我有一个用于查询 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/