A developer has a payment-processing application implemented as an AWS Lambda function. During peak hours, this function occasionally fails because it exceeds its configured timeout limit of 15 seconds. The developer needs to configure an Amazon CloudWatch Logs metric filter to count these timeout occurrences and trigger an alarm. The log group contains both application-generated JSON logs and standard Lambda platform logs. The Lambda platform writes the timeout log as a plain text string:
`2026-07-14T17:20:32.123Z 88a381cf-192a-4a6f-9988-51fcf5498bd6 Task timed out after 15.02 seconds`
Which of the following is the correct configuration or filter pattern for this metric filter?
- ASet the filter pattern to { $.message = "Task timed out*" } to extract the message field from the platform log.
- Set the filter pattern to "Task timed out" to match the plain text log line generated by the Lambda service.Answer
- CCatch the timeout exception within the Lambda function code using a try-catch block, write a custom JSON log with a status of "timeout", and set the filter pattern to { $.status = "timeout" }.
- DSet the filter pattern to [timestamp, request_id, message = "*Task timed out*"] to parse the space-delimited log line.
Answer
Set the filter pattern to "Task timed out" to match the plain text log line generated by the Lambda service.
The correct answer is to use a simple text/phrase filter pattern. The Lambda platform writes timeout logs as plain text rather than JSON. An exact phrase match in double quotes like "Task timed out" will correctly scan the log group and match these events.
Step-by-Step Solution
Key Concept
Monitoring and Analyzing Logs with Amazon CloudWatch
Estimated Time:2m 0s