> ## Documentation Index
> Fetch the complete documentation index at: https://cloud-architect.ipoint-labs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating a CloudWatch Dashboard for EC2 Instance

> Hands-on lab · 30m

Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console.

<a className="ip-lab-portal-btn" href="https://labs.intellectualpoint.com/labs/creating-a-cloudwatch-dashboard-for-ec2-instance" target="_blank" rel="noreferrer">
  Open IP Lab Portal
</a>

## Overview

### Lab details

1. This lab walks you through the steps to create CloudWatch Dashboard for EC2
2. Duration: **30 minutes**
3. AWS Region: **US East (N. Virginia) us-east-1**

### Introduction

CloudWatch dashboard provides a customizable, centralized view of your EC2 instance metrics. It is a tool provided by Amazon Web Services (AWS) that allows you to visualize and track metrics and alarms for your EC2 instances. In this lab, we will create an EC2 instance and attach it to CloudWatch dashboard. We will then add widgets to visualize the metrics we want to monitor.

### Architecture diagram

<img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/001.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=9b2addf8ac22f04d0be132648a373cc9" alt="" width="1830" height="780" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/001.png" />

### Task details

1. Sign in to AWS Management Console.
2. Launch an EC2 instance.
3. Create a CloudWatch dashboard.
4. Create different widgets for the same metric to see the difference.
5. Validation of the lab

### Launching the lab environment

1. To launch the lab environment, Click on the **Launch lab** button.
2. Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
3. Once the Lab is started, you will be provided with **IAM user name**, **Password**, **Access** **Key**, and **Secret** **Access** **Key**.

<Note>
  You can only start one lab at any given time
</Note>

## Lab guide

### Lab steps

#### Task 1: Sign in to AWS Management Console

1. Click on the **Open console** button, and you will get redirected to AWS Console in a new browser tab.
2. 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

3. Once Signed In to the AWS Management Console, Make the default AWS Region as **US East (N. Virginia) us-east-1.**

#### Task 2: Launch an EC2 instance

1. Make sure you are in the **N.Virginia Region**.
2. Navigate to EC2 by clicking on the **Services** menu in the top, then click on **EC2** in the **Compute** section.
3. Navigate to **Instances** from the left side menu and click on **Launch Instance.**
4. Enter **Name** as **whizlabs.**
5. Choose an Amazon Machine Image (AMI): Select **Amazon Linux 2023 AMI** in the drop-down.
6. Choose **architecture** as **64-bit(x86)**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/002.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=f3212024d9fad9f9fcec11c74d493483" alt="" width="930" height="466" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/002.png" />

7. Choose an **Instance Type**: Select ***t2.micro***\*\*.\*\*

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-connecting-through-browser-based-ssh/003.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=a09f43626a29bfa39733b8a791add5e2" alt="" width="970" height="240" data-path="images/labs/launching-ec2-machine-and-connecting-through-browser-based-ssh/003.png" />

8. **For Key pair:** Select **Create a new key pair** Button

* Key pair name: **WhizKey**
* Key pair type: **RSA**
* Private key file format: **.pem**

9. Select **Create key pair** Button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/003.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=f7b129eed1e3cbf380cee158d5252a98" alt="" width="750" height="780" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/003.png" />

10. 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***

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-connecting-through-browser-based-ssh/005.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=fb28a6f462268a7c45e87015a1c52101" alt="" width="975" height="472" data-path="images/labs/launching-ec2-machine-and-connecting-through-browser-based-ssh/005.png" />

* Check Allow SSH from and Select Anywhere from dropdown
* To add **SSH**,

  1. Choose Type: **SSH.**
  2. Source: Select **Anywhere.**

11. **Leave** the rest of the things as default.

12. Click on the **Launch Instance.**

13. **Launch Status:** Your instance is now launching. Click on the instance ID and wait for complete initialization of instance (until the status changes to Running).

<img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/004.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=5bd22f65ee9bcfca015518eb5a55896d" alt="" width="1104" height="184" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/004.png" />

14. Note the **Public IPv4 Address** and **Instance ID** of the EC2 instance. A sample is shown in the screenshot below.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/005.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=a12b61e93c021ad9eabb82245d8401f8" alt="" width="2214" height="652" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/005.png" />

#### Task 3: Creating a CloudWatch Dashboard

1. Wait for 5-10 minutes for CloudWatch to gather metrics from EC2 Instance.
2. Navigate to **CloudWatch** by clicking on the **Services** menu at the top of the page, then click on **CloudWatch** in the **Management and Governance section**.
3. Click on **Dashboards** on the left panel.
4. Click on **Create Dashboard**.
5. Give a name to your dashboard.

* Dashboard name: Enter **MyEC2**
* Click on **Create dashboard** button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/006.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=d3131ec0938fe90a8a261fecbbb6054a" alt="" width="1228" height="446" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/006.png" />

6. We have to select a widget type to configure and add to this dashboard. Leave it as the default line **chosen**.
7. Click on the **Next** button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/TSQ7Mvha7YyTZ0k2/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/007.png?fit=max&auto=format&n=TSQ7Mvha7YyTZ0k2&q=85&s=d9d08254e74a783d779ede82d4081001" alt="" width="1918" height="1068" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/007.png" />

8. Under Add metric graph in the **Browse** tab, scroll down to **EC2** and click on EC2.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/vScAll09yOH6D8RK/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/008.png?fit=max&auto=format&n=vScAll09yOH6D8RK&q=85&s=0cafcc06155af4b497c470a54113aecc" alt="" width="1318" height="683" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/008.png" />

<img src="https://mintcdn.com/ip-cloud-architect-pathway/vScAll09yOH6D8RK/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/009.png?fit=max&auto=format&n=vScAll09yOH6D8RK&q=85&s=c7dc7790c7ca6e39b1fff8681ad4dc21" alt="" width="748" height="314" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/009.png" />

.

9. Under EC2, choose **Per-Instance Metrics**.

10. **Paste the copied Instance id** in the search bar and select the **CPUUtilization** from the metrics and click on **Create Widget** button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/vScAll09yOH6D8RK/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/010.png?fit=max&auto=format&n=vScAll09yOH6D8RK&q=85&s=5b72133e60abeeca07c1764d99ad5115" alt="" width="1576" height="413" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/010.png" />

<Note>
  If you don't see the CPUUtilization metrics, wait for 5 minutes.
</Note>

11. Click **Create Widget.**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/vScAll09yOH6D8RK/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/011.png?fit=max&auto=format&n=vScAll09yOH6D8RK&q=85&s=70ed5e1566f00a0a223e542fdeec8ace" alt="" width="1318" height="670" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/011.png" />

12. Refresh **CPUUtilization.**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/vScAll09yOH6D8RK/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/012.png?fit=max&auto=format&n=vScAll09yOH6D8RK&q=85&s=8bd0ed6500f77113cd0a42b378464c59" alt="" width="808" height="724" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/012.png" />

13. You have successfully created a **Line widget** for CPUUtilization.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/vScAll09yOH6D8RK/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/013.png?fit=max&auto=format&n=vScAll09yOH6D8RK&q=85&s=142f3e99d65f6d15d1fb9760c49344f2" alt="" width="280" height="224" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/013.png" />

#### Task 4: Creating different Widgets for same Metric

#### Stacked Area

1. In the dashboard click on **MyEC2**.
2. Click on the **+ button to Add widget** and select **Stacked area.** Click on **Next.**
3. You will see a metric graph. Under **All metrics**, search and choose **EC2** (since we are going to watch the metrics of EC2 which we have created earlier).
4. Under EC2, choose **Per-Instance Metrics**.
5. Search by pasting the copied Instance id and select the **CPUUtilization** from the metrics and click on **Create Widget** button.
6. You have successfully created a **Stacked Area widget** for CPU Utilization.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/vScAll09yOH6D8RK/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/014.png?fit=max&auto=format&n=vScAll09yOH6D8RK&q=85&s=8132142a958758dcfd9c514989b654b5" alt="" width="267" height="312" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/014.png" />

#### Number

1. In the dashboard click on **MyEC2**.
2. Click on **+ button to** **Add widget** and select **Number.** Click on **Next.**
3. You can see a metric graph. Under **All metrics**, search and choose \*\*EC2 (\*\*since we are going to watch the metrics of EC2 which we have created earlier).
4. Under EC2, choose **Per-Instance Metrics**.
5. Search by pasting the copied Instance id and select the **CPUUtilization** from the metrics and click on **Create Widget** button.
6. You have successfully created a **Number widget** for CPU Utilization.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/vScAll09yOH6D8RK/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/015.png?fit=max&auto=format&n=vScAll09yOH6D8RK&q=85&s=fee84c251b8b7cf4f04f21467911f885" alt="" width="260" height="158" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/015.png" />
7. Click on **Save Dashboard** to save the widgets.
8. Refresh the page, until the metric value is shown.
9. Using these steps, you can use the widgets to create your own dashboard for metrics.

<Note>
  The actual metric generated depends on the CPUUtilization.
</Note>

<img src="https://mintcdn.com/ip-cloud-architect-pathway/vScAll09yOH6D8RK/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/016.png?fit=max&auto=format&n=vScAll09yOH6D8RK&q=85&s=dd6d885a85f49637bf101c2d7853cbce" alt="" width="786" height="306" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/016.png" />

<Tip>
  **Do you know?**

  While CloudWatch dashboards are typically associated with a specific region, you can create cross-region dashboards. This allows you to aggregate metrics from EC2 instances across multiple regions into a single dashboard, providing a centralized view of your global infrastructure.CloudWatch dashboards support dynamic widgets that allow you to pass parameters and filter metrics based on runtime conditions.
</Tip>

#### Task 5 : Validation of the Lab

1. Once the lab steps are completed, please click on the **Check my work** button on the left side panel.
2. This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
3. Sample output :

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/vScAll09yOH6D8RK/images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/017.gif?s=11483e4f0eba7ddd789780ddd03fc9fd" alt="" width="1000" height="440" data-path="images/labs/creating-a-cloudwatch-dashboard-for-ec2-instance/017.gif" />

### Completion and conclusion

1. You have successfully launched an EC2 Instance.
2. You have created a CloudWatch dashboard.
3. You have successfully created different widgets for the same metric.

### End lab

1. Sign out of the AWS Account.
2. You have successfully completed the lab.
3. Once you have completed the steps, click on **End lab** 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.
* **create a cloudwatch dashboard** — check whether the Cloudwatch dashboard is created or not

## Related help

* [FAQs and Troubleshooting](/aws-cp/support/faqs-and-troubleshooting)
* [SSH into EC2 Instance](/aws-cp/support/ssh-into-ec2-instance)
