How to filter out specific dependencies from application insights?

Laura Broderick 0 Reputation points Microsoft Employee
2024-02-05T22:26:28.3933333+00:00

In Application Insights I am trying to reduce unnecessary logging by following the steps here - https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-standalone-sampling-overrides to sample specific logs. I added the following to my applicationinsights.json file -

"sampling": {
      "overrides": [
        {
          "telemetryKind": "dependency",
          "attributes": [
            {
              "key": "name",
              "value": "ExternalConnectionPool.releaseConnection",
              "matchType": "strict"
            }
          ],
          "percentage": 0
        }
      ]
    },


However, in the dependencies table I still see logs with the name "ExternalConnectionPool.releaseConnection". I am guessing the attribute is wrong, so I tried adding this to my applicationinsights.json file to see what attributes are available -

"selfDiagnostics": {  
  "destination": "file+console",  
  "level": "DEBUG",  
  "file": {    
    "path": "applicationinsights.log",    
    "maxSizeMb": 5,
    "maxHistory": 1
  }
}

I see debug messages in my console and see logs being sent to application insights, but don't see any starting with "exporting span" as mentioned in documentation. What attributes can I use to stop sending this log message?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,645 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
    2024-02-08T03:38:53.6533333+00:00

    Hey @Laura Broderick

    For the span attribute, did you try using the environment variables APPLICATIONINSIGHTS_SELF_DIAGNOSTICS_LEVEL and APPLICATIONINSIGHTS_SELF_DIAGNOSTICS_FILE_PATH? You can also try identifying the noisy telemetry with the following query:

    search *
    | where TimeGenerated > ago(30d)
    | where IKey == 'REPLACE WITH DESIRED IKEY'
    | summarize count()  by $table
    | sort by count_ desc
    

    Using these results to query which logs are making the table(s) noisy. For example, if AppDependenices is a noisy table, you can query like

    AppDependencies
    | where TimeGenerated > ago(30d)
    | where IKey == 'REPLACE WITH DESIRED IKEY'
    | where Name == 'SQL: DB Query'
    | summarize count() by Name, OperationName, Data
    | sort by count_ desc
    

    This output should provide you the attribute values you're looking for. May need to use a regex to cover different patterns.


    EDIT 9 Feb 2024 I've updated the AppDendencies query to include Data which you can use to filter by attribute. Compare the value of Data to the output of your Span attributes and use that key/value pair as the key and value in your sampling override.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.