Chapter-5 EC2-CloudWatch

Amazon CloudWatch

Performance and monitoring are the parameters which provides better business and benefits. In AWS, Amazon CloudWatch is a monitoring service for AWS cloud resources. It monitors AWS services and the applications that run on AWS. We can use Amazon CloudWatch to collect and track metrics, collect and monitor log files, set alarms, and automatically react to changes in our AWS resources.

CloudWatch monitors Performance. It monitors many services like

Compute – EC2 instances, Autoscaling Groups, ELB, Route53 health checks.

Storage and Content Delivery: EBS Volumes Storage Gateways, Cloudfront.

It monitors like – CPU UTILIZATION ,Network ,Disk ,Status Check

What is CloudTrail?

AWS CloudTraiI increases visibility into your user and resource activity by recording AWS Management Console actions and API calls.

What is difference between CloudWatch and CloudTrail?

CloudWatch monitors performance and

CloudTrail monitors API calls in the AWS platform.

CloudWatch Lab:

Step 1: Launch EC2 Instance and navigate to Configure Instance Details.

Select checkbox Monitoring option for using CloudWatch. Its not free and it charges as per used time.

and complete remaining steps. EC2 instance is created.

Step 2:  Check Monitoring tab: In this tab we can see Performance of EC2 Instance. If anything goes wrong then it will reflect in Monitoring Tab. Admin Team will take action accordingly.

Step 3: Navigate to CloudWatch and select CPU Utilization parameter. There are so many parameters on which we can perform CloudWatch monitoring. For practice purpose, we are going to use CPUUtilization parameter. Lets understand how will it work?

If user has setup CPUUtilization threshold value 90% then CloudWatch will trigger Alarm when CPUUtilization will reach 90%. And User will be notified about CPUUtilization performance. Accordingly User increases CPU size or reduce its load. In real life , we used to use WorkFlow.

Click on Create Alarm.

Select metric and choose EC2 instance. Make sure that Metric name is CPUUtilization if we are going to perform Alarm on CPU Utilization.

Select highlighted row to perform Alarm.

Next fill details as below:

Matric Name – Provide any name i.e. CPUUtilization.

Period : Its value can be changed. By default it shows 5 mins.

Whenever CPUUtilization is : have selected Greater and entered 95. Its mean, whenever CPUutilization exceeds 95% then Alarm will be triggered.

Next :

Send Notification to : we can provide email ids on which Alarm will be triggered.

Next enter other details and Alarm is created.


Now Alarm setup is completed. For practice purpose, we will increase CPUUtilization by increasing its load. So we will connect EC2 instance and will print something in infinite loop. Doing so , load on CPUUtiliation will increase. And Alarm will be triggered.

Lets do it practically. Now we will connect to EC2 instance through its IP address. If you dont know , how to connect EC2 instance then please refer chapter 1 EC2 instance creation or follow below details:

How to login EC2 instance through command line?

  1. We have stored pem file in previous steps.
  2. Open cmd and navigate to the folder where we have put pem file.

Run below command to provide full access:

CHMOD 400 LearningEC2.pem

  • Run below command to open EC2 instance:

ssh ec2-user@ -i LearningEC2.pem

Type Yes if any question is asked.

cloudvikas@personal  ~/Documents/AWS WEBSITE/test/SSH

$ ls


cloudvikas@personal  ~/Documents/AWS WEBSITE/test/SSH

$ CHMOD 400 LearningEC2.pem

$ ssh ec2-user@ -i LearningEC2.pem

The authenticity of host ‘ (’ can’t be established.

ECDSA key fingerprint is SHA256:w38Wj5jrEk4jhXmyMrtyuuiikih6xgn8qw.

Are you sure you want to continue connecting (yes/no/[fingerprint])? y

Please type ‘yes’, ‘no’ or the fingerprint: yes

Warning: Permanently added ‘’ (ECDSA) to the list of known hosts.

       __|  __|_  )

       _|  (     /   Amazon Linux 2 AMI


8 package(s) needed for security, out of 17 available

Run “sudo yum update” to apply all updates.

[ec2-user@ip-172-11-1-111 ~]$

Now run below command to execute in infinite loop. Doing so CPU utilization will reach 90% based on our selection. And Alarm will be triggered.

Alarm will be triggered:

Its monitoring graph in EC2 dashboard:

Important Points:

CloudWatch is used for monitoring performance.

CloudWatch can monitor most of AWS as well as your applications that run on AWS.

CloudWatch with EC2 will monitor events every 5 minutes by default.

• You can have 1 minute intervals by turning on detailed monitoring.

You can create CloudWatch alarms which trigger notifications.

CloudWatch is all about performance. CloudTrail is all about auditing.

What Can I do With CloudWatch?

Dashboards – Creates awesome dashboards to monitoring.

Alarms – Allows you to set Alarms that notify you when particular thresholds are reached.

Events – CloudWatch Events helps you to respond to state changes in your AWS resources.

Logs – CloudWatch Logs helps you to aggregate, monitor, and store logs.

Why CloudWatch?

It is important to monitor performance of your resources like EC2 for better business. As an example, you have an EC2 resource and its CPU workload is getting increased on a particular day. If it is not brought in your intention, then CPU performance will be decreased, and business can go down. In this case, CloudWatch works as monitoring device. CloudWatch monitors your resources like EC2 and collects data in form of logs.

 It will monitor your resource and will send Alarm based on threshold value. After getting Alarms, Admin will act in advance and Performance will not be reduced.

How does CloudWatch work?

Step 1: CloudWatch collects monitoring and operational data in the form of logs, metrics, and events.

Step 2: We can create alarms based on metric value thresholds.

Step 3: To act quickly, we can set up automated actions to notify us if an alarm is triggered and automatically start auto scaling.

************************** End *******************************

Related Topics:

Chapter-2 EC2 Instance Termination

Chapter-3 EC2-Security Groups

Chapter-1 EC2 Instance Creation

Chapter-4 EC2 EBS

Chapter 6 AWS CLI

Chapter 7 AWS Boot Strap Scripts

EC2 Knowledge Check

For latest updates please join FB group (search in FaceBook) or click on link Cloudvikasgroup