What solution will accomplish this?
Analyze logs in CloudWatch Logs for the timestamps at which the API calls are made while the Lambda function is running. Compare with the logs from the previous month.
Enable AWS X-Ray for the function. Analyze the service map and traces to help identify the API calls with anomalous response times.
Search CloudTrail logs for the calls from the Lambda function. Compare the observed and expected times of API calls relative to the time when the function starts.
Use CloudWatch to monitor the Duration metric of function invocations for the Lambda function. Compare with the measurements from the previous month.
Explanations:
While analyzing CloudWatch Logs could help identify timestamps and some delays, it won’t provide detailed performance insights or specific bottlenecks in the API calls. It lacks granularity for tracing individual request latencies.
AWS X-Ray is specifically designed to trace Lambda function executions and provide detailed insights into where delays are occurring, including API call latencies and service interactions. It helps identify bottlenecks and anomalous response times.
Searching CloudTrail logs for API calls won’t give insights into how long the Lambda function execution is taking or where delays are occurring during execution. It only logs the API calls without any tracing of the Lambda function’s internal performance.
Monitoring the Duration metric for Lambda function invocations in CloudWatch provides overall execution time but doesn’t give details about which specific parts (like individual API calls) are causing the delays. It lacks the granularity needed to pinpoint specific slowdowns.