Amazon CloudWatch is a monitoring service which monitor AWS resources on Cloud. It comes with dozen of monitoring metrics which ease Cloud Admin to use them in monitoring their AWS Infrastructure services resources like Amazon EC2 instances, Amazon S3 Cloud Storage, Amazon RDS (Relational Database Service) on Cloud etc.
It collects monitoring and operational data in the form of logs, metrics, and events, providing you with a unified view of AWS resources, applications and services that run on AWS, and on-premises servers. Also Amazon CloudWatch can be use for preventing issues proactively on bases of alert threshold.
You can set high resolution visualize graphs for AWS resources performance monitoring metrics. With the help of Amazon SNS (Simple Notification Services) you can create a CloudWatch alarm that sends a simple notification service message when the alarm changes the state. Alarm watches every single metric over a time period and hence performs actions depending on those metric values.
Watch the below Amazon CloudWatch video for more introduction.
In this tutorial I have demonstrated how to setup dashboard for monitoring real time CPUUtilization metric of an AWS EC2 instance after this I have also demonstrated how to setup Amazon CloudWatch alarm for sending notification on email through Amazon SNS service using when Amazon EC2 same CPUUtilization metric meet the threshold.
Note: You can setup dashboard with multiple other metrics (eg. EC2 Disk Read/write Ops, Network Out etc.) as well in AWS console and also set alarm with threshold limit with Amazon SNS service.
To know more about Amazon CloudWatch and SNS services I suggest to refer the AWS document links which are available in the end of this tutorial.
To setup dashboard for monitoring real time CPU Utilization
- In AWS Console go to services and select CloudWatch.
- Click on Dashboard and click on Create Dashboard button located on right side.
- Provide desire Dashboard name, click Create Dashboard.
- Select the widget type Stacked Area and click on Configure button
- Search and Select CPUUtilization metrics after click on Create widget button.
- Click on Save dashboard button.
- Under Dashboard select the provided dashboard name.
- At right you will see CPU utilization monitoring metric graph double click on it for enlarging the graph window. You can see now the realtime monitoring of CPU Utilization.
To setup Amazon CloudWatch alarm for sending notification on email through Amazon SNS service
- Login to AWS console, select Amazon EC2 instance and select Monitoring.
- Click on Create Alarm button.
- Provide desire notification recipient name and email address where you want the Amazon CloudWatch send email notification when CPU threshold meet.
- Set the threshold percentage and provide the desire name of alarm. Click on Create Alarm button.
- Post Alarm configuration if you are getting below message under Config Status you need to verify your email address from Amazon SNS email message which sent to you for confirmation.
- Below is sample email message sent from Amazon SNS service asking for subscription confirmation.
- Once you confirm the subscription from your email from Config Status pending confirmation message will be remove.
Viola! Your Amazon CloudWatch alarm is configured successfully. Whenever Amazon EC2 CPU utilization reaches mentioned threshold limit 80% Amazon CloudWatch will send an email through Amazon SNS service on your subscribed email address.