What is CloudWatch?
- CloudWatch is a service used to monitor your AWS resources and applications that you run on AWS in real time. CloudWatch is used to collect and track metrics that measure your resources and applications.
- It displays the metrics automatically about every AWS service that you choose.
- You can create the dashboard to display the metrics about your custom application and also display the metrics of custom collections that you choose.
- You can also create an alarm to watch metrics. For example, you can monitor CPU usage, disk read and disk writes of Amazon EC2 instance to determine whether the additional EC2 instances are required to handle the load or not. It can also be used to stop the instance to save money.
Following are the terms associated with CloudWatch:
- Dashboards: CloudWatch is used to create dashboards to show what is happening with your AWS environment.
- Alarms: It allows you to set alarms to notify you whenever a particular threshold is hit.
- Logs: CloudWatch logs help you to aggregate, monitor, and store logs.
- Events: CloudWatch help you to respond to state changes to your AWS resources.
Creating a Dashboard
- Sign in to the AWS Management Console.
- I created an EC2 instance, and the name of an EC2 instance is EC2instance.
- Move to the CloudWatch service.
- Click on the Dashboards appearing on the left side of the console.
- Click on the Create dashboard button. Enter the dashboard name. Suppose I write the dashboard name as WebServer.
- Click on the Create dashboard.
- Select the widget type and add to the dashboard.
- I add the Line widget to our dashboard.
- After adding a line widget, you have to choose the service. I choose the EC2 service.
- Click on the per-instance metrics.
- Choose the CPUUtilization as a metric name and click on the create widget button.
- The below screen shows the CPU utilization in the form of line widget.
- I add another widget known as stacked area.
The above screen shows the CPU utilization in the form of a colored graph.
Creating an Alarm
- Click on the Alarms appearing on the left side of the console.
- Click on the Create Alarm.
- Click on the Per-Instance Metrics.
- I select a CPUUtilization metric.
The above details show that when CPU utilization is greater than 80%, then an alarm is triggered and sent to the email address that you mentioned while filling the alarm details.
- Click on the link sent to your email address for confirmation and this confirmation shows that you are ready to receive the alerts.