Observability
D2 · Resilient
D3 · Performance
~1 phút đọc

CloudWatch — Monitoring, Logs, Metrics & Alarms

CloudWatch là trung tâm giám sát AWS: thu thập metrics, logs, tạo alarm, dashboard. Hiểu rõ metric resolution, log group, alarm action và Logs Insights.

cloudwatch
metrics
logs
alarms
dashboard
observability

Sơ đồ tổng quan

Đang tải sơ đồ…

Tổng quan

CloudWatch là dịch vụ giám sát tập trung của AWS, thu thập metrics từ hầu hết service (EC2, RDS, Lambda, ELB...), lưu trữ logs, và cho phép tạo alarm để phản ứng tự động khi metric vượt ngưỡng.

Metrics & Resolution

  • Standard resolution: 5 phút (miễn phí cho hầu hết service).
  • Detailed monitoring: 1 phút (EC2 trả thêm phí).
  • High-resolution custom metrics: tới 1 giây.
  • Custom metrics qua PutMetricData API hoặc CloudWatch Agent.
  • Metric Math: tính toán trên nhiều metric (vd: error rate = errors / total).

Logs

  • Log Group → Log Stream → Log Events.
  • CloudWatch Agent cài trên EC2 để push OS/app logs.
  • Logs Insights: query language mạnh, tìm pattern, thống kê.
  • Subscription Filter: stream log tới Kinesis, Lambda, hoặc OpenSearch.
  • Retention: 1 ngày → vĩnh viễn, mặc định never expire.
  • Embedded Metric Format (EMF): gửi metric trong log → tự extract.

Alarms & Actions

  • 3 trạng thái: OK, ALARM, INSUFFICIENT_DATA.
  • Action: SNS notification, Auto Scaling, EC2 action (stop/terminate/reboot/recover).
  • Composite Alarm: kết hợp nhiều alarm bằng AND/OR → giảm noise.
  • Anomaly Detection: ML-based, tự học baseline.
Tip
Đề thi hay hỏi 'auto recover EC2 khi fail status check' → CloudWatch Alarm + EC2 Recovery action.

Dashboard & Synthetics

  • Dashboard: cross-account, cross-region, tự động refresh.
  • Synthetics Canaries: script chạy định kỳ kiểm tra endpoint/URL.
  • RUM (Real User Monitoring): thu thập performance từ browser thật.
  • Container Insights: metrics cho ECS/EKS cluster.
  • Lambda Insights: detailed function-level metrics.
Nội dung liên quan
Flashcards liên quan