Custom Log messages from APIM to log analytics

Nagashree Balasundaram 731 Reputation points
2022-06-29T18:07:44.917+00:00

Hi,
The default log analytics configuration through the azure monitor has a fixed schema for the Gateway Logs. Is it possible to write custom log messages to log analytics from Azure APIM?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,769 questions
0 comments No comments
{count} votes

Accepted answer
  1. JananiRamesh-MSFT 21,471 Reputation points
    2022-06-30T17:19:38.62+00:00

    @Nagashree Balasundaram Thanks for reaching out. you can log a custom header value in Log Analytics, using the following built-in ‘Additional Settings – Headers To Log’ functionality under setting tab.

    216615-loganalytics.png

    At the API (All Operations) level, maneuver to the Settings tab and scroll down to the Diagnostics Logs section.

    • On the Azure Monitor tab, configure the required settings. Here is what I configured for my API/APIM service.
    • Under the Additional Settings section, I have configured adding a Frontend Request Header called Test
    • Once configured, ensure that you click on the Save button
    • Now, test with a sample API call to see whether the APIM service is receiving this custom request header.

    For testing purpose, in my environment, I manually added the Request Header Test along with a dummy value for it, invoked the API operation and then checked the Ocp-Apim trace to verify whether the APIM service is receiving it as an incoming header.

    216616-image.png

    Maneuver to the Logs pane and verify APIManagementGatewayLogs, You can observe the custom header Test being logged as shown in my sample below:

    216617-image.png

    To benefit the community find the right answers, please do mark the post which was helpful by clicking on Accept Answer’ & ‘Up-Vote’.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful