Fix AKS cloud.resource_id derivation - #2237
Merged
Merged
Conversation
jefchien
force-pushed
the
otel-config-fixes
branch
from
August 6, 2026 17:15
51be3ad to
5b413de
Compare
Contributor
|
nit: I think there is more work done than the PR title suggests, like the windows stuffs |
Paamicky
reviewed
Aug 6, 2026
| # (MC_<clusterRG>_<cluster>_<region>); extract the cluster's RG into a temp attribute (cluster | ||
| # name injected as a regex literal at translate time), build the ID, then drop the temp. | ||
| - set(resource.attributes["_tmp.azure.resourcegroup.name"], resource.attributes["azure.resourcegroup.name"]) where resource.attributes["cloud.platform"] == "azure_aks" and resource.attributes["azure.resourcegroup.name"] != nil | ||
| - replace_pattern(resource.attributes["_tmp.azure.resourcegroup.name"], "^MC_(.+)_%CLUSTER_NAME%_[^_]+$", "$$$1") where resource.attributes["cloud.platform"] == "azure_aks" |
Contributor
There was a problem hiding this comment.
Should we add a test to document the non-matching behavior?
mitali-salvi
reviewed
Aug 6, 2026
| # (MC_<clusterRG>_<cluster>_<region>); extract the cluster's RG into a temp attribute (cluster | ||
| # name injected as a regex literal at translate time), build the ID, then drop the temp. | ||
| - set(resource.attributes["_tmp.azure.resourcegroup.name"], resource.attributes["azure.resourcegroup.name"]) where resource.attributes["cloud.platform"] == "azure_aks" and resource.attributes["azure.resourcegroup.name"] != nil | ||
| - replace_pattern(resource.attributes["_tmp.azure.resourcegroup.name"], "^MC_(.+)_%CLUSTER_NAME%_[^_]+$", "$$$1") where resource.attributes["cloud.platform"] == "azure_aks" |
Contributor
There was a problem hiding this comment.
Won't the $$$$ add an extra $ after substitution ?
Nvm, I misread the code. the substitution has the correct number of $ chars
mitali-salvi
approved these changes
Aug 6, 2026
Paamicky
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the issue
On AKS,
cloud.resource_idis built fromazure.resourcegroup.name, which is the node's infrastructure resource group (MC_<clusterRG>_<cluster>_<region>). See https://learn.microsoft.com/en-us/azure/aks/faq#why-are-two-resource-groups-created-with-aks-The current ARM ID that gets emitted isn't valid.
Description of changes
cloud.resource_idderivation: extracts the cluster resource group via replace_pattern with the cluster name baked in as a regex literal at translate time.Note
It is possible to have a resource group for the nodes that doesn't match the pattern, but that feature is in preview and at that point, there isn't anything we can do to detect the cluster resource group.
https://learn.microsoft.com/en-us/azure/aks/faq#can-i-provide-my-own-name-for-the-aks-node-resource-group-
cloud.resource_idstatements. A nilcloud.account.idorcloud.regionpreviously rendered in the emitted ID.{instance_id}/{hostname}placeholders inwindows_eventslog group and stream names to match the placeholder resolution ofopentelemetry.collect.files.role_arnfrom the k8s OTel default config. On Kubernetes, the role comes from the pod's environment variables (AKS) or IRSA/Pod Identity (EKS), so a static ${CWAGENT_ROLE_ARN} in the config is unnecessary.License
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Tests
Added unit tests and built and deployed agent to AKS cluster with helm chart. Can see
otlpmetrics and logs being emitted with the correctcloud.resource_id.Requirements
Before commiting your code, please do the following steps.
make fmtandmake fmt-shmake lintIntegration Tests
To run integration tests against this PR, add the
ready for testinglabel.