-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[processor/resourcedetection] Detect Azure Kubernetes Service cluster name #29328
[processor/resourcedetection] Detect Azure Kubernetes Service cluster name #29328
Conversation
cc @jinja2 @jsirianni. Would also be great if someone from Microsoft reviews this :) |
enabled: true | ||
k8s.cluster.name: | ||
description: The k8s.cluster.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some details in the description about how the cluster name is detected? The comments in the code are great but a user won't know to refer to them and might assume that this is set to the cluster resource name which might not be the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking a look. I added some clarity to the metadata yaml and readme.
125db6d
to
0065a48
Compare
@mx-psi Let me know if there is anything else I need to do here 👍 |
|
||
The cluster name is accurately detected if underscores are not present in the resource group name or the cluster name. | ||
|
||
If accurate parsing cannot be performed, the infrastructure resource group value is returned. This value can be used to accurately identify the cluster, as Azure will not allow users to create multiple clusters with the same infrastructure resource group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If accurate parsing cannot be performed, the infrastructure resource group value is returned. This value can be used to accurately identify the cluster, as Azure will not allow users to create multiple clusters with the same infrastructure resource group. | |
If accurate parsing cannot be performed, the infrastructure resource group value is returned. This value can be used to uniquely identify the cluster, as Azure will not allow users to create multiple clusters with the same infrastructure resource group name. |
|
||
Azure AKS cluster name is derived from the Azure Instance Metadata Service's (IMDS) infrastructure resource group field. This field contains the resource group and name of the cluster, separated by underscores. e.g: `MC_<resource group>_<cluster name>_<location>`. | ||
|
||
The cluster name is accurately detected if underscores are not present in the resource group name or the cluster name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo we should clarify that we can only get the correct cluster name if custom resource group name is not used. I still think some users might prefer setting the clusterName themself then defaulting to custom resource group name. So explicitly making a note of what is returned in different scenarios would provide better user experience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Apologies for the late response.
I was waiting on jinja2 to finish their review before I took a look :) |
description: The k8s.cluster.name parsed from the Azure Instance Metadata Service's infrastructure resource group field | ||
type: string | ||
enabled: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enabled: true | |
enabled: false |
I think we should keep it disabled by default.
0065a48
to
030bdc1
Compare
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
@jinja2 Mind taking another look? |
// because Azure will not allow the user to create multiple AKS clusters with the same | ||
// infrastructure resource group name. | ||
func parseClusterName(resourceGroup string) string { | ||
// Code inspired by https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/datadogexporter/internal/hostmetadata/internal/azure/provider.go#L36 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice description for parseClusterName
👍
Assuming that this code won't be removed from exporter/datadogexporter
going forward (cc @mx-psi to confirm), I think we should consolidate it in internal/azure
and use it both here and in exporter/datadogexporter
. Moving it from exporter/datadogexporter
to internal/azure
can be done in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not going to remove this from the Datadog exporter in the short term,so I agree we should consolidate this 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, no action needed from me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we'd like to make it a common utility in internal/azure
and update the components, but can be done in a separate PR. @dmitryax if this is not a blocker, I think we are good to merge this needs some testing updates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me as a follow-up PR. @jsirianni will you have a chance to submit that PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmitryax I think I can handle that 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsirianni thanks. Submitted #30834
030bdc1
to
197d3d5
Compare
@@ -34,6 +34,8 @@ func TestDetector_Detect_K8s_Azure(t *testing.T) { | |||
assert.Equal(t, map[string]any{ | |||
"cloud.provider": "azure", | |||
"cloud.platform": "azure_aks", | |||
// Cluster name will not be detected if resource grup is not set | |||
"k8s.cluster.name": "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the attribute is not enabled, it won't be available in the output, so you want to remove this. See failing test here.
I think it would be better to add another test case with the attribute enabled.
18236de
to
3f0c0e3
Compare
… name (open-telemetry#29328) **Description:** Added best effort support for detecting Azure Kubernetes Service cluster name: `k8s.cluster.name`. The cluster name can be extracted from the cluster's "resource group name" which is retrieved using existing functionality. The `parseClusterName` function has comments explaining the limitations. **Link to tracking Issue:** open-telemetry#26794 **Testing:** I added unit tests for each scenario, and have tested against live AKS clusters that fit each scenario. I am happy to spin these up if anyone has any questions. Added `k8s.cluster.name` to the list of AKS resource attributes.
Description:
Added best effort support for detecting Azure Kubernetes Service cluster name:
k8s.cluster.name
.The cluster name can be extracted from the cluster's "resource group name" which is retrieved using existing functionality. The
parseClusterName
function has comments explaining the limitations.Link to tracking Issue:
#26794
Testing:
I added unit tests for each scenario, and have tested against live AKS clusters that fit each scenario. I am happy to spin these up if anyone has any questions.
Documentation:
Added
k8s.cluster.name
to the list of AKS resource attributes.