1Cost Management
CloudWatch Custom Metrics and high-retention Log Groups can become expensive. Set expiration policies on your Log Groups (e.g., delete after 30 days) to prevent infinite storage costs.
2Step-by-Step Breakdown
What is CloudWatch?. A monitoring and observability service that provides data and actionable insights to monitor your applications and optimize resource utilization.
CloudWatch Metrics. Metrics represent a time-ordered set of data points. AWS automatically provides metrics like EC2 CPU utilization, RDS database connections, and S3 bucket size.
Standard vs Detailed Monitoring. By default, EC2 metrics are reported every 5 minutes (Standard). You can pay to enable Detailed Monitoring, which reports every 1 minute.
Custom Metrics. You aren't limited to AWS metrics. Your application code can push Custom Metrics to CloudWatch, like 'Number of items sold' or 'Login failures'.
Knowledge Check. By default, how frequently are Amazon EC2 standard metrics sent to CloudWatch?
- →Every 1 minute
- →Every 5 minutes
CloudWatch Logs. Centralized storage for your application logs. You install the CloudWatch Agent on EC2, and it streams /var/log/syslog directly to the cloud.
Log Insights. A powerful query language allowing you to search through terabytes of log data instantly to find specific errors or IPs.
CloudWatch Alarms. Alarms watch a single metric and perform actions based on a threshold you define.
Alarm Actions. When an alarm is triggered, it can send an SNS email to your phone, trigger an Auto Scaling Group to add instances, or even reboot an EC2 instance.
Summary. Metrics tell you what's happening. Logs tell you why. Alarms take action.
