詳細検索

Set up and monitor alerts in AWS Cloudwatch

Avatar
by 橋本 豪
4 min read

Set up and monitor alerts in AWS Cloudwatch
Translated from 日本語 • View original

Hello. This is Hashimoto, a newcomer.

Until now, I have been involved in operation and construction work in on-premises hybrid cloud (private + public) and physical servers.

AWS itself is the first environment to handle, so I would like to write a blog from that perspective.

This time, after installing AWS, you can set up Cloudwatch and Alarm, which can monitor basic resources, and send an email when the threshold is exceeded.

I will describe the very basic settings.

  1. Settings screen

After creating an instance in EC2, select the instance you want to set Alarm to in the Instance field of EC2, and select the Monitoring tab.

スクリーンショット1
  1. Alarm settings

Select Create Alarm in the right part to bring up the Create Alarm screen and enter each item.

  • Send a Notification to → If you have created an SNS topic in a separate field, it will be added to the list (we will not add it this time).
  • Take the action → Alarm. You can choose what to do if it happens (I won't set it this time)
  • Whenever → Select a degree (e.g., Average, Max, Minimum) and an item (e.g., CPU Utilization, Disk Usage) from the list
  • Is → Set a threshold (e.g., more than or equal to ○○ percent or less)
  • For at least → Set the judgment condition (Alarm will be counted if the [Whenever] item is [Is] △ times every ○ minutes).
  • Name of Alarm → Set the Alarm name

スクリーンショット2  

  1. Add settings

After setting each item, select Create Alarm in the lower right corner to create an alarm item and the following screen will appear, click the link.

スクリーンショット3
  1. Confirm the addition of items

To navigate to the CloudWatch Management Console screen, make sure the field is added and click the Modify tab.

スクリーンショット4
  1. Email Sending Settings (1)

The Modify Alarm screen appears, so click +Notification in the Actions item.

スクリーンショット5
  1. Email Sending Settings (2)

The Notification field will appear, so select Newlist and set the email address to which you want to send it.

  • Whenever this alarm → Set when to send emails (this time send when alarm state)
  • Send notification → Set the destination
スクリーンショット6
  1. Email sending settings (3)

Once you have set each item, select Save Changes in the bottom right.

スクリーンショット7
  1. Email Confirmation (1)

The Confirm new email addresses screen will appear, and a confirmation email will be sent to the email address you configured.

スクリーンショット8
  1. Email sending confirmation (2)

You will receive the following email to the email address you set, so click on the link.

スクリーンショット9
  1. Email sending confirmation (3)

Click the link to see the confirmation completion screen.

Note) If you click "click here to unsubscribe" on the displayed screen, your email address will be canceled, so be careful!

スクリーンショット10
  1. Email Sending Confirmation (4)

When you return to the Confirm new email addresses screen, you will have completed the recipient address confirmation settings, so select View Alarm.

スクリーンショット11

Now you can set up Alarm.

This time, we have added an item that says, "Alarm will be counted if the CPU usage continues to exceed 90% for 10 minutes (5 minutes×2)."

For demonstration, we will test it with a load on the configured instance.

This time, I created a simple vbs like the one below and put a load on the CPU.

Paste it into Notepad, save the name as "CPU_busy.vbs", and double-click to run it.

Dim goal Dim before Dim x Dim y Dim i

goal = 1000000

Do While True before = Timer For i = 0 to goal x = 0.000001 y = sin(x) y = y + 0.00001 Next

y = y + 0.01

Loop

Before execution)

スクリーンショット12

After execution)

スクリーンショット13

Now let's look at the Alarm screen in the CloudWatch Management Console.

5 minutes later...

スクリーンショット14

Oh, you've crossed the threshold...?

10 minutes later...

スクリーンショット15

Alarms counted!!

In this state, check whether the email has been received to the destination address you set earlier.

I'm sure you've received an email with the subject line of the Alarm item!

#届いていない場合は, please check the reception environment as well to see if there is a filter applied

Summary)

Configure Cloudwatch for easy resource monitoring.

Also, depending on the items you set, you can set a billing report (Billing) or a value that is temporarily strengthened during high CPU load (burst value: CPUCreditUtil value),

Recently, it has become possible to accumulate OS logs and set them to monitor them in real time.

Please try various things in your environment.

Related Articles