You can set up CloudWatch alarms to monitor metrics and trigger actions based on predefined thresholds. Here's an example using the AWS CLI to create an alarm:
aws cloudwatch put-metric-alarm \
--alarm-name "HighCPUUtilization" \
--alarm-description "Alarm when CPU utilization exceeds 70%" \
--actions-enabled \
--alarm-actions <ARN_of_SNS_Topic> \
--metric-name CPUUtilization \
--namespace AWS/EC2 \
--statistic Average \
--period 300 \
--threshold 70 \
--comparison-operator GreaterThanThreshold \
--dimensions Name=InstanceId,Value=<InstanceId> \
--evaluation-periods 2 \
--unit Percent