App Insights:按请求参数分组的获取请求计数

问题描述 投票:0回答:1

所以,我正在尝试分析系统的性能。我们有 3 种类型的请求 URL。像这样的东西-->

1. https://<base-url>/recent?param1=string1
   https://<base-url>/recent?param2=string2
2. https://<base-url>/all?param1=string3
   https://<base-url>/all?param2=string4
3. https://<base-url>?param3=string5

我正在使用这个查询:

let start=datetime("2023-07-31T23:59:59.000Z");
let end=datetime("2023-08-01T23:59:59.000Z");
let timeGrain=5m;
let dataset=requests
    | where timestamp > start and timestamp < end
    | where client_Type != "Browser"
    | where * has "<base-url>?param1"
;
dataset
| summarize count_=sum(itemCount), avg(duration), percentiles(duration, 50, 95, 99) by operation_Name
| union(dataset
    | summarize count_=sum(itemCount), avg(duration), percentiles(duration, 50, 95, 99)
    | extend operation_Name="Overall")

我想通过特定的请求参数分析这些 URL 的请求计数。我能够针对特定请求参数这样做。 我想要一个模块化查询,显示按请求参数分组的计数和持续时间。

azure azure-application-insights azure-api-management kql
1个回答
0
投票

我已经使用这些 URL 来重现并通过使用下面给出的查询得到了结果 -

1. https://<base-url>/echo/recent?param1=Afreen
   https://<base-url>/echo/recent?param2=Afreen
2. https://<base-url>/echo/all?param1=Afreen
   https://<base-url>/echo/all?param2=Afreen
3. https://<base-url>/echo/resource?param1=sample

Query:

let start=datetime("2023-08-07T11:40:30.8754634Z");
let end=datetime("2023-08-09T23:59:59.000Z");
let timeGrain = 5m;
let base_url = dynamic(["https://<base-url>/echo/resource", "https://<base-url>/echo/recent", "https://<base-url>/echo/all"]);
let dataset = requests
    | where timestamp > start and timestamp < end
    | where client_Type != "Browser"
    | where url has_any (base_url) and isnotempty(split(url, "?")[1])
    | extend urlParams = tostring(parse_url(url)["Query Parameters"])
;
dataset
| summarize count_ = sum(itemCount), avg(duration), percentiles(duration, 50, 95, 99) by urlParams

Output:

enter image description here

如果您想按 Param_Name 对它们进行分组,请使用

split(urlParams, ":")[0]
,因为
parse_url(url)["Query Parameters"]
"param" : "value"
格式返回值。

© www.soinside.com 2019 - 2024. All rights reserved.