Closed kevinles117 closed 3 years ago
Date | Activity | Time Spent |
---|---|---|
3/10/2021 | Setting up issue | 30 mins |
3/11/2021 | Researching | 2 hours |
3/15/2021 | Reading about CloudWatch | 2 hours |
3/16/2021 | Researching about alerts | 1 hour |
3/18/2021 | Testing | 2 hours |
3/19/2021 | Trying to fix keyerror | 2 hours |
3/20/2021 | Rewatched lecture and got error email | 2 hours |
3/20/2021 | Total time spent | 11.5 hours |
To create a metric filter using the CloudWatch console
Open the CloudWatch dashboard
In the navigation pane, choose Log groups.
Scroll down to the lambda function TaskId log group.
Click on metric filters and create a metric filter.
Enter "Error 500" for the filter pattern.
Select the latest log data for testing the filter and click test pattern to make sure you had Error 500's in the log.
Click Next, and enter a name for the filter as well as the Metric namespace and Metric value (I chose 1.0 for the metric value)
Once the metric filter is created, you can click the box in the upper right corner of the metric filter to create an alarm.
Create the alarm
The alarm should have a statistic of sum and time period of 5 minutes. The threshold should be Static and Greater/Equal to 10
Click Next and select the SNS topic you created.
Click Next and add the name of your alarm and click next and confirm the details of the alarm. Create the alarm.
Go back to the lambda function and test it with this event: { "body": "value1", "requestContext": { "http": { "method": "GET" } }, "pathParameters": { "userId": "1", "taskId": "1" } }
This should be the email you get:
Creating alerts for error 500 in AWS using CloudWatch. If there is more than 10 errors 500 within 5 minutes, send an alert.