Add lambda-cloudwatch-otlp-metrics-sam pattern - #3298
Open
manishh-13 wants to merge 1 commit into
Open
Conversation
Record custom application metrics in AWS Lambda with the OpenTelemetry metrics API and send them to Amazon CloudWatch over OTLP. The ADOT Lambda layer runs a collector that signs each request with SigV4, so the function makes no PutMetricData calls and writes no embedded metric format logs.
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
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.
Issue #, if available:
Submission issue: #3299
Description:
Adds a new pattern: lambda-cloudwatch-otlp-metrics-sam.
Records custom application metrics in an AWS Lambda function using the OpenTelemetry metrics API and sends them to Amazon CloudWatch over OTLP. The AWS Distro for OpenTelemetry Lambda layer runs a collector next to the function that signs each request with SigV4 and forwards it to the CloudWatch OTLP endpoint. The function makes no PutMetricData calls, writes no embedded metric format logs, and performs no request signing of its own. The only IAM permission it needs is
cloudwatch:PutMetricData.Why OTLP rather than PutMetricData or embedded metric format:
The pattern also documents the details that are easy to get wrong, all of which I hit while testing:
batchstops the collector from starting and nothing is exported.metrics_endpoint, notendpoint. The exporter appends the signal path toendpoint, so settingendpointto the full metrics URL produces/v1/metrics/v1/metricsand every export fails with HTTP 404.Language: Python 3.13. Framework: AWS SAM. Level: 300.
Tested end to end in a live account: deployed with
sam buildandsam deploy, invoked the function, confirmed the collector exported with no errors, and queried the CloudWatch PromQL endpoint to verify the data points arrived with the expected value and labels. The stack was then deleted.By submitting this pull request, I confirm that my contribution is made under the terms of the MIT-0 license.