There is a way to get reports of the instance on the AWS EC2 instance under the “Status Checks” tab. There are two types of status checks: Instance status checks and System status checks. The System Status checks focus on the hardware and virtualization infrastructure supporting your EC2 instance whilst the Instance status check is mostly on the software and configuration specific to each EC2 instance.
1. Go to Ec2 Instance -> Status checks & Alarms
As you can see below both Status Checks are running.
2. Go to Actions -> Create Status check alarm
Since I’m creating a new alarm, I created a new topic name associated with that alarm and then chose an option as to what to do then the alarm triggered. I chose “reboot”
Then configure the Alarm threshold based on your requirements
3. Hit create and once you have the instance, you should see the alarm created
As you can see, it says INSUFFICIENT_DATA, because it was recently created. After some time the status should say “OK”
4. From the console, go CloudWatch, and you should be able to see the alarm there as well. It will also display a redline on the graph which is the threshold for the alarm to be triggered.
5. You can also go to Cloudwatch -> Alarms -> All Alarms
Choose the Alarm you created and scroll down to history. This gives more details about the Alarm log itself.
6. On top, there is a button called “CloudWatch Shell”, as soon as you hit that, it will open a shell prompt.
As you can see, the shell open below:
7. On the Cloudwatch shell, you can issue some issue command, i.e.; an API call to make the Alarm go to a state in which you would want to trigger a specific action. On the AWS portal, there is documentation for the CloudWatch shell command.
aws cloudwatch set-alarm-state --alarm-name awsec2-i-0ebb3d73fbac66293-GreaterThanOrEqualToThreshold-CPUUtilization --state-value ALARM --state-reason "testing new alarm"