AWS Windows EC2 instance resource alerting (CPU/Memory/Disk) without Cloudwatch

Phani Kumar
1 min readMar 19, 2021

Monitoring is an important part of maintaining the reliability, availability, and performance of your Amazon Elastic Compute Cloud (Amazon EC2) instances. The use of AWS Cloudwatch service for monitoring could costs if usage reached free tier limits and monitoring of Disk & Memory of EC2 is not straightforward to monitor even using Cloudwatch. The following article tells you how to alert you when the instance reached the prescribed limits using a simple PowerShell script generic to all EC2 Windows instances.

Before you execute the following script make sure the IAM role of the instance has policies to publish a message to the SNS topic and to describe tags in order to get the instance given name.

The script goes like this

At line 20 update the disk percentage when the alert needs to be sent

At line 33 update the CPU & Memory percentages when the alert needs to be sent

At line 35 update the correct SNS topic ARN

And finally running the above Powershell script to execute periodically

  1. Login into the instance
  2. create a file to save the above Powershell script e.g. C://monitor.ps1
  3. copy and save the PowerShell script
  4. create a task in the Task scheduler to execute the file periodically

Please follow my other stories to execute the above script without login into the instance using the AWS SSM run command

--

--