How to get detailed api response message in application insight for APIM ?

Deshmukh, Vijit 496 Reputation points
2022-09-27T13:50:54.64+00:00

Hi Team,

We are using APIM at the backend of which we have azure app service and aws lambda services configured.

Some of the APIs are failed with the response code of 500 "internal server error" and 504 "Gateway Timeout Error"

We got the failures count using some metrics and application insights.
But we need more detailed message what exactly caused this error.

Please help us to provide some query or any metrics option from where we can extract error response with detailed message.

Thanks,
vijit

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,800 questions
Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,752 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MuthuKumaranMurugaachari-MSFT 22,141 Reputation points
    2022-09-27T19:13:31.347+00:00

    @Deshmukh, Vijit Thank you for reaching out to Microsoft Q&A. Based on your statement, you have integrated APIM with Application Insights and wanted to log detailed API response message for errors like 500 and 504.

    Have you looked at docs: Enable Application Insights logging for your API? You can use "Always log errors" setting to log all failures to Application Insights, regardless of the Sampling setting.

    245167-image.png

    245168-image.png

    For more detailed error info, you can change Verbosity to Verbose and add Headers to log for both Backend Response and Frontend Response and this would help in reviewing the errors. Refer to docs for more info about this setting.
    245218-image.png

    Second part on querying Application Insights, you can navigate to Application Insights -> Transaction Search and select timeframe and event type -> Exception to search the results. Then double click the search result to view End to End Transaction details. Refer to the docs: Viewing Azure Application Insights Data for each steps.
    245200-image.png

    I hope this answers your question and feel free to add if you have any questions. I would be happy to assist you.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community.