First step, let’s create an anomaly detector model on a specific CloudWatch metric (EC2 Average CPUUtilization for an instance):

aws cloudwatch put-anomaly-detector — namespace “AWS/EC2” — metric-name “CPUUtilization” — dimensions Name=InstanceId,Value=i-0345489963224c1a3 — stat “Average”

We can list our Cloudwatch anomaly detectors for the CPUUtilization of all our EC2 instances with

aws cloudwatch describe-anomaly-detectors — metric-name “CPUUtilization” — namespace “AWS/EC2”

In the AWS Console, you will be able to see the different models you have created:

--

--

Download and install the stress test tool

sudo amazon-linux-extras install epel -y
sudo yum install stress -y

Launch the stress test in background (for 800 seconds in that example)

sudo stress --cpu 8 --timeout 800 &

Check the stress test processes with the top command

top

Result for the top command

Manually stop the stress test (if needed)

sudo killall stress

Check the EC2 CPU metric in Clouwatch
(protip, enable detailed monitoring)

--

--

Greg

This is my personal blog where I post (in my spare time) computer science “cheatsheets”. I mainly do it for myself but it may benefit others.