应用程序见解中请求的持续时间范围

时间:2018-07-17 15:35:44

标签: azure-application-insights

我正在基于持续时间为某些请求创建存储桶。因此,对于名称“ A”的请求,我需要计算持续时间小于2秒,2秒-4秒和> 4秒的时间。我使用以下方法分别获取数据:

requests
| where name == "A"
| where duration <= 2000
| summarize count()

但是我真正需要的是数量占“ A”请求总数的百分比,例如,像这样的表:

名称<2秒2-4秒> 4秒 89%98%99%

谢谢, 克里斯

1 个答案:

答案 0 :(得分:0)

一种方法是依靠performanceBucket字段。这样可以进行一些分配,但是性能段已预先配置。

requests
| where timestamp > ago(1d)
| summarize count() by performanceBucket

另一种方法是执行以下操作:

requests
| where timestamp > ago(1d)
| extend requestPeformanceBucket = iff(duration < 2000, "<2secs",
    iff(duration < 2000, "2secs-4secs", ">4secs"))
| summarize count() by requestPeformanceBucket

这是获取百分比的方法:

let dataSet = requests
| where timestamp > ago(1d);
let totalCount = toscalar(dataSet | count);
dataSet
| extend requestPeformanceBucket = iff(duration < 2000, "<2secs",
    iff(duration < 2000, "2secs-4secs", ">4secs"))
| summarize count() by requestPeformanceBucket
| project ["Bucket"]=requestPeformanceBucket, 
          ["Count"]=count_, 
          ["Percentage"]=strcat(round(todouble(count_) / totalCount * 100, 2), "%")

enter image description here