
Record custom metrics in AWS Lambda with the OpenTelemetry metrics API and send them to the Amazon CloudWatch OTLP endpoint via the ADOT layer.
cloudwatch:PutMetricData beyond basic logging permissions.PutMetricData or embedded metric format logs, OTLP has no per-series charge and allows up to 150 labels per data point instead of 30 dimensions, so it suits high-cardinality metrics such as per-tenant or business metrics. Keep label values bounded, and don't use request IDs or UUIDs as labels.batch stops it from starting. The function flushes the meter provider before it returns, because Lambda freezes the environment straight after. The metrics are queried with PromQL in Query Studio, not in the classic CloudWatch metrics console.git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-cloudwatch-otlp-metrics/python/samsam deploy --guidedsam delete --stack-name STACK_NAME --region $REGION and enter y at each confirmation prompt, confirm it with aws cloudformation list-stacks, then delete the local out.json response file. The shared AWS SAM CLI managed artifacts bucket and the optional account and Region wide enrichment settings are not created by the stack and are left in place. Metric data points that were already ingested cannot be deleted and age out under the included retention.