Search code examples
azure-application-insightskqlurl-parsing

How to summarize requests by url with path parameters using Kusto


I am trying to summarize API requests by url using Application Insights:

requests 
| summarize hits = count() by url  
| order by hits desc

some of the URLs have path parameters which I would like to ignore in the summary, so if the following urls are called:

https://foo.bar/api/v1/items/abc123/latest
https://foo.bar/api/v1/items/xyz789/latest

I would like them to be summarized together as

How should I modify my Kusto query?


Solution

  • You can do this with regex_replace:

    requests 
    | extend  newUrl = replace_regex(url, @"items\/[a-zA-Z0-9]*\/latest", @"items\/\*\/latest")
    | summarize hits = count() by newUrl  
    | order by hits desc