-
Notifications
You must be signed in to change notification settings - Fork 214
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
Implement Kubernetes Metadata Extension #1583
base: feature-custom-metrics-entity
Are you sure you want to change the base?
Conversation
a5ea567
to
512f3f3
Compare
512f3f3
to
20824f2
Compare
Co-authored-by: Ping Xiang <>
e9a7edf
to
801cd88
Compare
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.
return k8sclient.PodMetadata{} | ||
} | ||
metadata := pm.(k8sclient.PodMetadata) | ||
e.logger.Debug("GetPodMetadata: found metadata", |
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.
Agent should not be logging entity key attributes and attributes.
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 already log them as part of the EMF exporter so I assumed that was okay, but that's a good point. We should not log them in both cases.
} | ||
|
||
const testIP = "1.2.3.4" | ||
expected := k8sclient.PodMetadata{ |
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.
Is there a possibility that podMetadata has only workload/any one field and remaining as empty?
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.
As in, namespace and node name is empty, but workload is present? It's possible, but I don't believe it would happen. I can add testing coverage for it though.
service: "nginx-service", | ||
expected: "nginx-123456", | ||
}, | ||
{ |
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.
Write a test to fallback to fullpodname
@@ -176,7 +193,7 @@ func (p *awsEntityProcessor) processMetrics(_ context.Context, md pmetric.Metric | |||
} | |||
} | |||
if p.config.KubernetesMode != "" { | |||
p.k8sscraper.Scrape(rm.At(i).Resource()) | |||
p.k8sscraper.Scrape(rm.At(i).Resource(), getPodMeta()) |
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.
Add additional unit tests for validating the addition of entity fields by reading from podMeta
This reverts commit ca56a5b.
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