Search code examples
azure-application-insightskqltelemetryazure-log-analytics-workspace

How can I parse path parameters from a url in KQL (Kusto for Log Analytics)?


An application insights instance is tracking the request ingestion for a service with the following url path pattern:

http://testurl.net/item/{itemId}/store/{storeId}/buyme

When I go to log analytics to query based on the itemId and storeId, I can only see them in the url. Since they aren't query parameters, the parse_urlquery function doesn't return the desired values. They also don't appear in the customDimensions section of the query. I'm starting to think I'll need to add additional telemetry just to be able to access these values in log analytics.

How can I get the itemId and storeId from the url (or any other field) in KQL?

Sample URLs:

http://testurl.net/item/123/store/5267/buyme
http://testurl.net/item/554/store/446/buyme

Solution

  • datatable(url:string)
    [
        "http://testurl.net/item/123/store/5267/buyme"
       ,"http://testurl.net/item/554/store/446/buyme"
    ]
    | parse url with * "//testurl.net/item/" itemId:int "/store/" storeId:int *
    

    Fiddle