CloudWatch alarm: S3 Object Lambda 5xxErrors
Alarm on AWS/S3ObjectLambda 5xxErrors for the AccessPointName and DataSourceARN, Average over 60 seconds, above 0.05 for 15 consecutive minutes. More than 5% of requests failing with server errors through an Object Lambda Access Point usually means the transformation function is crashing, timing out or responding incorrectly.
Where 5xx errors come from
An Object Lambda request succeeds only if your function runs and calls WriteGetObjectResponse in time. Server-side failures in that chain surface as 5xx to the client:
| Source | What you will see |
|---|---|
| Function throws or crashes | Lambda Errors rises at the same time; stack traces in the function's logs |
| Function times out or never responds | Duration near the timeout; no WriteGetObjectResponse call |
| Function is throttled | Lambda Throttles on the function |
| Function returns a 5xx itself | Function logs show the status it chose |
| S3 service issue | Errors across access points; AWS Health event |
Large objects make timeouts more likely: the function has to fetch, transform and stream the result within its time limit.
Recommended alarm settings
| Setting | Recommended value |
|---|---|
| Namespace | AWS/S3ObjectLambda |
| Metric | 5xxErrors |
| Dimensions | AccessPointName, DataSourceARN |
| Statistic | Average |
| Threshold | 0.05 |
| Period | 60 seconds |
| Datapoints to alarm | 15 |
| Evaluation periods | 15 |
| Comparison operator | GreaterThanThreshold |
Tuning
Most Object Lambda access points should run near zero 5xx, so 5% for fifteen minutes is a conservative trigger. For user-facing paths consider 0.01. If you also alarm on the function's Errors and Throttles, keep this one as the customer-impact view: it measures what callers actually received.
It also helps to know your object size profile. If most objects are small but a few are hundreds of megabytes, the large ones are where timeouts and memory exhaustion happen, and they can push the error rate over 5% on their own when traffic is light. In that case, either route large objects through a different path, or raise the function's memory and timeout to cover the worst case, and keep an eye on Duration as a leading indicator. A 5xx rate that rises slowly during the day usually tracks load (throttling or a slow dependency); one that jumps in a single minute usually tracks a deploy.
Create the alarm
aws cloudwatch put-metric-alarm \
--alarm-name s3ol-redacted-docs-5xx-rate \
--alarm-description "More than 5% of requests to redacted-docs returning 5xx" \
--namespace AWS/S3ObjectLambda \
--metric-name 5xxErrors \
--dimensions Name=AccessPointName,Value=redacted-docs Name=DataSourceARN,Value=arn:aws:s3:eu-west-2:123456789012:accesspoint/docs-ap \
--statistic Average \
--period 60 \
--evaluation-periods 15 \
--datapoints-to-alarm 15 \
--threshold 0.05 \
--comparison-operator GreaterThanThreshold \
--treat-missing-data notBreaching \
--alarm-actions arn:aws:sns:eu-west-2:123456789012:oncall-alertsWhen it fires
- Check the function first: Errors, Throttles and Duration for the transformation function, and its recent log output.
- Roll back if a new function version coincides with the spike; see roll back a Lambda version.
- Timeouts: stream the transformation rather than buffering whole objects, raise memory (more CPU) or the timeout.
- Throttles: add reserved concurrency for the function or request a higher account quota.
- If the function is healthy, check AWS Health for S3 in the Region.
Questions
How do I create a CloudWatch alarm for an S3 bucket?
Enable request metrics on the bucket with a metrics configuration (a filter), then alarm on metrics such as 4xxErrors or 5xxErrors using the BucketName and FilterId dimensions. Daily storage metrics like BucketSizeBytes need no setup but are only updated once a day.
Does a Lambda timeout show as an S3 Object Lambda 5xx?
Yes. If the function never completes its WriteGetObjectResponse call, the client receives a server error, which this metric counts.
When a transformation function breaks, every download through the access point fails at once. CloudConsole, a phone app for AWS, is built to show the alarm and the function's recent errors together on your phone.
Did it start after a deploy? What changed? on the app’s alarm screen lists the deploys and configuration changes from the hour before the alarm fired.
About the app → · Download on the App Store