Cloud Fortgeschritten
AWS CloudWatch — Monitoring und Observability¶
AWSCloudWatchMonitoringObservability 5 min Lesezeit
CloudWatch Metriken, Logs, Alarme, Logs Insights und Synthetics.
Custom Metriken¶
import boto3
cw = boto3.client('cloudwatch')
cw.put_metric_data(Namespace='MyApp', MetricData=[{
'MetricName': 'OrdersProcessed',
'Value': 42, 'Unit': 'Count',
'Dimensions': [{'Name':'Environment','Value':'production'}]
}])
Logs Insights¶
fields @timestamp, @message
| filter @message like /duration/
| parse @message "duration=* ms" as duration
| sort duration desc
| limit 10
Alarme¶
resource "aws_cloudwatch_metric_alarm" "high_cpu" {
alarm_name = "high-cpu"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = 3
metric_name = "CPUUtilization"
namespace = "AWS/EC2"
period = 300
statistic = "Average"
threshold = 80
alarm_actions = [aws_sns_topic.alerts.arn]
}
Zusammenfassung¶
CloudWatch = zentraler Monitoring-Hub von AWS. Kombinieren Sie es mit X-Ray (Tracing) und Synthetics (Canary Tests).
Brauchen Sie Hilfe bei der Implementierung?¶
Unser Team hat Erfahrung in der Planung und Implementierung moderner Architekturen. Wir helfen Ihnen gerne.