0

We are using Azure APIM for using the APIs , From backend we send geneic response such as

{ 
   "result" :[
    .....
     ],
    "status": {
        "code": 500,
        "message": "Internal Error due to xyz"
    }
}

And i want a record to see what are the different types of 500 errors we are getting at one place and its frequency.

Where in azure i can log these things or can show these things at one place.

gouravm
  • 301
  • 1
  • 12
  • You can use App Insights for logging: https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-app-insights – Markus Meyer Jun 30 '23 at 04:03

1 Answers1

0

To retrieve logs for failed Azure API Management (APIM) requests, you can use Azure Monitor Logs. Azure Monitor provides a centralized logging and monitoring solution for Azure resources, including APIM. Here's an overview of the steps involved:

  1. Enable diagnostics logs for Azure API Management which will send the logs to Azure Monitor.

  2. Create Log Analytics workspace which will be used to store the log data collected from APIM.

  3. Configure diagnostic settings

    1. Go to your APIM instance in the Azure portal, navigate to the "Diagnostics settings" section, and create a new diagnostic setting.
    2. Choose the appropriate log categories, such as "GatewayLogs," "BackendLogs," or "EventHub."
    3. Select the Log Analytics workspace you created in the previous step as the destination for the logs.

enter image description here

enter image description here 4. Query logs: Once the logs are ingested into the Log Analytics workspace, you can query them using Azure Monitor Logs. Here's an example query to retrieve failed APIM requests:

    AzureDiagnostics
             | where ResourceType == "APIManagementGateway"
             | where OperationName == "GatewayLogs"
             | where ResponseStatus_s == "Failed"
  1. View logs and export results: Execute the query, and the logs containing failed APIM requests will be displayed in the Azure Monitor Logs query editor.
SaiSakethGuduru
  • 2,218
  • 1
  • 5
  • 15
  • Did this and was able to see 500 from different apis but i wanted to look to grab inside messgaes why they came from. – gouravm Jun 30 '23 at 10:17
  • This answer looks like it was generated by an AI (like ChatGPT), not by an actual human being. You should be aware that [posting AI-generated output is officially **BANNED** on Stack Overflow](https://meta.stackoverflow.com/q/421831). If this answer was indeed generated by an AI, then I strongly suggest you delete it before you get yourself into even bigger trouble: **WE TAKE PLAGIARISM SERIOUSLY HERE.** – tchrist Jul 03 '23 at 03:10