Tracing API errors using request ID
Problem: Need to identify the root cause of API errors or failed image processing requests.
Solution:
Each API response includes an x-amz-request-id header that can be used to trace the request in CloudWatch logs:
-
Capture the
x-amz-request-idfrom the API response headers -
Navigate to the CloudWatch console
-
Go to Log groups
-
Find the log group for the image processing service:
-
Lambda architecture: Look for the Lambda function log group
-
ECS architecture: Look for the ECS task log group
-
-
Search for the request ID in the logs:
-
Use the CloudWatch Logs Insights query:
fields @timestamp, @message | filter @message like /REQUEST_ID/ -
Replace
REQUEST_IDwith the actual request ID value
-
-
Review the log entries to identify error messages, stack traces, or processing details
The request ID allows you to trace the complete request lifecycle and identify exactly where errors occurred during image processing.