# AWS - CloudWatch Subscription Filters/Alarms/ServiceLens/Synthetics/Metric Stream
# Subscription Filters
用途:即時把 Logs 串流到其他服務做後續處理
可串接對象
- Lambda 即時告警、自動修復
- Kinesis Data Streams 即時分析
- Kinesis Firehose 落地到 S3 / OpenSearch
關鍵字
- Real-time log processing
- Near real-time analytics
- Trigger Lambda from logs
# Logs Encryption
- 預設:AWS 管理金鑰
- 進階:Customer Managed KMS Key
什麼時候一定選 KMS?
- 金融、醫療、法規合規(HIPAA、PCI DSS)
# Retention Period
-
預設:Never Expire(最貴)
-
正確做法:
- 7 天、14 天、30 天
-
SOA 常考:如何降低 CloudWatch Logs 成本?
- 正解:設定 Retention
# CloudWatch Alarms
降低告警雜訊與進階分析
# Composite Alarms (減少告警雜訊)
用途:多個 Alarm 組合成一個最終告警
EX:
1 | CPU > 80% AND StatusCheckFailed |
關鍵字
- Reduce alert noise
- Avoid false positives
# Metric Math (趨勢與異常分析)
功能
- 交叉計算多個 Metrics
- 成長率 / 差值 / 比例
可搭配
-
Anomaly Detection
-
Forecasting
-
Detect abnormal traffic patterns automatically
- 標準答案:Metric Math + Anomaly Detection
# ServiceLens – X-Ray + CloudWatch 整合
用途:把 Infra(CloudWatch) + Application(X-Ray)整合成單一故障視圖
你可以看到
- ALB → EC2 → Lambda → RDS
- 服務瓶頸在哪一層
SOA 常考情境
- 使用者回報「系統變慢」
- 需要 快速找出是哪個微服務出問題
- 正解:ServiceLens
# CloudWatch Synthetics – API 與網站主動監控
# Canaries (主動式監控)
用途: 用腳本定期「模擬使用者操作」
可監控
-
API Endpoint 是否正常
-
登入流程
-
表單提交
-
第三方服務 SLA
-
它是 Proactive Monitoring(主動監控)
-
CloudWatch Metrics 是 Reactive(被動)
經典考題
- 在用戶還沒發現前,提前知道 API 掛了
- 標準答案:CloudWatch Synthetics Canaries
# Metric Streams (即時輸出到外部監控系統)
用途:把 CloudWatch Metrics 即時串流到外部平台
標準串流對象
-
Kinesis Data Firehose → S3 / OpenSearch / Splunk
-
Prometheus
-
幾乎「零延遲」
-
不經過 GetMetricData API(省錢)
關鍵字
- Real-time monitoring outside AWS
- External SIEM / Observability platform
- 標準答案:Metric Streams + Firehose