A developer needs to monitor an AWS Lambda function that occasionally times out during execution. The developer wants to count the occurrences of these timeouts and receive an alert when they happen. Which of the following steps should the developer perform to meet these requirements? (Select TWO.)
- Create a CloudWatch Logs metric filter on the function's log group with the filter pattern "Task timed out" to increment a custom metric.Answer
- Create a CloudWatch Alarm based on the custom metric generated by the metric filter to send an alert when the threshold is exceeded.Answer
- CCreate a CloudWatch Logs subscription filter on the log group to send log data directly to an Amazon SNS topic.
- DIncrease the function's execution timeout limit to automatically publish a custom LambdaTimeout metric to CloudWatch.
- EConfigure a CloudWatch metric filter on the default AWS Lambda metrics stream with the pattern "timeout".
Answer
Create a CloudWatch Logs metric filter with the pattern "Task timed out" on the function's log group and configure a CloudWatch Alarm based on the resulting metric.
To monitor and alarm on specific log statements, a developer must create a metric filter on the CloudWatch Logs log group associated with the log source (such as the Lambda log group /aws/lambda/<function-name>). When Lambda times out, it logs a standard message containing the phrase "Task timed out". Creating a metric filter with the pattern "Task timed out" will match this phrase and increment a custom metric. The developer can then associate a CloudWatch Alarm with this custom metric to send alerts when the failure count exceeds thresholds.
Step-by-Step Solution
Key Concept
Using CloudWatch Logs metric filters to extract metrics from plain text log streams and alarming on them.