6

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??

Pankaj Rawat
  • 4,037
  • 6
  • 41
  • 73
  • You could refer to this [article](https://stackoverflow.com/questions/42686363/view-post-request-body-in-application-insights) to view request body in app insight. – Joey Cai Mar 16 '18 at 07:54
  • I can't do code changes in existing api. any option without code change would help me – Pankaj Rawat Mar 16 '18 at 08:19

4 Answers4

7

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.
Sam Rueby
  • 5,914
  • 6
  • 36
  • 52
3

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.

Joey Cai
  • 18,968
  • 1
  • 20
  • 30
0

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.

JJ.
  • 879
  • 7
  • 10
0

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.

Dan Friedman
  • 4,941
  • 2
  • 41
  • 65