2
votes

How can I correlate a single request across multiple Azure services in Application Insights?

Say we expose a "Create Case" API endpoint in API Management, using an API App.

The API App does some work, including triggering a Logic App.

How can I see the "flow" of the request throughout all the various Azure services to give a single "view" of the state of a particular case?

And I'm only saying Application Insights as we sort of use it in Web Apps / API Apps, so any other Azure based tool is fine

2
What we do: in API Management inbound policy we create a GUID (CorrelationId) which we then pass on either in HTTP headers to API backends or in Message Properties through Service Bus Queues/Topics. API Management logging is pushed to EventHub which then is logged to AppInsights with an Azure Functions. All APIs and Functions that handle Queue etc. messsages also log to AppInsights. In total: all logic components that can log to AppInsights take the CorrelationId and put it into the CustomDimensions. This way we keep track of all steps a request takes.Kai Walter
@KaiWalter Sounds good ... shouldn't you make it an answer, rather than a comment?SteveC

2 Answers

5
votes

What we do:

  1. in API Management inbound policy we create a GUID (CorrelationId)
  2. which we then pass on either in HTTP headers to API backends or in Message Properties through Service Bus Queues/Topics
  3. API Management logging (including the CorrelationId) is pushed to EventHub which then is logged to AppInsights with an Azure Functions
  4. all APIs and Functions that handle Queue etc. messsages also log to AppInsights

In summary: all logic components that can log to AppInsights take the CorrelationId and put it into the CustomDimensions. This way we keep track of all steps a request takes.

1
votes

You can use Client Tracking Id for this.

The client tracking ID is a value that will correlate events across a logic app run, including any nested workflows called as a part of a logic app. This ID will be auto-generated if not provided, but you can manually specify the client tracking ID from a trigger by passing a x-ms-client-tracking-id header with the ID value in the trigger request (request trigger, HTTP trigger, or webhook trigger).