Application Insights 查询以显示请求总数、通过总数和失败总数

Application Insights Query to display Total Request vs Total Passed vs Total Failed

任何人都可以共享 Azure Application Insights 查询以显示给定测试持续时间内的总请求数、总通过数和总失败数: 操作 Totalcount TotalPassed TotalFailed 请求 1 10 5 5 请求 2 10 7 3

感谢@lubumbax你的回答帮助我提高了查询知识。

我在这里使用查询从应用程序洞察中获取总计数、成功和失败响应。

查询如下:

let TOTAL = requests | where timestamp > ago(1d) | summarize TotalRequests=sum(itemCount) | extend Foo=1;
let Req_TOTAL = materialize(TOTAL);

let FAILED = requests
| where timestamp > ago(1d)
| where resultCode hasprefix "5"
| summarize Failed=sum(itemCount)
| extend Foo=1;
let Req_FAILED = materialize(FAILED);

let SUCCESS = requests
| where timestamp > ago(1d)
| where resultCode hasprefix "2"
| summarize Success=sum(itemCount)
| extend Foo=1;
let Req_SUCCESSED = materialize(SUCCESS);

Req_FAILED
| join kind=inner Req_TOTAL on Foo
| join kind=inner Req_SUCCESSED on Foo
| extend PercentFailed = round(todouble(Failed * 100) / TotalRequests, 2)
| extend PercentSuccess = round(todouble(Success * 100)/ TotalRequests, 2)
| project TotalRequests, Failed, Success, PercentFailed, PercentSuccess; availabilityResults

结果: