Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting request payload for put and post methods through ApplicationInsights.json config file for java based applications #2936

Closed
yellamandaiah-gogula opened this issue Feb 27, 2023 · 11 comments

Comments

@yellamandaiah-gogula
Copy link

Hi Team,
One our java based application in running azure and we recently implemented Application insights.
1.Is there any way i can configure in applicationinsights.json for HTTP post and put method`s payload (to check request payload in logs) .
2. can we configure to collect only failure dependency logs not all dependency (since in my application request logs are 5 gb and dependency logs or 20 gb.

Thanks

@Trass3r
Copy link

Trass3r commented Sep 1, 2023

@yellamandaiah-gogula
Copy link
Author

Thank @Trass3r , Could you provide some samples

  1. request url : https://abc123.com have header -> header1
  2. request url : https://xyz123.com have headers-> header1, header2
    and also is there any way to support PUT,Post request Body details ? if yes please provide some samples.

@yellamandaiah-gogula
Copy link
Author

yellamandaiah-gogula commented Sep 1, 2023

my applicationinsights.json look like this which his working fine production

{
"sampling": {
"percentage": 33.3
},
"instrumentation": {
"logging": {
"level": "WARN"
},
"micrometer": {
"enabled": false
},
"springScheduling": {
"enabled": false
},
"kafka": {
"enabled": false
}
},
"preview": {
"sampling": {
"overrides": [
{
"telemetryType": "request",
"attributes": [
{
"key": "http.url",
"value": "https?://[^/]+/health",
"matchType": "regexp"
}
],
"percentage": 5
},
{
"telemetryType": "dependency",
"attributes": [
{
"key": "http.url",
"value": "https://xyz.abc.jp",
"matchType": "strict"
}
],
"percentage": 0
},
{
"telemetryType": "dependency",
"attributes": [
{
"key": "db.system",
"value": "redis",
"matchType": "strict"
}
],
"percentage": 10
},
{
"telemetryType": "dependency",
"attributes": [
{
"key": "db.system",
"value": "cassandra",
"matchType": "strict"
}
],
"percentage": 10
}
]
}
}
}

@Trass3r
Copy link

Trass3r commented Sep 1, 2023

Ah sorry, right, that setting is only for headers.
To capture the body custom code seems to be necessary: https://stackoverflow.com/questions/42686363/view-post-request-body-in-application-insights

@Trass3r
Copy link

Trass3r commented Sep 1, 2023

  1. can we configure to collect only failure dependency logs not all dependency (since in my application request logs are 5 gb and dependency logs or 20 gb.

I tried to achieve the same thing for requests but it doesn't seem to be possible with configuration only:

https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-standalone-sampling-overrides#span-attributes-available-for-sampling

Only attributes set at the start of the span are available for sampling, so attributes such as http.status_code which are captured later on can't be used for sampling.

@yellamandaiah-gogula
Copy link
Author

yellamandaiah-gogula commented Sep 1, 2023

@Trass3r Thanks for reply , please provide some sample for headers


{
"preview": {
"captureHttpServerHeaders": {
"requestHeaders": [
"header1",
"header2"
]
}
}
}
above config will show all request which have header1,header2 ?

@MelleD
Copy link

MelleD commented Nov 27, 2023

Is there a way to see the payload for a request in Application Insights? So far there is only the option of turning on http headers, but that is not sufficient. In some cases the request body (json) would be helpful for error analysis.

@heyams
Copy link
Contributor

heyams commented Nov 28, 2023

Is there a way to see the payload for a request in Application Insights? So far there is only the option of turning on http headers, but that is not sufficient. In some cases the request body (json) would be helpful for error analysis.

You can set the self-diagnostics log to debug level, payload is logged in DEBUG level. You can search for {"ver":1,"name":"Request"

@MelleD
Copy link

MelleD commented Nov 28, 2023

@heyams thanks for the quick reply

Can I only see the request body in the LOG file or directly in the Azure portal?

Regulating this via the log level is still suboptimal because then I get much more than I need. Changing at runtime is also difficult with AKS because then the pod has to restart, etc.
For this reason, a separate setting like the http header would be better?
Or what do you think?

I also thought self diagnostic was for Application Insights itself and not for collecting your own metrics from the application.

@heyams
Copy link
Contributor

heyams commented Nov 29, 2023

@MelleD I think I understand your ask better now.
It's similar to this ask. We don't support it, and it seems that it might require lots of work for supporting this feature for all instrumentations according to laurit's comment.

Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants