Pankaj Rawat
Pankaj Rawat

Reputation: 4573

View Request Body in Application Insights

I'm using Application insights with API-Management to monitor my API's. Application Insights is great tool but I'm not able to see body.

I want to see Post request body parameter. Is there any way to add body data on application insights??

Upvotes: 6

Views: 20737

Answers (4)

Sam Rueby
Sam Rueby

Reputation: 6129

You have to configure API Management to log the request payload to Application Insights. See here: Enable Application Insights logging for your API

  1. Navigate to your Azure API Management service instance in the Azure portal.
  2. Select APIs from the menu on the left.
  3. Click on your API.
  4. Go to the Settings tab from the top bar.
  5. Scroll down to the Diagnostics Logs section.
  6. Check the Enable box.
  7. Select your attached logger in the Destination dropdown.
  8. Input 100 as Sampling (%) and tick the Always log errors checkbox.
  9. Under Additional settings, configure up to 8192 bytes of the payload to be logged.
  10. Click Save.

Upvotes: 12

Dan Friedman
Dan Friedman

Reputation: 5218

The simplest way (ok, the only way I've gotten it to work) would be to log the body yourself using the AppInsights SDK.

According to GitHub, the more recent AppInsights SDKs have initializers running after processing when the stream is closed.

Upvotes: 0

JJ.
JJ.

Reputation: 1149

This is not supported at the moment. APIM is not exposing Telemetry Initializers to the customer instead it will be providing custom options added to the diagnostic entity that will allow you to control sampling, verbosity and ability to log headers. Body is still being debated. Will user want to see response body returned from backend or sent to client? Body can be modified at different stages. Alternatively, you can use Log-To-EventHub and have the ability to place it at specific points of pipeline. Another idea being considered is Log-To-ApplicationInsights.

Note: Adding for more data to Application Insights takes hit on APIM perf.

Upvotes: 0

Joey Cai
Joey Cai

Reputation: 20067

I can't do code changes in existing api. any option without code change would help me

Unfortunately, it is not supported by Application Insights.

I also find the feedback, you could vote it.

It now supports custom Telemetry Initializer as I have shown to you.

Upvotes: 2

Related Questions