Pattern name: lambda-cloudwatch-otlp-metrics-sam
Pull request: #3298
Description:
Send custom Lambda metrics to Amazon CloudWatch over OTLP. The function records a counter and a histogram using only the OpenTelemetry metrics API, and the AWS Distro for OpenTelemetry Lambda layer runs a collector that signs each request with SigV4 and forwards it to the CloudWatch OTLP endpoint. The function makes no PutMetricData calls and writes no embedded metric format logs, and the only permission it needs is cloudwatch:PutMetricData.
Compared with embedded metric format there is no per series charge, and the endpoint accepts up to 150 labels per metric against the 30 dimensions allowed by PutMetricData, so high cardinality metrics are much cheaper and richer.
Services used: AWS Lambda, Amazon CloudWatch (OTLP metrics endpoint), AWS Distro for OpenTelemetry Lambda layer.
Language: Python 3.13
Framework: AWS SAM
Level: 300
Tested end to end in a live account: deployed, invoked, confirmed the collector exported without errors, and queried the CloudWatch PromQL endpoint to verify the data points arrived with the expected value and labels. The stack was then deleted.
Pattern name: lambda-cloudwatch-otlp-metrics-sam
Pull request: #3298
Description:
Send custom Lambda metrics to Amazon CloudWatch over OTLP. The function records a counter and a histogram using only the OpenTelemetry metrics API, and the AWS Distro for OpenTelemetry Lambda layer runs a collector that signs each request with SigV4 and forwards it to the CloudWatch OTLP endpoint. The function makes no PutMetricData calls and writes no embedded metric format logs, and the only permission it needs is cloudwatch:PutMetricData.
Compared with embedded metric format there is no per series charge, and the endpoint accepts up to 150 labels per metric against the 30 dimensions allowed by PutMetricData, so high cardinality metrics are much cheaper and richer.
Services used: AWS Lambda, Amazon CloudWatch (OTLP metrics endpoint), AWS Distro for OpenTelemetry Lambda layer.
Language: Python 3.13
Framework: AWS SAM
Level: 300
Tested end to end in a live account: deployed, invoked, confirmed the collector exported without errors, and queried the CloudWatch PromQL endpoint to verify the data points arrived with the expected value and labels. The stack was then deleted.