DEV Community

Aisalkyn Aidarova
Aisalkyn Aidarova

Posted on

Lab – Amazon CloudWatch Metrics, Dashboards & Alarms

Lab Goal

In this lab you will learn how DevOps engineers monitor applications running in production.

By the end of this lab you will be able to:

  • Understand what CloudWatch Metrics are.
  • Create a CloudWatch Dashboard.
  • Monitor your ECS Service.
  • Monitor your Application Load Balancer.
  • Create CloudWatch Alarms.
  • Receive notifications when something goes wrong.
  • Understand how DevOps engineers detect problems before customers report them.

Production Scenario

Imagine your application is running on ECS.

GitHub

↓

GitHub Actions

↓

Amazon ECR

↓

Amazon ECS

↓

Application Load Balancer

↓

Users
Enter fullscreen mode Exit fullscreen mode

Yesterday everything worked perfectly.

Today users start saying:

"The website is very slow."

As a DevOps Engineer, the first question is:

What changed?

You don't guess.

You look at monitoring.

That is why companies use Amazon CloudWatch.


What is Amazon CloudWatch?

CloudWatch is AWS's monitoring service.

Think of it as a health monitor for your AWS resources.

Instead of waiting for customers to complain, CloudWatch tells you when something is wrong.

CloudWatch collects information such as:

  • CPU Usage
  • Memory Usage
  • Network Traffic
  • Requests
  • Response Time
  • Errors

What is a Metric?

A metric is simply a number measured over time.

Examples:

Metric Meaning
CPU Utilization How busy the server is
Memory Utilization How much RAM is being used
Request Count Number of users visiting
Response Time How long requests take
Healthy Host Count Number of healthy ECS tasks

Think of your smartwatch.

It measures:

  • Heart Rate
  • Steps
  • Calories

CloudWatch does the same thing for AWS resources.


Why Do Companies Monitor?

Imagine this happens:

At 2 AM

CPU becomes

98%
Enter fullscreen mode Exit fullscreen mode

If nobody notices,

the application becomes slow.

Eventually

CPU 100%

↓

Application Stops Responding
Enter fullscreen mode Exit fullscreen mode

Customers cannot use the website.

Monitoring allows DevOps engineers to fix problems before they become outages.


What Can CloudWatch Monitor?

Today we will monitor:

  • ECS Service
  • ECS Tasks
  • Application Load Balancer

Later you can also monitor:

  • EC2
  • Lambda
  • RDS
  • DynamoDB
  • API Gateway
  • S3

Part 1 – Open CloudWatch

Open AWS Console

Search

CloudWatch
Enter fullscreen mode Exit fullscreen mode

Open it.

You will see:

  • Dashboards
  • Alarms
  • Metrics
  • Logs

Today we will use:

  • Metrics
  • Dashboards
  • Alarms

Part 2 – View Metrics

Click

Metrics
Enter fullscreen mode Exit fullscreen mode

Click

All Metrics
Enter fullscreen mode Exit fullscreen mode

You will see many AWS services.

Examples:

  • ECS
  • EC2
  • ApplicationELB
  • Lambda
  • RDS

Part 3 – ECS Metrics

Click

ECS
Enter fullscreen mode Exit fullscreen mode

Then

ClusterName
Enter fullscreen mode Exit fullscreen mode

Choose your cluster.

You should see metrics such as:

  • CPUUtilization
  • MemoryUtilization

Click

CPUUtilization
Enter fullscreen mode Exit fullscreen mode

A graph appears.

This graph shows how busy your ECS service has been.


Why CPU Matters

Imagine CPU usage stays around

15%
Enter fullscreen mode Exit fullscreen mode

Everything is healthy.

Now traffic increases.

CPU becomes

95%
Enter fullscreen mode Exit fullscreen mode

The application may:

  • become slow
  • stop responding
  • restart

This is why DevOps engineers always monitor CPU.


Memory Utilization

Return to Metrics.

Choose

MemoryUtilization
Enter fullscreen mode Exit fullscreen mode

Memory shows how much RAM the container is using.

If memory reaches

100%
Enter fullscreen mode Exit fullscreen mode

The container may crash.


Part 4 – Monitor the Load Balancer

Go back.

Choose

ApplicationELB
Enter fullscreen mode Exit fullscreen mode

Select your ALB.

Useful metrics include:

RequestCount

How many requests users are sending.

If it suddenly increases,

your website is getting more traffic.


TargetResponseTime

How long your application takes to respond.

Healthy example:

150 ms
Enter fullscreen mode Exit fullscreen mode

Bad example:

3 seconds
Enter fullscreen mode Exit fullscreen mode

Slow response usually means:

  • high CPU
  • database problems
  • slow application code

HealthyHostCount

Shows how many healthy ECS tasks are receiving traffic.

Example

2 Healthy
Enter fullscreen mode Exit fullscreen mode

Good.

If it becomes

0
Enter fullscreen mode Exit fullscreen mode

Nobody can use your application.


HTTPCode_Target_5XX_Count

Shows application errors.

Examples

500

502

503

504
Enter fullscreen mode Exit fullscreen mode

These usually mean something is wrong with the application.


Part 5 – Create a Dashboard

Why create dashboards?

Instead of opening many AWS pages,

DevOps engineers want everything on one screen.

Open

Dashboards

↓

Create Dashboard
Enter fullscreen mode Exit fullscreen mode

Dashboard name

Restaurant-App
Enter fullscreen mode Exit fullscreen mode

Click

Create
Enter fullscreen mode Exit fullscreen mode

Add Widgets

Click

Add Widget
Enter fullscreen mode Exit fullscreen mode

Choose

Line
Enter fullscreen mode Exit fullscreen mode

Add:

Widget 1

CPUUtilization
Enter fullscreen mode Exit fullscreen mode

Widget 2

MemoryUtilization
Enter fullscreen mode Exit fullscreen mode

Widget 3

RequestCount
Enter fullscreen mode Exit fullscreen mode

Widget 4

HealthyHostCount
Enter fullscreen mode Exit fullscreen mode

Widget 5

TargetResponseTime
Enter fullscreen mode Exit fullscreen mode

Save.

Now one screen shows the health of your application.

This is how many DevOps teams monitor production.


Part 6 – CloudWatch Alarms

Monitoring is useful.

But nobody watches dashboards 24 hours a day.

Instead,

CloudWatch sends alerts.

Example

CPU

95%

↓

CloudWatch Alarm

↓

Email

↓

DevOps Engineer
Enter fullscreen mode Exit fullscreen mode

Now someone knows there is a problem.


Part 7 – Create CPU Alarm

Open

CloudWatch

↓

Alarms

↓

Create Alarm
Enter fullscreen mode Exit fullscreen mode

Choose Metric

ECS

↓

CPUUtilization
Enter fullscreen mode Exit fullscreen mode

Condition

Greater Than

80
Enter fullscreen mode Exit fullscreen mode

Meaning

If CPU stays above

80%
Enter fullscreen mode Exit fullscreen mode

CloudWatch creates an alarm.


Evaluation Period

Choose

5 minutes
Enter fullscreen mode Exit fullscreen mode

Why?

CPU can briefly spike.

We don't want false alarms.

Waiting a few minutes helps reduce unnecessary alerts.


Notification

Choose

Create New SNS Topic
Enter fullscreen mode Exit fullscreen mode

Name

DevOpsAlerts
Enter fullscreen mode Exit fullscreen mode

Enter your email.

Click

Create
Enter fullscreen mode Exit fullscreen mode

Check your email.

Click

Confirm Subscription
Enter fullscreen mode Exit fullscreen mode

Without confirming, AWS cannot send notifications.


Alarm Name

High-CPU-Restaurant-App
Enter fullscreen mode Exit fullscreen mode

Click

Create Alarm
Enter fullscreen mode Exit fullscreen mode

Done.


Part 8 – Create Memory Alarm

Repeat the process.

Metric

MemoryUtilization
Enter fullscreen mode Exit fullscreen mode

Threshold

80%
Enter fullscreen mode Exit fullscreen mode

Alarm Name

High-Memory
Enter fullscreen mode Exit fullscreen mode

Part 9 – Create Healthy Host Alarm

Metric

HealthyHostCount
Enter fullscreen mode Exit fullscreen mode

Condition

Less Than

1
Enter fullscreen mode Exit fullscreen mode

Meaning

If no healthy ECS tasks exist,

CloudWatch immediately sends an alert.

This is one of the most important production alarms.


Part 10 – Create Target Response Time Alarm

Metric

TargetResponseTime
Enter fullscreen mode Exit fullscreen mode

Condition

Greater Than

2 Seconds
Enter fullscreen mode Exit fullscreen mode

If users wait too long,

DevOps receives a notification.


Which Alarms Should Every DevOps Engineer Create?

At a minimum:

Alarm Why It Matters
High CPU Application is overloaded
High Memory Prevent container crashes
Healthy Host Count < 1 Application is unavailable
Target Response Time High Website is slow
HTTP 5XX Errors Application is failing

As you gain experience, you can add alarms for other AWS services and business-specific metrics.


How DevOps Engineers Use CloudWatch

Imagine your phone rings.

Email says:

High CPU

95%
Enter fullscreen mode Exit fullscreen mode

What should you check?

  1. Is ECS running?
  2. Are tasks healthy?
  3. Open CloudWatch Logs.
  4. Look for application errors.
  5. Check database connectivity.
  6. Decide whether scaling or a code fix is needed.

CloudWatch tells you something is wrong.

CloudWatch Logs usually help explain why it is happened.


Production Tips

✔ Monitor trends, not just current values.

✔ Use dashboards for daily monitoring.

✔ Use alarms for important events.

✔ Don't create hundreds of unnecessary alarms.

✔ Review alarms regularly to remove ones that are noisy or no longer useful.


Lab Checklist

Complete the following:

✅ View ECS CPU metric

✅ View ECS Memory metric

✅ View ALB Request Count

✅ View ALB Healthy Hosts

✅ Create Dashboard

✅ Add CPU Widget

✅ Add Memory Widget

✅ Add Request Widget

✅ Add Healthy Host Widget

✅ Create CPU Alarm

✅ Create Memory Alarm

✅ Create Healthy Host Alarm

✅ Confirm SNS Email


Interview Questions

1. What is CloudWatch?

AWS monitoring service used to collect metrics, logs, dashboards, and alarms.


2. What is the difference between Metrics and Logs?

Metrics are numbers collected over time (CPU, memory, requests). Logs are detailed text records from your application or services that explain what happened.


3. Why do we create Dashboards?

To view the health of multiple AWS resources in one place.


4. Why do we create Alarms?

To notify the DevOps team automatically when a metric crosses a defined threshold.


5. Which metrics do you monitor in ECS?

  • CPU Utilization
  • Memory Utilization
  • Healthy Host Count
  • Request Count
  • Target Response Time
  • HTTP 5XX Errors

6. What happens if Healthy Host Count becomes 0?

The load balancer has no healthy targets to send traffic to, so users are likely to experience application failures.


7. What is Amazon SNS used for in CloudWatch?

SNS sends notifications, such as email, when an alarm changes to the ALARM state.


Homework

  1. Create a CloudWatch Dashboard with at least 5 widgets.
  2. Create 4 CloudWatch Alarms:
  • High CPU (>80%)
  • High Memory (>80%)
  • Healthy Host Count (<1)
  • High Target Response Time (>2 seconds)

    1. Trigger one alarm (if possible) and verify that you receive an email notification.
    2. Take screenshots of:
  • Your Dashboard

  • Your Alarms

  • Your SNS subscription confirmation

  • Your ECS Metrics graph

By completing this lab, students will have a basic monitoring setup similar to what many teams configure for an ECS application in AWS.

Top comments (0)