How to setup a Cloud Watch
Last Updated : 16 Oct, 2024
Amazon CloudWatch a key component of Amazon Web Services (AWS) is a service for real-time monitoring. Designed to empower users with vital data and actionable insights. It facilitates the continuous monitoring of applications, and performance adjustments across systems. It collects operational data in the form of logs, metrics and events. It also offers users a perspective on AWS resources, applications, and services operating within the AWS environment.
Components Of Cloud Watch
- EC2 (Elastic Compute Cloud): Before starting with CloudWatch we must know what is EC2 It is the Amazon Web Service we use to create and run virtual machines in the cloud (we call these virtual machines 'instances').To set CloudWatch we must have one EC2 instance running on your machine. If you don't know how to launch an EC2 instance you can refer to this article.
- Resource Groups: AWS Resource Groups lets us organize all the resources such as EC2 instances, RDS database, and S3 buckets into groups using tags that we define while launching/creating instances services. It is a collection of resources that match the resource types specified in a query, and share one or more tags or portions of tags.
- Cloudwatch Logs: CloudWatch Logs allows us to see all of our logs, regardless of their source, as a single and consistent flow of events ordered by time with the help of Graphs.
- Cloudwatch Alarms: CloudWatch Alarms allow us to set different types of alarms which notify us if any Matric goes above the threshold (will be set while creating an alarm).
Installing and Configuring AWS CloudWatch Agent on EC2 Instances Using AWS CLI
For detailed steps and best practices on installing and configuring the AWS CloudWatch agent on EC2 instances using the AWS CLI please refer to our comprehensive guide on Installing and Configuring AWS CloudWatch Agent on EC2 Instances Using AWS CL
How To Setup AWS Cloud Watch
In this architecture we illustrate the essential components involved in setting up AWS CloudWatch for monitoring and alerting your AWS resources effectively The architecture for setting up AWS CloudWatch starts with the user accessing the AWS Management Console. From there, the user can manage various AWS services, including CloudWatch, to monitor their resources effectively. In this setup an Amazon EC2 instance acts as the primary resource being monitored. This instance continuously generates performance metrics such as CPU utilization and network traffic which are then sent to CloudWatch.
Step 1: Go to https://aws.amazon.com/ and Sign in.
Step 2: In the Search Bar, search for EC2 as shown below.
EC2Step 3: After clicking on EC2 from search bar you will land on EC2 dashboard where all the stuff about EC2 is displayed. Click on Instances.
EC2 DashboardStep 4: Here you will get all the EC2 which are running, stopped, terminated, etc. Select the one you want to use. Make sure its Running.
Select Running EC2 InstanceStep 5: Go to to tags section where you will found Key-Value pair, note this down somewhere.
Go to TagsStep 6: Again go to search bar, search for Resource Groups.
Resource GroupsStep 7: After landing in Resource Groups page, from left side select Create Resource Group. In group type select EC2:Instance.
Search EC2 InstanceStep 8: Scroll down you will find Tags section here, select you Key-Value of your EC2 in this tags and select them. You can also select multiple tags if you want.
Select TagStep 9: Scroll down more, name your resource group and hit Create Group.
Group NameStep 10: If you get message something like shown in image below then you successfully created Resource Group.
Create GroupStep 11: Now go to search bar and search for Cloudwatch.
CloudwatchStep 12: Select filter from 'Filter by resource group' and select your Resource Group which we made earlier.
Filter by GroupStep 13: Scroll down and click on 'View EC2 dashboard' and you will get all the necessary graphs.
GraphsAWS Configuration for CloudWatch Logs
For a comprehensive guide on configuring CloudWatch logs in AWS please refer to our detailed article on AWS Configuration for CloudWatch Logs.
How to Setup AWS CloudWatch Alarms
Step 14: On the left menu got Alarms > All alarms > Create alarm > Select metric. Now select EC2 as were setting alarm for EC2 instance.
.png)
Step 15: Select Pre-Instance Metric and now select where Metric Name is CPU Utilization.
Metric NameStep 16: Scroll down and set threshold according to your needs. Click Next
ThresholdStep 17: In Notification, Create a New Topic. Enter Topic name and your Email address. Create and Next.
Create TopicStep 18: Set preferred Alarm name, Next > Create Alarm.
Alarm CreatedStep 19: If you get notification for Pending Cornfirmation, confirm subscription from your mail.
Step 20: After confirming subscription confirm from SNS subscription page.
Conclusion
We have seen how to setup Cloudwatch using EC2 instance and Resource Groups. We have also seen how to set alarm for your EC2 instance to get notification on your mails for CPU Utilization.