Intercept and enrich (with custom data) messages logged in AppInsights by Azure APIM.

Kumar 111 Reputation points
2023-03-16T02:21:47.4033333+00:00

In Azure API Management, we have configured Diagnostic Logs (request, response, trace, headers etc.) to be sent to Application Insights.

We would like to add some custom data to every log sent to Application Insights.

Within APIM is there an option to intercept the log message and add custom properties before sending to Application Insights?

If not, what would be an alternative. Am looking for a more generic solution where we don't have to make changes to policies in each API.

Please clarify.

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,661 questions
Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,455 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MuthuKumaranMurugaachari-MSFT 22,441 Reputation points Moderator
    2023-03-20T14:57:06.6466667+00:00

    Kumar Use trace policy to add custom trace to request tracing output and this creates a Trace telemetry in App Insights based on severity level. Check out doc: Trace for more info on this (Policy scopes: global, product, API, operation) and you can apply this policy at the global level so that you don't have add it in each API.

    Currently, it is not possible to add custom data to App Insights without writing policy. If you have any feedback or suggestions, you can directly submit to our product team via https://aka.ms/apimwish and others with similar interests can upvote your idea too. I hope this helps with your question and let me know if any other questions.

    1 person found this answer helpful.
    0 comments No comments

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.