Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用Azure上的应用程序洞察在ASP.Net MVC应用程序上捕获搜索查询字符串_C#_Jquery_Vb.net_Azure_Azure Application Insights - Fatal编程技术网

C# 使用Azure上的应用程序洞察在ASP.Net MVC应用程序上捕获搜索查询字符串

C# 使用Azure上的应用程序洞察在ASP.Net MVC应用程序上捕获搜索查询字符串,c#,jquery,vb.net,azure,azure-application-insights,C#,Jquery,Vb.net,Azure,Azure Application Insights,作为Azure Application Insights的新手,我想知道如何使用Azure Application Insights在ASP.Net MVC应用程序上捕获一个简单的免费文本搜索查询字符串 当用户在应用程序上输入搜索查询时,应用程序创建一个GET请求。查询如下所示https://example.com/GalleryPartial?search=Application&id=&sort=。我需要捕获的是为search输入的文本,在这个特定实例中是“Application” 我已尝试

作为
Azure Application Insights
的新手,我想知道如何使用
Azure Application Insights
ASP.Net MVC
应用程序上捕获一个简单的免费文本搜索查询字符串

当用户在应用程序上输入搜索查询时,应用程序创建一个
GET
请求。查询如下所示
https://example.com/GalleryPartial?search=Application&id=&sort=
。我需要捕获的是为
search
输入的文本,在这个特定实例中是“Application”

我已尝试使用下面的
应用程序洞察
生活中的
日志
捕获链接:

requests
| where url contains "search"
| summarize count() by bin(timestamp, 1m), URL
| render timechart 
问题:如何仅提取搜索查询并在Application Insights仪表板中查看所有搜索查询(用户输入的文本)的列表?除了为Azure应用程序捕获一些遥测数据外,我没有更多的代码

视图
如下所示:

@ModelType IEnumerable(Of Models.UXFilter)
@code
Dim m_Search As String
If ViewContext.Controller.ViewBag.SearchObject IsNot Nothing Then
    m_Search = ViewContext.Controller.ViewBag.SearchObject
Else
    m_Search = ""
End If
End Code

<div>
    <div class="wrapperSearch">
         <input class="inputSearch" placeholder="Search..." type="text" id="searchValue" value="@m_Search" autocomplete="off">
    </div>
</div>
    $(document).ready(function () {
    var amountFilter = 0;

    $('#searchValue').on('keyup', function () {

        var filterText = $('#searchValue').val();
        var DepId = JSON.parse('@Html.Raw(Json.Encode(ViewData("ID")))');
        var filterTextLength = filterText.length;

        $("#log").ajaxError(function (event, jqxhr, settings, exception) {
            alert(exception);
        });

        var runIt = 'false';

        if (filterText.length > 2) {
            runIt = 'true';
        } else if (filterText.length == 0) {
            runIt = 'true';
        }

        if (runIt == 'true') {
            var existingUrl = window.location.href;
            var n = existingUrl.indexOf("/Gallery");
            if (n < 0) {
                var url = '@Url.Action("Gallery", "UX", New With {.id = "filter"})?search=' + filterText;
                window.location.href = url;
            }

            $.get('@Url.Action("GalleryPartial")',
                    { searchen: filterText, id: DepId, sort: "" }, function (data) {

                        $("#target").html(data);
                });

            SetupFilters();
        }
    }); 
}

在Kusto中,有几种辅助方法可以使用。在您的情况下,这可能会很有帮助,因为它将包含一个可以轻松访问的查询参数数组:

requests
| extend searchText = tostring(parse_url(url).["Query Parameters"]["search"])
| summarize count() by bin(timestamp, 1m), searchText 
| render timechart