AWS Metrics Retention
- Cloudwatch retains metrics data
- Data points with period of less than 60 seconds (frequency) are available for 3 hours. These are called as high resolution metrics
- Data points with period of 60 seconds are available for 15 days
- Data points with period over 300 seconds are available for 63 days
- Data points with period over 3600 seconds are available for 455 days
AWS Cloudwatch Terms
- Dimensions: A dimension is a name/value pair that is part of identity of metric. Each metric can have upto 10 dimensions
- General Dimensions added are
- Environment = (Dev/QA/UAT/Prod)
- Project = (name of project)
- Version = (Version of the project)
- Statistics:
- Minimum
- Maximum
- Sum
- Average
- Sample Count
- pNN.NN : percentile (p96.54)
- Units: Each statistic has a unit of measure . Example units Bytes, Seconds, Percent etc
- Period: frequency of data collection. Generally defined by number of seconds
- Alarm: We use alarm to initiate some action automatically. Alarms can send notifications to SNS or Auto Scaling policy. Alarm can 3 values
- Insufficient: Alarm doesnot sufficient data to decide
- OK: Alarm is not met
- Alarm: Your condition of alarm is met.
Lets play with Alarms
-
Scenario 1: Lets take a metric called as CPU Utilization (Percentage CPU) and when Percentage CPU is less than 40 lets shutdown the system.
-
Solution:
-
Scenario 2: Lets create an alarm to restart ec2 instance when Percentage CPU is grater than 90% for 5 mins
- Lets login into ec2 instance and try to install a tool called stress
sudo amazon-linux-extras install epel sudo yum install stress -y stress --cpu 8 -v --timeout 100m
- Now watch for CPU Utilization
- Now create an alarm for above condition
-
Scenario 3: Create a cloudwatch alarm with no action to (Exercise)
- Plot if the DB Connections are less than or equal to 10 in last 1 hour
- Plot if the free space is less than 100 MB
-
Scenario 4: Send an email when cpu utilzation is grater than 80 % for 5 minutes
-
Scenario 5: Send an email for underused ec2 instance (when cpu utilization is less than 30)
-
Scenario 6: Send an email for under used RDS instance (DB Connections equal to zero in last 1 hour)