Improve cluster detection for entity and app signals processors #1525
+79
−30
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
When running on a Kubernetes cluster, the only way the CloudWatch Agent can detect the cluster name is:
ec2:DescribeTags
call.Ideally, the agent should minimize external API calls, so we should implement a global way to retrieve the cluster name in case it isn't provided in the configuration. We can fetch the
K8S_CLUSTER_NAME
environmental variable, which is populated by the Amazon CloudWatch Observability EKS add-on / Helm chart.Description of changes
Important
Co-PR: aws-observability/helm-charts#167
GetHostedIn
function, which looks for cluster name under app signals.GetClusterName
function, which looks for cluster name under kubernetes, inK8S_CLUSTER_NAME
environmental variable, or by aec2:DescribeTags
call.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
In an EKS cluster, I added a print statement to verify the environmental variable's value is accessed during translation:
Requirements
Before commit the code, please do the following steps.
make fmt
andmake fmt-sh
make lint