Junior — Middle
What monitoring and alerting scenarios in AWS cloud have you worked with using CloudWatch?
sobes.tech AI
Answer from AI
Using AWS CloudWatch, I handled the following monitoring and alerting scenarios:
- EC2 Instance Performance Monitoring: tracking CPU, memory, disk activity metrics, and creating alarms when thresholds are exceeded.
- Application Status Monitoring: collecting custom metrics from applications and setting up alerts for anomalies.
- Log Management and Log Analysis: integrating with CloudWatch Logs for log collection and filtering, setting alerts for error occurrences.
- AWS Service Monitoring: for example, checking RDS, Lambda function statuses, and creating notifications for failures.
Example of setting up a CPU alarm on EC2 using Python and boto3:
import boto3
cloudwatch = boto3.client('cloudwatch')
cloudwatch.put_metric_alarm(
AlarmName='HighCPUUtilization',
MetricName='CPUUtilization',
Namespace='AWS/EC2',
Statistic='Average',
Period=300,
EvaluationPeriods=2,
Threshold=80.0,
ComparisonOperator='GreaterThanThreshold',
Dimensions=[{'Name': 'InstanceId', 'Value': 'i-1234567890abcdef0'}],
AlarmActions=['arn:aws:sns:region:account-id:my-sns-topic']
)