Overview
Lab details
- This lab guides you through the different features of CloudWatch that are used for monitoring resources.You will learn how to create CloudWatch alarms and dashboards, enabling you to effectively monitor your resources and set up notifications for important metrics.
- Duration: 90 minutes
- AWS Region: US East (N. Virginia) us-east-1
Architecture diagram

Task details
- Sign into the AWS Management Console.
- Create an EC2 Instance.
- SSH into EC2 Instance and install necessary Softwares.
- Create SNS Topic.
- Subscribe to an SNS Topic.
- Check EC2 CPU Utilization Metrics in CloudWatch Metrics.
- Create CloudWatch Alarm.
- Testing CloudWatch Alarm by Stressing CPU Utilization.
- Checking For an Email from the SNS Topic.
- Checking the CloudWatch Alarm Graph.
- Create a CloudWatch Dashboard.
- Validation of the lab.
Launching the lab environment
- To launch the lab environment, Click on the Launch lab button.
- Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
- Once the Lab is started, you will be provided with IAM user name, Password, Access Key, and Secret Access Key.
Lab guide
Lab steps
Task 1: Sign in to AWS Management Console
- Click on the Open console button, and you will get redirected to AWS Console in a new browser tab.
-
On the AWS sign-in page,
- Leave the Account ID as default. Never edit/remove the 12 digit Account ID present in the AWS Console. otherwise, you cannot proceed with the lab.
- Now copy your User Name and Password in the Lab Console to the IAM Username and Password in AWS Console and click on the Sign in button.
- Once Signed In to the AWS Management Console, Make the default AWS Region as US East (N. Virginia) us-east-1.
Task 2: Launching an EC2 Instance
In this task, we are going to launch an EC2 Instance that will be used for checking various features in CloudWatch.- Make sure you are in the N.Virginia Region.
- Navigate to EC2 by clicking on the Services menu in the top, then click on EC2 in the Compute section.
- Navigate to Instances from the left side menu and click on Launch instances button.
- Name : Enter MyEC2Server

-
For Amazon Machine Image (AMI): Select Amazon Linux and the select Amazon Linux 2023 AMI from the drop-down.

- For Instance Type: Select t2.micro
-
For Key pair: Select Create a new key pair Button
- Key pair name: MyEC2Key
- Key pair type: RSA
- Private key file format: .pem
- Select Create key pair Button.

- In Network Settings Click on Edit button:
- Auto-assign public IP: Enable
- Select Create new Security group
- Security group name : Enter MyEC2Server_SG
- Description : Enter Security Group to allow traffic to EC2
-
To add SSH :
- Choose Type: Select SSH
- Source: Select Anywhere
- Keep Rest the things as Default and Click on Launch Instance Button.
- Select View all Instances to View the Instance you created.
- Launch Status: Your instance is now launching. Click on the instance ID and wait for complete initialization of the instance (until the status changes to running).
Select the instance and Copy the Instance-ID and save it for later, we need to search the metrics in CloudWatch based on this.

Task 3: SSH into EC2 Instance and install necessary Softwares
- Follow the instructions provided in SSH to EC2 instance to SSH into the EC2 instance you created.
-
Once you are logged into the EC2 instance, switch to root user.
-
Update :
-
Stress Tool will be used for simulating EC2 metrics. Once we create the CloudWatch Alarm, we shall come back to SSH and trigger CPUUtilization using it.
Task 4: Create SNS Topic
In this task, we are going to create a SNS Topic.- Make sure you are in the N.Virginia Region.
- Navigate to Simple Notification Service by clicking on the Services menu available under the Application Integration section.
- Click on Topics in the left panel and then click on Create topic button.
-
Under Details:
- Type: Select Standard
- Name: Enter MyServerMonitor
- Display name: Enter MyServerMonitor

- Leave other options as default and click on Create topic button. A SNS topic will be created.
Note : Please ignore if below error message appears.


Task 5: Subscribe to an SNS Topic
- Once SNS topic is created, click on SNS topic MyServerMonitor.
- Click on Create subscription button.
-
Under Details:
- Protocol : Select Email
- Endpoint : Enter your email address
- Note: Make sure you give proper email address as this is where your notification will be delivered.
- You will receive a subscription confirmation to your email address

- Click on Confirm subscription.

- Your email address is now subscribed to SNS Topic MyServerMonitor.
Task 6: Using CloudWatch to Check EC2 CPU Utilization Metrics in CloudWatch Metrics
- Navigate to CloudWatch by clicking on the Services menu available under the Management & Governance section.
- Click on All metrics under Metrics in the Left Panel.
- You should be able to see EC2 under All Metrics. If EC2 is not visible, please wait for 5-10 minutes, CloudWatch usually takes around 5-10 minutes after the creation of EC2 to start fetching metric details.

- Click on EC2. Select Per-Instance Metrics.
- Here you can see various metrics. Select the CPUUtilization metric to see the graph.

- Now at the top of the screen, you can see the CPU Utilization graph (which is at zero since we have not stressed the CPU yet).
Task 7: Create CloudWatch Alarm
CloudWatch alarms are used to watch a single CloudWatch metric or the result of a math expression based on CloudWatch metrics.- Click on In alarms under Alarms in the left panel of the CloudWatch dashboard.
- Click on Create alarm available on the top right corner.
-
In the Specify metric and conditions page:
- Click on Select metric. It will open the Select Metrics page.
- Scroll down and Select EC2.
- Select Per-Instance Metrics
- Enter your EC2 Instance-ID in the search bar to get metrics for MyEC2Server
- Choose the CPUUtilization metric.
- Click on Select metric button.
-
Now, configure the alarm with the following details:
-
Under Metrics
- Period: Select 1 Minute
-
Under Conditions
- Threshold type: Choose Static
- Whenever CPUUtilization is… : Choose Greater
- than: Enter 30
- Leave other values as default and click on Next button.
-
Under Metrics
-
In Configure actions page:
-
Under Notification
- Alarm state trigger: Choose In Alarm
- Select an SNS topic: Choose Select an existing SNS topic
- Send a notification to… : Choose MyServerMonitor SNS topic which was created earlier.
-
Under Notification

- Leave other fields as default. Click on Next button.
- In the Add a description page, (under Name and Description):
- Name: Enter the Name MyServerCPUUtilizationAlarm
- Click on Next button.
- A preview of the Alarm will be shown. Scroll down and click on Create alarm button.
- A new CloudWatch Alarm is now created.

- Whenever the CPU Utilization goes above 30 for more than 1 minute, an SNS Notification will be triggered and you will receive an email.
Task 8: Testing CloudWatch Alarm by Stressing CPU Utilization
- SSH back into the EC2 instance - MyEC2Server.
-
The stress tool has already been installed. Lets run a command to increase the CPU Utilization manually.
-
This command shall monitor the process created by the stress tool(which we triggered manually). It will run for 6 minutes and 40 seconds. It will monitor CPU utilization, which should remain very near 100% for that amount of time.

- Open another Terminal on your local machine and SSH back in EC2 instance - MyEC2Server.
-
Run this command to see the CPU utilization if you are a MAC or Linux User. For Windows User, you can navigate to Task manager.

- You can now see that %Cpu(s) is 100. By running this stress command, we have manually increased the CPU utilization of the EC2 Instance.
- After 400 Seconds, the %Cpu will reduce back to 0.
Task 9 : Checking For an Email from the SNS Topic
- Navigate to your mailbox and refresh it. You should see a new email notification for MyServerCPUUtilizationAlarm.

- We can see that mail we received contains details about our CloudWatch Alarm,(name of the alarm, when it was triggered, etc.).
Task 10: Checking the CloudWatch Alarm Graph
- Navigate back to CloudWatch page, Click on Alarms.
- Click on MyServerCPUUtilizationAlarm.
- On the Graph, you can see places where CPUUtilization has gone above the 30% threshold.

- We can trigger CPUUtilization multiple times to see the spike on the graph.
- You have successfully triggered a CloudWatch Alarm for CPUUtilzation.
Task 11: Create a CloudWatch Dashboard
We can create a simple Cloudwatch dashboard to see the CPUUtilization and various other metric widgets.- Click on Dashboard in the left panel of the CloudWatch page.
-
Click on Create dashboard button.
- Dashboard name: Enter MyEC2ServerDashboard
- Click on Create dashboard
- Add widget: Select Line Graph.
- Click on Next button.
- Select Metrics. Click on Next button.
- On the next page, Choose EC2 under the Metrics tab. Choose Per-Instance Metrics.
- In the search bar, enter your EC2 Instance ID. Select CPUUtilization.
- Click on Create Widget button.
- Depending on how many times you triggered the stress command, you will see different spikes in the timeline.

- Now click on the Save button.
- You can also add multiple Widgets to the same Dashboard by clicking on Add widget button.
Task 12 : Validation Test
- Once the lab steps are completed, please click on the Check my work button on the left side panel.
- This will validate the resources in the AWS account and shows you whether you have completed this lab successfully or not.
- Sample output :

Completion and conclusion
- You have created an EC2 Instance for which CloudWatch Monitoring will be carried out.
- You have successfully created an Amazon SNS Topic used by CloudWatch.
- You have successfully subscribed to SNS topic using your email address.
- You have used CloudWatch to see CPUUtilization Metrics using CloudWatch Metrics.
- You have successfully created and triggered a CloudWatch Alarm based on the CPUUtilzation Metric.
End lab
- Sign out of AWS Account.
- You have successfully completed the lab.
- Once you have completed the steps, click on End lab button in the IP Lab Portal.
What gets checked
When you press Check my work, the platform verifies each of these:- Launch an EC2 Instance — Check whether an EC2 Instance is launched or not.
- Launch EC2 AMI type Amazon Linux — Check whether the EC2 instance is launched using an Amazon AMI.
- Create an Amazon SNS Topic — Check If SNS Topic created or not
- Check CloudWatch Alarm Creation — Check whether at least one CloudWatch alarm exists or not.
- Check Log Group — Check whether a CloudWatch log group exists.