Search code examples
javaazure-application-insightsazure-application-insights-profiler

How to configure sampling for java application dependency calls using the dependency properties in applicationinsights.json file


I have deployed a java application in AKS with Appinsights. I am using applicationinsights.json to configure the appinsights in the service deployed. And I want to sample the dependency calls which has Base name property with certain value as per the below screenshot.

enter image description here

I have used below applicationinsights.json configuration file. But it did not work for me. I tried with strict and Regex both but that also did not work. Can someone please tell me how I can sample the above dependency call with Base name property or any other properties if possible.

{
    "role": {
        "name": "ROLE_NAME"
    },
    "heartbeat": {
        "intervalSeconds": 60
    },
    "preview": {
        "processors": [
            {
                "type": "attribute",
                "actions": [
                    {
                        "key": "http.url",
                        "pattern": "(?<redacted>\\?.*)",
                        "replace": "\\?***",
                        "action": "mask"
                    }
                ],
                "id": "/log/maskQueryString"
            }
        ],
        "sampling": {
            "overrides": [
                {
                    "telemetryType": "dependency",
                    "attributes": [
                        {
                            "key": "Base name",
                            "value": "<value of the property>",
                            "matchType": "strict"
                        }
                    ],
                    "percentage": 0
                }
            ]
        }
    }
}

Solution

  • I was able to sample my DB dependency calls by adding the below sampling configs in my applicationinsights.json config file

    {
        "preview": {
            "sampling": {
                "overrides": [
                    {
                        "telemetryType": "dependency",
                        "attributes": [
                            {
                                "key": "db.system",
                                "value": ".*sql.*",
                                "matchType": "regexp"
                            }
                        ],
                        "percentage": 0
                    }
                ]
            }
        }
    }