Create a CloudWatch Alarm

We’ll use a CloudWatch Alarm to trigger our Auto Scaling Group. First, we need to determine which metric we want to monitor. Since we want to scale on node CPU usage, we’ll use the node_cpu_utilization metric.

Select Select Metric, Container Insights, followed by ClusterName, InstanceId, NodeName. Locate node_cpu_utilization on any of the EC2 instances and press Select Metric.

Container Insights Results

Now we get to specify metrics and conditions. Under the first section, change the period to 1 minute.

Container Insights Results

Let’s move to Conditions:

  1. Leave Static selected.
  2. Choose Greater
  3. In the threshold value text box, type 50.
  4. Click Next.

Threshold 50

When CPU is greater than 50, the alarm will be triggered. We now need to configure the actions that happen when the alarm gets triggered.

For Alarm state trigger leave it as In alarm. Under that, we want to select Create new Topic. Let’s give the topic a name, I am going to use CPU_Increase. Enter your email address to receive a notification when the alarm is triggered, then click Create topic.

Lastly, leave everything else as it is and press “Next”.

Configure Alarm

We are going to receive an email titled AWS Notification - Subscription Confirmation. Open your inbox, locate it, and click the Confirm subscription link.

AWS Notification - Subscription Confirmation

You will then see a confirmation like this: AWS Notification - confirmed

Lastly, back in the CloudWatch “Configure actions” page, enter a name for the alarm. Let’s keep it simple and name it ScaleUp-Alarm, then press “Next”. Go ahead and review the configuration, and don’t forget to press Create alarm.