Partilhar via


Retrieving Distinct Count of the PageViews in Application Insights using parseurl

Had a query from a partner today about how they could get a report from Application Insights to tell them how many times a particular App Service had been called. The sticking point was to group all of the hits to a particular instance irrespective of the full url that was being retrieved.

We built this up slowly to find out the syntax of what was being expected

// Create a table with a query let recentReqs = pageViews | where timestamp > ago(30d); // select one column into a new table let recentHosts = recentReqs | project parsejson(parseurl(url))["Host"]; recentHosts | summarize count() by tostring(Host)

Once we had this working, we knew we could simplifying this into

pageViews | where timestamp > ago(30d) | summarize count() by tostring(parsejson(parseurl((url))["Host"]))

Hope this helps someone!