zhu*_*es3 3 azure-application-insights kql
我有一个 Kusto 查询,用于查询 Application Insights。目标是获取 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)
Run Code Online (Sandbox Code Playgroud)
目前它返回:
timestamp [UTC] |p |failed |reqs
5/17/2021, 8:20:00.000 PM 0 1,220 6,649
Run Code Online (Sandbox Code Playgroud)
如果有人能让我深入了解如何获得我期望的 p 的小数值(~0.18)?
必须将值转换为 Double 才能返回 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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7561 次 |
| 最近记录: |