Soru

Zorluk: KolayMonitoring and Analyzing Logs with Amazon CloudWatch

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.)

  1. Create a CloudWatch Logs metric filter on the function's log group with the filter pattern "Task timed out" to increment a custom metric.Cevap
  2. Create a CloudWatch Alarm based on the custom metric generated by the metric filter to send an alert when the threshold is exceeded.Cevap
  3. C
    Create a CloudWatch Logs subscription filter on the log group to send log data directly to an Amazon SNS topic.
  4. D
    Increase the function's execution timeout limit to automatically publish a custom LambdaTimeout metric to CloudWatch.
  5. E
    Configure a CloudWatch metric filter on the default AWS Lambda metrics stream with the pattern "timeout".

Cevap

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.

Adım Adım Çözüm

1
Identify the log group associated with the Lambda function and the exact log phrase indicating a timeout.
The log group is /aws/lambda/<function-name> and the timeout log phrase is "Task timed out".
This identifies the target log source and the search criteria needed for tracking timeouts.
2
Configure a metric filter on the identified log group with the pattern "Task timed out".
A custom metric is generated and incremented whenever a log matches the pattern.
This extracts the text pattern from the raw log stream into a numeric time-series metric.
3
Create a CloudWatch Alarm that monitors the custom metric.
An alarm is created to trigger alerts (e.g., via SNS) when the count exceeds the defined threshold.
This establishes the alerting mechanism to notify the developer when timeouts occur.

Anahtar Kavram

Using CloudWatch Logs metric filters to extract metrics from plain text log streams and alarming on them.
Bu soruyu puanla