azure app insights get a part of a string from the url and display it in the name column

There are some functions that might be helpful.

First of all, you can get the different url parts using parse_url() method. For example, given the url https://localhost:80/api/external-reports/blob/39/test 01b/false :

| project parse_url(url)


{"Scheme":"https","Host":"localhost","Port":"80","Path":"/api/external-reports/blob/39/test 01b/false","Username":"","Password":"","Query Parameters":{},"Fragment":""} 
  • You can split the result even further using the split() method:
| project split(parse_url(url).Path, "/")


["","api","external-reports","blob","39","test 01b","false"]    
  • To get the part you want you can use the index:
| project mycolumn = split(parse_url(test).Path, "/")[5]


test 01b
  • When an index is used that is greater than the number of parts an empty result is returned. You can replace it with a value of your own using the coalesce function:
| project mycolumn = coalesce(split(parse_url(test).Path, "/")[5], "unknown")

it shows unknown when the index is out of range or the part is empty.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top