Cloud
Pokročilý
AWS CloudWatch — Monitoring a Observabilita
CloudWatch metriky, logy, alarmy, Logs Insights a Synthetics.
Custom Metriky
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
Alarmy
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]
}
Shrnutí
CloudWatch = centrální monitoring hub AWS. Kombinujte s X-Ray (tracing) a Synthetics (canary tests).
Potřebujete pomoct s implementací?
Náš tým má zkušenosti s návrhem a implementací moderních architektur. Rádi vám pomůžeme.
Nezávazná konzultace