Aidan
Aidan

Reputation: 4901

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?

Upvotes: 1

Views: 1429

Answers (1)

Markus Meyer
Markus Meyer

Reputation: 3967

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

Upvotes: 2

Related Questions