12

我想做,

  • 在“2.”中提取 param=1 的“查询”字符串,如下所示。
  • 在 Analytics 中获取 pageViews,表格为“3”。

1、pageView中包含的实际url

  • https://example.com/dir01/?query=apple&param=1
  • https://example.com/dir01/?query=apple&param=1
  • https://example.com/dir01/?query=lemon+juice&param=1
  • https://example.com/dir01/?query=lemon+juice&param=0
  • https://example.com/dir01/?query=tasteful+grape+wine&param=1

2. 预期提取的价值

  • apple
  • lemon+juice
  • tasteful+grape+wine

3. AI Analytics 的预期输出

  • 查询参数 | 数数
    • 苹果| 高分辨率照片| CLIPARTO 2
    • 柠檬+果汁 | 1
    • 美味+葡萄+酒| 1

图片

试图做

https://docs.microsoft.com/en-us/azure/application-insights/app-insights-analytics-reference#parseurl

https://aka.ms/AIAnalyticsDemo

我认为extractparseurl(url)应该有用。我尝试了后者parseurl(url),但不知道如何将“查询参数”提取为一列。

pageViews
| where timestamp > ago(1d)
| extend parsed_url=parseurl(url)
| summarize count() by tostring(parsed_url)
| render barchart 
  • url
    • http://aiconnect2.cloudapp.net/FabrikamProd/
  • parsed_url
    • {"Scheme":"http","Host":"aiconnect2.cloudapp.net","Port":"","Path":"/FabrikamProd/","Username":"","Password":"","Query Parameters":{},"Fragment":""}
4

1 回答 1

19

是的, parseurl 就是这样做的方法。它会产生一个动态值,您可以将其用作 json。获取查询参数的“查询”值:

pageViews
| where timestamp > ago(1d)
| extend parsed_url=parseurl(url)
| extend query = tostring(parsed_url["Query Parameters"]["query"])

并通过参数值进行总结:

pageViews
| where timestamp > ago(1d)
| extend parsed_url=parseurl(url)
| extend query = tostring(parsed_url["Query Parameters"]["query"])
| extend param = toint(parsed["Query Parameters"]["param"])
| summarize sum(param) by query

您可以在演示门户中查看它如何处理您的示例值:

let vals = datatable(url:string)["https://example.com/dir01/?
query=apple&param=1", "https://example.com/dir01/?query=apple&param=1", 
"https://example.com/dir01/?query=lemon+juice&param=1", 
"https://example.com/dir01/?query=lemon+juice&param=0", 
"https://example.com/dir01/?query=tasteful+grape+wine&param=1"];
vals
| extend parsed = parseurl(url)
| extend query = tostring(parsed["Query Parameters"]["query"])
| extend param = toint(parsed["Query Parameters"]["param"])
| summarize sum(param) by query

希望这可以帮助,

阿萨夫

于 2017-04-04T10:27:27.937 回答