-
Notifications
You must be signed in to change notification settings - Fork 230
Implement Kubernetes Metadata Extension #1583
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
Merged
nathalapooja
merged 18 commits into
feature-custom-metrics-entity
from
k8s-metadata-extension
Mar 17, 2025
Merged
Implement Kubernetes Metadata Extension #1583
nathalapooja
merged 18 commits into
feature-custom-metrics-entity
from
k8s-metadata-extension
Mar 17, 2025
Conversation
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
a5ea567
to
512f3f3
Compare
512f3f3
to
20824f2
Compare
Co-authored-by: Ping Xiang <>
e9a7edf
to
801cd88
Compare
lisguo
reviewed
Mar 11, 2025
Co-authored-by: Lisa Guo <lguo25@gmail.com>
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.
OverAll looks good. Added few comments and check the below as well
- It says it used 'k8s-attr` branch in overview instead of PR branch
- Lets do stress test to make sure we are not throttling the k8s api.
lisguo
approved these changes
Mar 17, 2025
nathalapooja
approved these changes
Mar 17, 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
To support the Explore related feature in CloudWatch, the CloudWatch Agent sends an "Entity", which includes relevant metadata to correlate metrics or logs between resources (e.g., an EKS cluster) and services (e.g., a Java application). When the CloudWatch Agent runs in a Kubernetes cluster, we need to collect the namespace, workload name, and node name to populate the "Entity".
However, we currently only get Kubernetes metadata when Application Signals is enabled. For OTLP custom metrics, if Application Signals isn't configured, then we don't have a way to fetch Kubernetes metadata. To achieve this, we must migrate the logic the Application Signals Processor uses to get Kuberbetes metadata to a global extension, which can be used by other pipelines.
Description of changes
extension/k8smetadata
)README.md
to document how the extension works.config.go
andfactory.go
barebone files in order to use in translation for the OTEL configuration.extension.go
, which sets up an EndpointSlice watcher andPod IP → {Workload, Namespace, Node} mappings
. TheGetPodMetadata()
method returns the respective mapping for a given Pod IP.endpointslicewatcher.go
andkubernetes_utils.go
to theinternal/k8sCommon/k8sclient
directory and adjustPod IP → Workload@Namespace
logic toPod IP → {Workload, Namespace, Node}
. Unused functionality was removed.awsentity
)getPodMeta()
function inprocessor.go
, which invokes the Kubernetes Metadata Extension to receive {Workload, Namespace, Node} from a given Pod IP.internal/k8sattributescraper/k8sattributescraper.go
to use the Kubernetes Metadata Extension to populate workload, namespace, and node instead of resource attributes if those values are present.translator/translate/otel
)extension/k8smetadata/translator.go
to reference the extension in translation.translators.Extensions.Set(k8smetadata.NewTranslator())
topipeline/host/translator.go
for OTLP pipeline in Kubernetes contexts.service/defaultcomponents/components.go
to include"k8smetadata"
.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
OTEL_EXPORTER_OTLP_ENDPOINT
tohttp://cloudwatch-agent.amazon-cloudwatch:4317
.make docker-build-amd64
and changed the image in the AmazonCloudWatchAgent custom resource fromk8s-metadata-extension
branch.Agent Config:
Kubernetes Metadata Extension
Logs:
Debug Exporter Output:
Entity Fields:
Requirements
Before commit the code, please do the following steps.
make fmt
andmake fmt-sh
make lint