I want to use Amazon CloudFront logs, usage reports, and metrics for CloudFront distribution performance and cost optimization.
Resolution
CloudFront standard logs and real-time logs
You can use standard log files or real-time logs to log the requests that come to your Amazon CloudFront distributions. To query the CloudFront logs, you can use Amazon Athena.
Standard log files include detailed information for user requests to your CloudFront distributions. CloudFront sends the standard log files to an Amazon Simple Storage Service (Amazon S3) bucket for you to troubleshoot and analyze.
Use real-time logs to get detailed request information in real time. CloudFront delivers the real-time logs to a data stream in Amazon Kinesis Data Streams.
To use standard log files or real-time logs, see How do I turn on logging for my CloudFront distribution?
CloudFront usage reports
The CloudFront console provides built-in usage reports and charts for single or multiple distributions.
You can view the following reports on the CloudFront console, or download the data in CSV format:
You can also view AWS billing and usage reports for CloudFront on the AWS Billing and Cost Management console. For information about how to analyze your billing and usage reports, see Interpret your AWS bill and usage reports for CloudFront.
CloudFront metrics
Amazon CloudWatch automatically publishes metrics for CloudFront distributions and edge functions. Use the CloudFront console to view distribution and edge function metrics or download metrics data in CSV format to troubleshoot, monitor, and debug issues. For more information, see Monitor CloudFront metrics with Amazon CloudWatch.
To monitor and troubleshoot performance, you can also create CloudWatch alarms to receive notifications when metrics exceed predefined thresholds. For example, you can use the TotalErrorRate metric to get the percentage of all viewer requests with an HTTP 4## or 5## status code response. For more information, see Values for CloudFront distribution metrics.