aws-samples / aws-samples/serverless-patterns

New pattern submission - lambda-cloudwatch-otlp-metrics-sam

Open
#3,299 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.8k
Forks
1.1k
Avg merge
7d 14h
Merged PRs (30d)
6

Description

**Pattern name:** lambda-cloudwatch-otlp-metrics-sam

**Pull request:** https://github.com/aws-samples/serverless-patterns/pull/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.

Contributor guide

Open the contributing guide

Research direction

Review the linked pull request #3298 and its lambda-cloudwatch-otlp-metrics-sam pattern first. Check the Python 3.13 Lambda, AWS SAM configuration, permissions, and AWS Distro for OpenTelemetry Lambda layer, then verify the documented end-to-end deployment and CloudWatch PromQL results. Done means the pattern is complete, deployable, and its exported metrics arrive with the expected values and labels.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud, observability-sre
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.