AWS-CLoud Watch - Notes By ShariqSP

AWS CloudWatch Overview

What is AWS CloudWatch?

AWS CloudWatch is a monitoring and observability service provided by Amazon Web Services. It allows users to collect and track metrics, collect and monitor log files, set alarms, and automatically react to changes in AWS resources. CloudWatch provides insights into the performance and health of your AWS infrastructure and applications.

Why do we need AWS CloudWatch?

AWS CloudWatch is essential for:

How to Access AWS CloudWatch?

You can access AWS CloudWatch through the AWS Management Console, AWS CLI (Command Line Interface), AWS SDKs (Software Development Kits), or AWS CloudWatch API (Application Programming Interface).

Examples on Monitoring an EC2 Instance

Here are step-by-step examples on how to monitor an EC2 instance using AWS CloudWatch:

Monitoring CPU Utilization

To monitor CPU utilization of an EC2 instance:

  1. Log in to the AWS Management Console.
  2. Navigate to the CloudWatch service.
  3. Click on "Alarms" in the left navigation pane.
  4. Click on "Create Alarm".
  5. Under "Select metric", choose "EC2" as the namespace and select the "Per-Instance Metrics" tab.
  6. Select the desired EC2 instance from the list.
  7. Choose the "CPUUtilization" metric.
  8. Configure the threshold for CPU utilization that triggers the alarm.
  9. Specify the actions to be taken when the alarm state is triggered. Choose "In alarm", then select "Stop instance" action to stop the instance.
  10. Configure the notification actions. Choose "In alarm", then select "Send notification to an SNS topic" and select the SNS topic to send the notification.
  11. Complete the alarm configuration and click "Create Alarm".

Monitoring Disk Utilization

To monitor disk utilization of an EC2 instance:

  1. Follow steps 1-7 from the CPU utilization monitoring section.
  2. Choose the "Disk" metric.
  3. Configure the threshold for disk utilization that triggers the alarm.
  4. Specify the actions to be taken when the alarm state is triggered. Choose "In alarm", then select "Stop instance" action to stop the instance.
  5. Configure the notification actions. Choose "In alarm", then select "Send notification to an SNS topic" and select the SNS topic to send the notification.
  6. Complete the alarm configuration and click "Create Alarm".

Monitoring Network Utilization

To monitor network utilization of an EC2 instance:

  1. Follow steps 1-7 from the CPU utilization monitoring section.
  2. Choose the "Network" metric.
  3. Configure the threshold for network utilization that triggers the alarm.
  4. Specify the actions to be taken when the alarm state is triggered. Choose "In alarm", then select "Stop instance" action to stop the instance.
  5. Configure the notification actions. Choose "In alarm", then select "Send notification to an SNS topic" and select the SNS topic to send the notification.
  6. Complete the alarm configuration and click "Create Alarm".

Conclusion

Monitoring EC2 instances with AWS CloudWatch provides valuable insights into their performance and health. By tracking metrics such as CPU utilization, disk utilization, and network utilization, you can optimize resource usage, troubleshoot issues, and ensure the smooth operation of your applications running on EC2 instances. Implementing actions like instance stoppage and email notifications enhances your ability to proactively manage your AWS resources.