应用程序洞察:分析 - 如何在特定位置提取字符串

时间:2017-04-04 09:55:40

标签: azure azure-application-insights ms-app-analytics

我想做,

  • 提取"查询"其中param = 1的字符串如下" 2。"
  • 使用表格" 3。"
  • 在Google Analytics中获取分页视图

1。 pageView

中包含的实际网址
  • 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中的预期输出

  • 查询参数|计数
    • apple | 2
    • 柠檬+果汁| 1
    • 有品味+葡萄+葡萄酒| 1

image

试图做

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":""}

1 个答案:

答案 0 :(得分:10)

是的,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

您可以在demo portal

中查看它对您的示例值的工作原理
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

希望这有帮助,

阿萨夫