本文介绍了Application Insights:Analytics(分析)-如何在特定位置提取字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做

  • 提取param = 1的查询"字符串,如"2"中所述.
  • 在Analytics(分析)中获取表格视图为"3"的pageViews.
  • 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
  • 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
  • apple
  • lemon+juice
  • tasteful+grape+wine
  • apple
  • lemon+juice
  • tasteful+grape+wine
  • 查询参数|数数
    • 苹果| 2
    • 柠檬+果汁| 1
    • 美味+葡萄+酒| 1
    • Query Parameters | Count
      • apple | 2
      • lemon+juice | 1
      • tasteful+grape+wine | 1

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

      https://aka.ms/AIAnalyticsDemo

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

      I think extract or parseurl(url) should be useful. I tried the latter parseurl(url) but don't know how to extract "Query Parameters" as one column.

      pageViews
      | where timestamp > ago(1d)
      | extend parsed_url=parseurl(url)
      | summarize count() by tostring(parsed_url)
      | render barchart 
      

      • url
        • http://aiconnect2.cloudapp.net/FabrikamProd/
          • url
            • http://aiconnect2.cloudapp.net/FabrikamProd/
              • {"Scheme":"http","Host":"aiconnect2.cloudapp.net","Port":"","Path":"/FabrikamProd/","Username":"","Password":"","Query Parameters":{},"Fragment":""}

              推荐答案

              是的,parseurl是实现此目的的方法.它会产生一个动态值,您可以将其用作json.要获取查询参数的查询"值:

              Yes, parseurl is the way to do it. It results in a dynamic value which you can use as a json.To get the "query" value of the query parameters:

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

              并通过参数值进行总结:

              and to summarize by the param value:

              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
              

              您可以看到它是如何工作在你的例子中的值的:

              You can see how it works on your example values in the 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
              

              希望这会有所帮助,

              Asaf

              这篇关于Application Insights:Analytics(分析)-如何在特定位置提取字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 03:03