Skip to content

Commit 36846da

Browse files
Create cloudwatch_cpu_alarm_via_aws_cli
1 parent 151774d commit 36846da

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

cloudwatch_cpu_alarm_via_aws_cli

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Setup CPU Usage Alarm using the AWS CLI
2+
3+
aws cloudwatch put-metric-alarm --alarm-name cpu-mon --alarm-description "Alarm when CPU exceeds 70 percent" --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period 300 --threshold 70 --comparison-operator GreaterThanThreshold --dimensions "Name=InstanceId,Value=i-12345678" --evaluation-periods 2 --alarm-actions arn:aws:sns:us-east-1:111122223333:MyTopic --unit Percent
4+
5+
# Change the alarm-state from INSUFFICIENT_DATA to OK
6+
7+
aws cloudwatch set-alarm-state --alarm-name "cpu-monitoring" --state-reason "initializing" --state-value OK
8+
9+
# Change the alarm-state from OK to ALARM
10+
11+
aws cloudwatch set-alarm-state --alarm-name "cpu-monitoring" --state-reason "initializing" --state-value ALARM

0 commit comments

Comments
 (0)