How To: EC2 Email Alarm Using CloudWatch (3 Min) | AWS EC2 CloudWatch Threshold Alert SNS Alarm

Gokce DB
24 Jan 202303:52

Summary

TLDRIn this tutorial, ABI from gokjdb demonstrates how to set up an email alarm for an AWS EC2 instance using CloudWatch and SNS. The process involves creating an SNS topic, subscribing an email address, confirming the subscription, launching an EC2 instance with user data to install the stress utility, and configuring an alarm with a CPU utilization threshold. Once the threshold is breached, an email notification is sent. The video concludes with a demonstration of the alarm in action and a reminder to like, subscribe, and enable notifications.

Takeaways

  • 🚀 Start by navigating to the SNS service in AWS to create a topic for email notifications.
  • 📝 Name your topic and create it to establish a channel for email alerts.
  • 🔗 Create a subscription to the topic using the email protocol and confirm the subscription in your inbox.
  • 🖥️ Head to the EC2 service to launch an instance with a specific name and AMI, while leaving other settings at default.
  • 🛠️ Install the stress utility on the EC2 instance via user data input for testing CPU utilization.
  • 💻 Launch the instance and wait for it to be in a 'running' state before proceeding.
  • ⚠️ Set up an alarm in CloudWatch with a threshold for CPU utilization, linking it to the SNS topic for notifications.
  • 🔍 SSH into the instance and use the 'top' command to monitor CPU utilization.
  • 🔧 Generate CPU stress using the 'stress -c 1' command to test the alarm threshold.
  • 📧 Receive an email alert if the CPU utilization crosses the specified threshold, indicating the alarm has been triggered.
  • 👍 Remember to like, subscribe, and enable notifications for more content.

Q & A

  • What is the purpose of the video by ABI from gokjdb?

    -The purpose of the video is to teach viewers how to create an email alarm for an EC2 instance using CloudWatch.

  • Which service should be navigated to first to create an email alarm?

    -The first service to navigate to is the SNS (Simple Notification Service).

  • What is the process to create a topic in SNS?

    -To create a topic in SNS, click on 'Topics', then 'Create topic', choose a topic type, give your topic a name, and hit 'Create topic'.

  • How do you subscribe to the created SNS topic via email?

    -After creating the topic, click on 'Create subscription', choose 'Email' from the protocol dropdown, enter your email address in the endpoint text box, and click 'Create subscription'.

  • What confirmation is needed after subscribing to the SNS topic via email?

    -You need to go to your inbox to confirm the subscription and then verify that your email status says 'confirmed' in the 'Subscriptions' tab.

  • What is the next step after confirming the SNS subscription?

    -After confirming the subscription, go to the EC2 service, click on 'Instances', and then 'Launch Instances'.

  • What commands should be pasted into the user data input box during the EC2 instance launch for a specific purpose?

    -Paste the two commands provided in the video to install the stress utility on the EC2 instance.

  • What is the CPU utilization threshold set in the CloudWatch alarm in the video?

    -The CPU utilization threshold set in the CloudWatch alarm is 25 percent.

  • What action can be specified when the alarm threshold is breached?

    -When the alarm threshold is breached, you can specify actions such as recover, reboot, stop, or terminate the EC2 instance.

  • How can you monitor the CPU utilization of the EC2 instance after applying stress?

    -You can monitor the CPU utilization using the 'top' command in an SSH terminal window.

  • What should you do if the 'stress' command is not found after attempting to apply stress to the EC2 instance?

    -If the 'stress' command is not found, you can manually install it using the two commands provided in the video.

  • How can you verify that the email alarm has been triggered in CloudWatch?

    -You can verify that the email alarm has been triggered by navigating to the CloudWatch service, clicking on 'Alarms', going inside the specific alarm for the EC2 instance, and checking the 'View in Metrics' section for the breached threshold and the email alert in your inbox.

Outlines

00:00

🚀 Creating an Email Alarm for EC2 with CloudWatch

ABI from gokjdb introduces a tutorial on setting up an email alarm for an Amazon EC2 instance using Amazon CloudWatch and SNS. The process begins with navigating to the SNS service to create a new topic, followed by subscribing to it with an email address. After confirming the subscription via email, the user is guided to the EC2 service to launch an instance with specific user data commands for installing the 'stress' utility. The tutorial continues with instructions on creating an alarm in CloudWatch that triggers an email notification when the CPU utilization reaches 25%. The video concludes with a demonstration of generating CPU stress and receiving an email alert when the threshold is breached.

Mindmap

Keywords

💡EC2 Instance

An EC2 (Elastic Compute Cloud) instance is a virtual server in the Amazon Web Services (AWS) cloud. It is the fundamental unit of computing capacity for which you can easily manage the size, operating system, networking, and storage. In the video, the EC2 instance is used to demonstrate how to set up an email alarm using CloudWatch, which is crucial for monitoring the instance's performance and sending alerts when certain thresholds are reached.

💡CloudWatch

Amazon CloudWatch is a monitoring service for AWS cloud resources and the applications you run on AWS. It collects monitoring and operational data in the form of logs, metrics, and events, allowing you to analyze resource and application performance. In the script, CloudWatch is used for setting up an alarm that triggers an email notification when a specific CPU utilization threshold is exceeded.

💡SNS (Simple Notification Service)

Amazon Simple Notification Service (SNS) is a fully managed messaging service that enables real-time communication among distributed software components. It can be used to send messages to a variety of endpoints (HTTP, HTTPS, email, SMS, etc.). In the video, SNS is used to create a topic and subscription to send email alerts when the EC2 instance's CPU utilization reaches a certain level.

💡Topic

In the context of SNS, a topic is a communication channel that sends messages to multiple endpoints. It is used to organize and manage message delivery to a group of subscribers. The video script describes creating a topic as part of setting up the email alarm for the EC2 instance.

💡Subscription

A subscription in SNS is the method by which an endpoint (like an email address) receives messages from a topic. The script mentions creating a subscription to an SNS topic with an email address as the endpoint, which is essential for receiving notifications when the alarm is triggered.

💡Endpoint

An endpoint in SNS refers to the destination where messages are sent, such as an email address, an HTTP endpoint, or an SMS number. In the script, the email address is entered as the endpoint to receive the CPU utilization alert from the SNS topic.

💡AMI (Amazon Machine Image)

An Amazon Machine Image (AMI) provides the information required to launch an instance, which is a virtual server in the AWS cloud. It includes the software (operating system, application server, and applications) and the configuration details of the server. The video script mentions selecting an AMI when launching an EC2 instance.

💡User Data

User data is a feature of EC2 that allows scripts to be executed when an instance is launched. It can be used to automate the configuration of the instance, such as installing additional software. In the script, user data is used to install the 'stress' utility on the EC2 instance.

💡SSH (Secure Shell)

SSH is a protocol that provides a secure channel over an unsecured network in a client-server architecture. It is used for remote login into an instance, executing commands, and moving files to and from the instance. The script mentions using SSH to connect to the EC2 instance and to run commands to generate CPU stress.

💡Alarm Threshold

An alarm threshold in CloudWatch is a value that triggers an alarm when the metric associated with the alarm goes beyond this value. In the video, a CPU utilization threshold of 25 percent is set, which, when exceeded, will trigger an email notification via SNS.

💡Stress Command

The 'stress' command is a utility that deliberately loads the CPU of a system to test its performance under stress. In the script, the 'stress -c 1' command is used to generate CPU load on the EC2 instance to demonstrate the alarm triggering.

Highlights

Introduction to creating an email alarm for an EC2 instance using CloudWatch.

Navigating to the SNS service to create a new topic for email notifications.

Selecting topic type and naming the topic for the email alarm.

Creating a subscription with the email address for the SNS topic.

Confirming the email subscription in the inbox and verifying the status as 'confirmed'.

Accessing the EC2 service to launch an instance with a specific name.

Using default settings for the EC2 instance configuration.

Installing the stress utility via user data input for instance monitoring.

Launching the instance and waiting for it to be in a 'running' state.

Configuring an alarm in the CloudWatch with an SNS topic for notifications.

Specifying a CPU utilization threshold of 25% for the alarm.

Option to set an alarm action such as recover, reboot, stop, or terminate.

SSHing into the EC2 instance to monitor CPU utilization with the 'top' command.

Generating stress on the EC2 instance using the 'stress -c 1' command.

Troubleshooting the 'stress command not found' error by manual installation.

Verifying the CPU utilization reaching 100% with the stress utility.

Viewing the breached threshold in CloudWatch and receiving an email alert.

Encouragement to like, subscribe, and turn on notifications for future content.

Transcripts

play00:00

hi guys this is ABI from gokjdb in this

play00:04

video we are going to learn how to

play00:07

create an email alarm for an ec2

play00:10

instance using Cloud watch

play00:13

let's start by navigating to the SNS

play00:16

service then click on topics then hit

play00:20

create topic

play00:22

choose a topic type then give your topic

play00:25

a name and then hit create topic

play00:29

next click on the create subscription

play00:31

button then choose email from the

play00:35

protocol drop down

play00:37

enter your email address in the endpoint

play00:40

text box then click on create

play00:43

subscription

play00:45

go to your inbox to confirm this

play00:48

subscription then come back to the

play00:50

subscriptions Tab and verify that your

play00:54

email status says confirmed

play00:57

now let's head to the ec2 service then

play01:01

click on instances followed by launch

play01:04

instances

play01:06

give your instance a name then select an

play01:09

Ami I'm going to leave all the other

play01:12

settings to default then scroll down to

play01:16

the advanced details section

play01:18

navigate to the user data input box and

play01:23

paste these two commands so we can

play01:25

install the stress utility

play01:28

click on launch instance then wait few

play01:31

minutes for the instance state to change

play01:35

to running

play01:36

click on the plus icon in the alarm

play01:40

status column then head to the alarm

play01:43

notification section and choose the SNS

play01:47

topic that we created in one of the

play01:49

earlier steps

play01:51

in the alarm threshold section I'm going

play01:55

to specify a CPU utilization of 25

play01:58

percent

play02:00

note you also get an option to specify

play02:03

an alarm action such as recover reboot

play02:08

stop or terminate when this alarm gets

play02:11

triggered

play02:13

hit the create button then SSH into your

play02:17

instance using ec2 instance connect

play02:21

I'm going to open one more SSH terminal

play02:25

window so we can monitor the CPU

play02:28

utilization using the top command

play02:31

I'm going to enter the stress hyphen C1

play02:35

command to generate some stress on my

play02:38

ec2 instance

play02:40

if you see the stress command not found

play02:43

error this means that the stress command

play02:46

was still not installed feel free to

play02:49

install it manually by using these two

play02:52

commands

play02:53

once the stress utility starts working

play02:56

verify that your top output now shows a

play03:00

CPU utilization of around 100 percent

play03:05

next let's navigate to the cloud watch

play03:08

service then click on alarms

play03:11

go inside your alarm that's specified

play03:14

for this ec2 instance then click on view

play03:18

in metrics

play03:20

give it a few minutes and you should see

play03:23

your threshold being breached you should

play03:26

also see an email alert in your inbox

play03:29

which will say that the CPU utilization

play03:32

of 25 was crossed for this instance

play03:37

there you have it make sure you like

play03:40

subscribe and turn on the notification

play03:42

Bell until next time

play03:46

foreign

play03:49

[Music]

Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
CloudWatchEC2Email AlarmSNS TopicAWS ServicesInstance MonitoringCPU UtilizationStress TestingAlert NotificationsAWS TutorialSystem Monitoring
Benötigen Sie eine Zusammenfassung auf Englisch?