DEV Community

Muhammad Nadeem
Muhammad Nadeem

Posted on

Monitering EC2 instance

TASK 1: Configure Amazon SNS ๐Ÿ“ง

Objective

Create an Amazon SNS topic and subscribe to email notifications for alerts.

What is Amazon SNS?
Full Name: Amazon Simple Notification Service
Type: Fully managed messaging service
Use Case: Application-to-Application (A2A) and Application-to-Person (A2P) communication
Purpose: Send real-time notifications via email, SMS, HTTP, SQS, Lambda, etc.

Lab tasks content summary ยท MD
AWS CloudWatch Monitoring Lab - Complete Task Content ๐Ÿ“‹
Overview

This lab teaches how to set up a complete monitoring solution on AWS that detects CPU spikes and sends automatic email alerts.

TASK 1: Configure Amazon SNS ๐Ÿ“ง
Objective

Create an Amazon SNS topic and subscribe to email notifications for alerts.

What is Amazon SNS?
Full Name: Amazon Simple Notification Service
Type: Fully managed messaging service
Use Case: Application-to-Application (A2A) and Application-to-Person (A2P) communication
Purpose: Send real-time notifications via email, SMS, HTTP, SQS, Lambda, etc.
Steps Completed:
Step 1: Navigate to SNS
AWS Console โ†’ Search Bar โ†’ Type "SNS" โ†’ Click "Simple Notification Service"
Step 2: Create SNS Topic
Location: Simple Notification Service Console
Action: Left Menu (โ˜ฐ) โ†’ Topics โ†’ Create topic

Configuration:
โ”œโ”€ Type: Standard (selected)
โ”œโ”€ Name: MyCwAlarm
โ””โ”€ Create topic (button clicked)

Result: Topic "MyCwAlarm" successfully created
Step 3: Create Email Subscription
Location: MyCwAlarm Topic Details Page
Action: Subscriptions Tab โ†’ Create subscription

Configuration:
โ”œโ”€ Topic ARN: arn:aws:sns:us-west-2:xxx:MyCwAlarm (auto-filled)
โ”œโ”€ Protocol: Email (selected from dropdown)
โ”œโ”€ Endpoint: [Your Email Address]
โ””โ”€ Create subscription (button clicked)

Status: "Pending confirmation"
Step 4: Confirm Email Subscription
Email Received: AWS Notification - Subscription Confirmation
Action:

  1. Check email inbox
  2. Open AWS notification email
  3. Click "Confirm subscription" link

Result: Status changed to "Confirmed"
Backend: SNS topic now linked to email address
What This Accomplished:

โœ… Created messaging topic
โœ… Linked email address to topic
โœ… Verified email subscription
โœ… Ready to send email alerts

Key Takeaway:

SNS acts as a bridge between AWS services (CloudWatch) and end users (your email). When alarms trigger, SNS automatically sends notifications to subscribers.

**

TASK 2: Create CloudWatch Alarm ๐Ÿšจ

Objective
**

Configure a CloudWatch alarm to monitor EC2 CPU utilization and trigger when threshold is exceeded.

What is CloudWatch?
Full Name: Amazon CloudWatch
Type: Monitoring and observability service
Purpose: Monitor applications, systems, and AWS resources
Data Types: Logs, Metrics, Events
Users: DevOps Engineers, SREs, IT Managers, Developers

TASK 3: Stress Test EC2 Instance โšก

Objective

Run CPU stress test to simulate high load and verify alarm triggers correctly.

Why Stress Test?
Simulates malware/attack scenarios
Tests alarm responsiveness
Validates monitoring system
Ensures notifications deliver
Security testing practice

TASK 4: Create CloudWatch Dashboard ๐Ÿ“Š
Objective

Create a customizable dashboard to visualize CPU utilization metrics in one place.

What is a CloudWatch Dashboard?
Purpose: Centralized monitoring interface
Customizable: Add/remove widgets
Multi-region: Monitor resources across regions
Real-time: Live metric updates
Widgets: Graphs, numbers, alarms, logs
Use Case: Quick overview for team monitoring

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ AWS Monitoring System โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ EC2 Instance (Stress Test) โ”‚ โ”‚
โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ Application/CPU Process โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ Stress Tool: 100% CPU Load โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ (Emits metrics) โ”‚
โ”‚ โ†“ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ CloudWatch โ”‚ โ”‚
โ”‚ โ”‚ (Monitoring)โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ (Metric: CPUUtilization) โ”‚
โ”‚ โ”‚ (Comparison: 95.2% > 60%) โ”‚
โ”‚ โ†“ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Alarm โ”‚ โ”‚
โ”‚ โ”‚ (Triggered) โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ (IN ALARM state) โ”‚
โ”‚ โ†“ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ SNS Topic โ”‚ โ”‚
โ”‚ โ”‚ (MyCwAlarm) โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ (Message routing) โ”‚
โ”‚ โ†“ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Email Alert โ”‚ โ”‚
โ”‚ โ”‚ Subscriber โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ โ”‚
โ”‚ โ†“ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Your Email โ”‚ โ”‚
โ”‚ โ”‚ Inbox โ”‚ โœ‰๏ธ Notification โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚
โ”‚ Dashboard Display: โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ LabEC2Dashboard โ”‚ โ”‚
โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ CPUUtilization Graph โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ โ•ฑโ•ฒ โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ โ•ฑ โ•ฒ โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ โ•ฑ โ•ฒ โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ โ•ฑโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฒโ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Top comments (0)