-
Notifications
You must be signed in to change notification settings - Fork 213
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
Improve cluster detection for components during translation #1525
Merged
Conversation
This file contains 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
jefchien
reviewed
Feb 4, 2025
dricross
reviewed
Feb 4, 2025
jefchien
approved these changes
Feb 4, 2025
dricross
approved these changes
Feb 4, 2025
musa-asad
added a commit
that referenced
this pull request
Feb 5, 2025
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
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
Revision 1
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.Revision 2
GetClusterName()
call for containerinsights.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:
![Screenshot 2025-02-03 at 2 14 23 AM](https://private-user-images.githubusercontent.com/165414028/408999034-487b0933-60f5-4277-8700-8e60eb997570.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNDk2MzYsIm5iZiI6MTczOTE0OTMzNiwicGF0aCI6Ii8xNjU0MTQwMjgvNDA4OTk5MDM0LTQ4N2IwOTMzLTYwZjUtNDI3Ny04NzAwLThlNjBlYjk5NzU3MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMFQwMTAyMTZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03NzFlNzFhM2U3ZTZhNjkyNWE2NjFiZmE0NzBiMzZmYmEyNzYwNDQxNjZmYTFmOGVhNDk5MWVkOTllODdiOGI4JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.95FPwJwOM0bdOvUhflJRN-u7zgdWDX6mIw3P0GnCf6o)
Requirements
Before commit the code, please do the following steps.
make fmt
andmake fmt-sh
make lint