

# PERF02-BP03 收集與運算相關的指標
<a name="perf_select_compute_collect_metrics"></a>

若要了解運算資源的執行方式，您必須記錄和追蹤各種系統的使用率。此資料可用來更準確地判斷資源需求。  

 工作負載可以產生大量資料，例如指標、日誌和事件。判斷您現有的儲存、監控和可觀測性服務是否可以管理產生的資料。識別哪些指標反映資源使用率，並可在整個單一平台上進行收集、彙總和相互關聯。這些指標應該代表您的所有工作負載資源、應用程式和服務，以便您可以輕鬆地取得全系統可見性，並快速識別效能改進機會和問題。

 **預期成果：** 與運算相關資源相關的所有指標都會在單一平台上進行識別、收集、彙總和相互關聯，並實作保留以支援成本和營運目標。 

 **常用的反模式：** 
+  您只使用手動日誌檔案來搜尋指標。  
+  您只將指標發佈到內部工具。 
+  您只會使用所選監控軟體記錄的預設指標。 
+  您只會在有問題時檢閱指標。 

 

 **建立此最佳實務的優勢：** 若要監控工作負載的效能，您必須記錄一段時間的多個效能指標。這些指標可讓您偵測效能中的異常。它們也會協助針對業務指標衡量效能，以確保您符合工作負載需求。 

 **若未建立此最佳實務，暴露的風險等級：** 高 

## 實作指引
<a name="implementation-guidance"></a>

 識別、收集、彙總運算相關指標，並使其相互關聯。使用 Amazon CloudWatch 這類服務可讓實作更快且更輕鬆維護。除了記錄的預設指標外，還會在您的工作負載內識別和追蹤其他系統等級指標。記錄 CPU 利用率、記憶體、磁碟 I/O，以及網路傳入和傳出指標等資料，以洞悉使用率水平或瓶頸。此資料對於了解工作負載的執行方式，以及運算解決方案的使用方式至關重要。將這些指標納入資料驅動的方法，以主動調整和優化工作負載的資源。  

 **實作步驟：** 

1.  哪些運算解決方案指標務必要追蹤？ 

   1.  [EC2 預設指標](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/viewing_metrics_with_cloudwatch.html) 

   1.  [Amazon ECS 預設指標](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cloudwatch-metrics.html) 

   1.  [EKS 預設指標](https://docs.aws.amazon.com/prescriptive-guidance/latest/implementing-logging-monitoring-cloudwatch/kubernetes-eks-metrics.html) 

   1.  [Lambda 預設指標](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-functions-access-metrics.html) 

   1.  [EC2 記憶體和磁碟指標](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/mon-scripts.html) 

1.  我目前是否具有核准的記錄和監控解決方案？ 

   1.  [Amazon CloudWatch](https://aws.amazon.com/cloudwatch/) 

   1.  [適用於 OpenTelemetry 的 AWS Distro](https://aws.amazon.com/otel/) 

   1.  [適用於 Prometheus 的 Amazon 受管服務](https://docs.aws.amazon.com/grafana/latest/userguide/prometheus-data-source.html) 

1.  我是否已識別並設定我的資料保留策略，以符合我的安全和營運目標？ 

   1.  [CloudWatch 指標的預設資料保留](https://aws.amazon.com/cloudwatch/faqs/#AWS_resource_.26_custom_metrics_monitoring) 

   1.  [CloudWatch Logs 的預設資料保留](https://aws.amazon.com/cloudwatch/faqs/#Log_management) 

1.  如何部署您的指標和記錄彙總代理程式？ 

   1.  [AWS Systems Manager 自動化](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-automation.html?ref=wellarchitected) 

   1.  [OpenTelemetry 收集器](https://aws-otel.github.io/docs/getting-started/collector) 

 **實作計劃的工作量： **有一個 *中* 工作量，用來從所有運算資源識別、追蹤、收集、彙總指標，並使其相互關聯。 

## 資源
<a name="resources"></a>

 **相關文件：** 
+  [Amazon CloudWatch 文件](https://docs.aws.amazon.com/cloudwatch/index.html?ref=wellarchitected) 
+  [使用 CloudWatch Agent 從 Amazon EC2 執行個體和內部部署伺服器收集指標和日誌](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html?ref=wellarchitected) 
+  [存取 Amazon CloudWatch Logs 的 AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-functions-logs.html?ref=wellarchitected) 
+  [搭配容器執行個體使用 CloudWatch Logs](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_cloudwatch_logs.html?ref=wellarchitected) 
+  [發佈自訂指標](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html?ref=wellarchitected) 
+  [AWS Answers：集中式記錄](https://aws.amazon.com/answers/logging/centralized-logging/?ref=wellarchitected) 
+  [發佈 CloudWatch 指標的 AWS 服務](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CW_Support_For_AWS.html?ref=wellarchitected) 
+  [在 AWS Fargate 上監控 Amazon EKS](https://aws.amazon.com/blogs/containers/monitoring-amazon-eks-on-aws-fargate-using-prometheus-and-grafana/) 

 

 **相關影片：** 
+  [AWS 上的應用程式效能管理](https://www.youtube.com/watch?v=5T4stR-HFas&ref=wellarchitected) 
+  [制定監控計劃](https://www.youtube.com/watch?v=OMmiGETJpfU&ref=wellarchitected) 

 

 **相關範例：** 
+  [Level 100：使用 CloudWatch 儀表板進行監控](https://wellarchitectedlabs.com/performance-efficiency/100_labs/100_monitoring_with_cloudwatch_dashboards/) 
+  [Level 100：使用 CloudWatch 儀表板監控 Windows EC2 執行個體](https://wellarchitectedlabs.com/performance-efficiency/100_labs/100_monitoring_windows_ec2_cloudwatch/) 
+  [Level 100：使用 CloudWatch 儀表板監控 Amazon Linux EC2 執行個體](https://wellarchitectedlabs.com/performance-efficiency/100_labs/100_monitoring_linux_ec2_cloudwatch/) 