Correlation of logs across multiple Application Insight instances

Kumar 111 Reputation points
2022-06-17T18:23:46.317+00:00

Here is our current setup. Transaction Path - Client - APIM - Azure AppService (ASP.NET Core App)

  • APIM logs to AppInsights-1
  • AppService leverages AppInsights SDK to log to AppInsights-2.

We have noticed that APIM logs in AppInsights-1 have an Operation_Id but the AppService logs in AppInsights-2 is missing the Operation_Id property. Based on that

1) Does the Operation_Id correlate transaction logs that span across multiple Application Insights instances or should all the systems involved in the transaction use the same instance of the Application Insights.

2) We were under the impression Operation_Id is autogenerated, not sure why the Operation_Id is missing in the logs from AppService.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,472 questions
{count} votes

Accepted answer
  1. AnuragSingh-MSFT 21,481 Reputation points
    2022-06-22T10:57:57.403+00:00

    Hi @Kumar ,

    Based on my understanding of the scenario, I did some test and here are my suggestions/findings.

    You are right. These values are auto-generated by the ApplicationInsight SDK ( *ifAppInsights is enabled for the deployed app service, AND they are not supplied in request header *). Refer to this link for detail.

    When the Web Service is called from APIM, these values are passed as header along with the request. Please ensure that the following is enabled:

    1. In APIM --> select your API --> Settings. Please ensure that the following settings are available, as shown in screenshot below:
    213777-image.png

    Note that: Application Insights is transitioning to W3C Trace-Context, and newer version of AppInsights SDK already has this mode enabled. For more information, refer Correlation headers using W3C TraceContext

    2. As a test, you may use the "Test" feature in APIM to send a request to backend API and note the headers being sent. This information will be available in "Trace" under "Test". The header traceparent is sent along with the request which contains the operation_id. In App service this operation_id along with the parent_id is logged. Even if you are using separate ApplicationInsights resource for logging with APIM and App Service, the operation_id remains the same.

    Hope it helps. In case this does not answer your question, can you please share more details with screenshots to help us better understand the scenario.

    ---
    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.