ApplicationInsights-Java icon indicating copy to clipboard operation
ApplicationInsights-Java copied to clipboard

How do you stop dependency sql from being logged?

Open s21-himesh opened this issue 7 months ago • 2 comments

I've tried the following options to try dependency sql logs to stop being logged in the applicationinsight.json file. However, they keep being logged:-

{ "preview": { "generalExportQueueCapacity": 4096 }, "connectionString": "InstrumentationKey=xxxxxxxxxxxxxxxx;IngestionEndpoint=https://uksouth-1.in.applicationinsights.azure.com/;LiveEndpoint=https://uksouth.livediagnostics.monitor.azure.com/;ApplicationId=xxxxxxxxxxxxxxxxxxxxxxxx" }, "role": { "name": "xxxxxxxxxxxxxx" }, "sampling": { "percentage": 20, "requests": { "percentage": 20 }, "dependencies": { "percentage": 1 } }, "instrumentation": { "logging": { "level": "warn" }, "micrometer": { "enabled": true } }, "jdbc": { "enabled": false }, "dependencies": { "excludedTypes": ["SQL"] } }

Example Log:-

Event time | 12/06/2025, 11:33:32.048 (Local time) |   -- | -- | -- Type | SQL |   Call status | true |   Duration | 306 μs |   Name | SQL: INSERT _meta_menu.meta_connect__32 |   Operation Id | db194a11e7cf42651dac8c69a2352ab2 |   Parent Id | db194a11e7cf42651dac8c69a2352ab2 |   Id | 278785e33b46242b |   Performance | Base name | h2 \| _meta_menu -- | --

s21-himesh avatar Jun 12 '25 10:06 s21-himesh

@s21-himesh - You can add in your JSON sampling overrides to shut off a particular dependency type. Go through this link for examples - https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-standalone-sampling-overrides

zoomingrocket avatar Jun 24 '25 21:06 zoomingrocket

Hi @zoomingrocket,

Thanks for your response. I've tried more things with no joy:-

{ "connectionString": "InstrumentationKey=**************************;IngestionEndpoint=https://uksouth-1.in.applicationinsights.azure.com/;LiveEndpoint=https://uksouth.livediagnostics.monitor.azure.com/;ApplicationId=***********************", "role": { "name": "****************" }, "preview": { "generalExportQueueCapacity": 4096 }, "sampling": { "percentage": 20, "requests": { "percentage": 20 }, "overrides": [ { "telemetryType": "dependency", "attributes": [ { "key": "type", "value": "SQL", "matchType": "strict" } ], "percentage": 0 } ] }, "instrumentation": { "logging": { "level": "warn" }, "micrometer": { "enabled": true }, "dependency": { "enabled": false } }, "jdbc": { "enabled": false }, "dependencies": { "excludedTypes": ["SQL"] } }

s21-himesh avatar Jun 25 '25 12:06 s21-himesh

I had a similar issue and for me I followed this:

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

I enabled APM Agent logging into a file inside of my container, I had a few issues as my container are running as non-root but managed to sort it eventually. Once I got the file, I changed the logging to DEBUG as per documentation and managed to get all the SPANS captured by the APM Agent logged into a file.

So, what was left to do was look at the spans I was interested and look at the attributes and use them to build the sampling file. All spans will start with this: Image

I ended up with a file similar to:

Image

Hope it helps ;)

fcl-9 avatar Jul 11 '25 15:07 fcl-9

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.