View Request Body in Application Insights
Asked Answered
R

4

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

Rigamarole answered 16/3, 2018 at 5:20 Comment(2)
You could refer to this article to view request body in app insight.Periostitis
I can't do code changes in existing api. any option without code change would help meRigamarole
P
2

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.

Periostitis answered 16/3, 2018 at 8:58 Comment(1)
No longuer true - you can do that now, see answer by Sam RuebyClaypan
G
12

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.
Gunilla answered 21/1, 2021 at 13:58 Comment(1)
This absolutely works. now my problem is how to override the 8192 bytes limit. as my payload is bigger than that. any workaround is appreciated.Selfinduced
P
2

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.

Periostitis answered 16/3, 2018 at 8:58 Comment(1)
No longuer true - you can do that now, see answer by Sam RuebyClaypan
A
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.

Adriatic answered 17/3, 2018 at 16:39 Comment(0)
L
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.

Lemoine answered 25/4, 2020 at 0:46 Comment(1)
I don't think API Management exposes telemetry initializers.Firebrat

© 2022 - 2024 — McMap. All rights reserved.