

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 集中日誌
<a name="centralizing-logs"></a>

 記錄是找出並解決問題的關鍵。透過微服務，您可以更頻繁地發佈並試驗新功能。 AWS 提供 Amazon S3、 CloudWatch Logs 和 Amazon OpenSearch Service 等服務來集中化日誌檔案。Amazon EC2 使用協助程式將日誌傳送至 CloudWatch，而 Lambda 和 Amazon ECS 則會在那裡原生傳送其日誌輸出。對於 Amazon EKS，[Fluent Bit 或 Fluentd 可用於](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Container-Insights-EKS-logs.html)將日誌轉送至 CloudWatch，以使用 OpenSearch 和 Kibana 進行報告。不過，由於佔用空間 和[效能優勢](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Container-Insights-EKS-logs.html)較小，建議使用 Fluent Bit 而非 Fluentd。

 圖 12 說明如何將各種 AWS 服務的日誌導向 Amazon S3 和 CloudWatch。這些集中式日誌可以使用 Amazon OpenSearch Service 進一步分析，包括用於資料視覺化的 Kibana。此外，Amazon Athena 可用於針對存放在 Amazon S3 中的日誌進行臨機操作查詢。

![\[顯示 AWS 服務記錄功能的圖表\]](http://docs.aws.amazon.com/zh_tw/whitepapers/latest/microservices-on-aws/images/logging-capabilities.png)
