This gist describes how to add Kubernetes customDismensions to the Java agent for Application Insights.
It's supplying the same customDimensions that are provided by the asp.net 6+ instrumentiation, except that not all of those dimensions are available using the Kubernetes Downward API
The supplied app-insights-java.yaml patch file configures customDimensions for the app insights agent using the APPLICATIONINSIGHTS_CONFIGURATION_CONTENT
env var.
This will override your applicationinsights.json configuration file if you were using one.
The example kustomization.yaml applies the patch to all deployments with the instrumentation.opentelemetry.io/inject-java: "true"
annotation.
This is the same annotation that is used by the Open Telemetry Kuberentes Operator. However, that operator selects pods with the annotation.
Only the first container in each pod will have the configuration injected. If you want to inject into other pods, then you will need to replace the 0
in the path:
s with the container index.