0

Given the following request URLs:

I wish to get separate columns for the values of {foo-id} and {bar-id}

What I tried

requests
| where timestamp > ago(1d)
| extend parsed_url=parse_url(url)
| extend path = tostring(parsed_url["Path"])
| extend: foo = "value of foo-id"
| extend: bar = "value of bar-id"

This gives me /api/foos/{foo-id}/bars/{bar-id} as a new path column.

Can I solve this question without using regular expressions?

Related, but not the same question: Application Insights: Analytics - how to extract string at specific position

Bernard Vander Beken
  • 4,848
  • 5
  • 54
  • 76

1 Answers1

2

Splitting on the '/' character will give you an array and then you can extract the elements you are looking for as long as the path stays consistent. Using parse_url() is optional- you could use substring() or just adjust the indexes you retrieve.

requests
| extend path = parse_url(url)
| extend elements = split(substring(path.Path, 1), "/") //gets rid of the leading slash
| extend foo=tostring(elements[2]), bar=tostring(elements[4])
| summarize count() by foo, bar
PerfectlyPanda
  • 3,271
  • 1
  • 6
  • 17