How To: EC2 Email Alarm Using CloudWatch (3 Min) | AWS EC2 CloudWatch Threshold Alert SNS Alarm
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
🚀 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
💡CloudWatch
💡SNS (Simple Notification Service)
💡Topic
💡Subscription
💡Endpoint
💡AMI (Amazon Machine Image)
💡User Data
💡SSH (Secure Shell)
💡Alarm Threshold
💡Stress Command
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
hi guys this is ABI from gokjdb in this
video we are going to learn how to
create an email alarm for an ec2
instance using Cloud watch
let's start by navigating to the SNS
service then click on topics then hit
create topic
choose a topic type then give your topic
a name and then hit create topic
next click on the create subscription
button then choose email from the
protocol drop down
enter your email address in the endpoint
text box then click on create
subscription
go to your inbox to confirm this
subscription then come back to the
subscriptions Tab and verify that your
email status says confirmed
now let's head to the ec2 service then
click on instances followed by launch
instances
give your instance a name then select an
Ami I'm going to leave all the other
settings to default then scroll down to
the advanced details section
navigate to the user data input box and
paste these two commands so we can
install the stress utility
click on launch instance then wait few
minutes for the instance state to change
to running
click on the plus icon in the alarm
status column then head to the alarm
notification section and choose the SNS
topic that we created in one of the
earlier steps
in the alarm threshold section I'm going
to specify a CPU utilization of 25
percent
note you also get an option to specify
an alarm action such as recover reboot
stop or terminate when this alarm gets
triggered
hit the create button then SSH into your
instance using ec2 instance connect
I'm going to open one more SSH terminal
window so we can monitor the CPU
utilization using the top command
I'm going to enter the stress hyphen C1
command to generate some stress on my
ec2 instance
if you see the stress command not found
error this means that the stress command
was still not installed feel free to
install it manually by using these two
commands
once the stress utility starts working
verify that your top output now shows a
CPU utilization of around 100 percent
next let's navigate to the cloud watch
service then click on alarms
go inside your alarm that's specified
for this ec2 instance then click on view
in metrics
give it a few minutes and you should see
your threshold being breached you should
also see an email alert in your inbox
which will say that the CPU utilization
of 25 was crossed for this instance
there you have it make sure you like
subscribe and turn on the notification
Bell until next time
foreign
[Music]
関連動画をさらに表示
How To: Route 53 Health Checks (4 Min) | AWS | Monitor Health & Performance Of Your Web Application
How To: Custom Domain For EC2 Web Server (3 Min) | AWS Route 53 | Using A DNS Record In Hosted Zone
HOW TO CONNECT TO EC2 INSTANCE FROM WINDOWS LAPTOP | MOBAXTERM | #aws #devops #abhishekveeramalla
How to connect EC2 instance over SSH using Windows and Mac? | Visual Explanations
AWS: How To Setup A Site-to-Site VPN (Start to Finish) 2024
AWS CloudFormation Template Tutorial
5.0 / 5 (0 votes)