0
votes

I have an apim instance configured to log to application insights.

I run the following kusto query to pull back useful info:

requests
| extend requestBody = customDimensions["Request-Body"]
| extend requestMethod = customDimensions["HTTP Method"]
| extend ApiName = customDimensions["API Name"]
| where ApiName == "client"
| project  timestamp, ApiName, url, requestBody, requestMethod
| sort by timestamp desc 

The "url" that this returns is the inbound url of the apim instance. Does anyone know how this can be updated to also pull back the back-end url that apim forwarded the request onto?

1

1 Answers

2
votes

If you are writing the logs of the backend application to the same instance of Application Insights you can simply join your query result with the "requests" table using the operation_Id of the APIM request and the operation_ParentId of the backend request.

You can also join the APIM requests with the dependency table. This should also give you the backend requests:

dependencies
| where timestamp > ago(1h) 
| join (requests | where timestamp > ago(1h))
  on operation_Id

After that you can extract the fields you are interested in.

EDIT: To get the backend URL field only with data logged by APIM and without the backend logging to Application Insights you can use the 'data' field of the dependency table joining requests and dependencies as follows:

dependencies
| where timestamp > ago(1h) 
| join (requests | where timestamp > ago(1h))
  on operation_Id
  | project backendUrl = data