CloudWatch Alarms

CloudWatch Alarms

In this section, we will set up an Alarm for the Error Log Metric that we created in the previous section.

  1. Return to the main screen of CloudWatch.

    • Select Alarms from the left menu.
    • Choose All alarms.
    • Click Create alarm.

5.1

  1. Select Select metric.

5.2

The metrics window appears, under Custom namespaces, select ec2-logs.

5.3

Next, select Metrics with no dimensions, choose /var/log/messages, and click Select metric.

5.4

  1. In the Specify metric and conditions section, set Period to 1 minute.

5.5

  1. In the Conditions section:

    • Threshold type: Static.
    • Condition: Greater than 10.

5.6

You will see a dashed line indicating that this is the threshold where the Alarm will be triggered => when there are too many errors, something unusual has happened in the application and needs to be checked immediately.

5.7

Then click Next to continue.

  1. Now, configure the notification as follows:

    • Alarm state trigger: In alarm.
    • Choose Create new topic.
    • Topic name: Error_logs_reach_10.
    • Email to notify: enter your email, here I will enter mine.
    • Click Create topic.

5.8

5.9

Click Next.

5.10

  1. In the final step, enter the alarm name as PythonApplicationErrorAlarm and click Next.

5.11

  1. Review the results and click Create alarm.

5.12

5.13

Result:

5.14

  1. Log in to Gmail or any email service you use. You will receive an email from AWS Notification.

5.15

Click Confirm subscription.

5.16

5.17

Okay, now we have completed the alarm setup.