Viewing CloudFront and Lambda@Edge metrics
You can view operational metrics about your CloudFront distributions and Lambda@Edge
functions in the CloudFront console. To view these metrics, see the Monitoring page in the CloudFront
console
Topics
Viewing the default CloudFront distribution metrics
The following default metrics are included for all CloudFront distributions, at no additional cost:
- Requests
-
The total number of viewer requests received by CloudFront, for all HTTP methods and for both HTTP and HTTPS requests.
- Bytes downloaded
-
The total number of bytes downloaded by viewers for
GET
,HEAD
, andOPTIONS
requests. - Bytes uploaded
-
The total number of bytes that viewers uploaded to your origin with CloudFront, using
POST
andPUT
requests. - 4xx error rate
-
The percentage of all viewer requests for which the response’s HTTP status code is
4xx
. - 5xx error rate
-
The percentage of all viewer requests for which the response’s HTTP status code is
5xx
. - Total error rate
-
The percentage of all viewer requests for which the response’s HTTP status code is
4xx
or5xx
.
These metrics are shown in graphs for each CloudFront distribution on the Monitoring
page in the CloudFront console
You can customize the graphs by doing the following:
-
To change the time range for the information displayed in the graphs, choose 1h (1 hour), 3h (3 hours), or another range, or specify a custom range.
-
To change how often CloudFront updates the information in the graph, choose the down arrow next to the refresh icon, and then choose a refresh rate. The default refresh rate is 1 minute, but you can choose 10 seconds, 2 minutes, or other options.
To view CloudFront graphs in the CloudWatch console, choose Add to dashboard.
Viewing additional CloudFront distribution metrics
In addition to the default metrics, you can enable additional metrics for an additional cost. For more information about the cost, see Estimating cost for the additional CloudFront metrics.
These additional metrics must be enabled for each distribution separately:
- Cache hit rate
-
The percentage of all cacheable requests for which CloudFront served the content from its cache. HTTP
POST
andPUT
requests, and errors, are not considered cacheable requests. - Origin latency
-
The total time spent from when CloudFront receives a request to when it starts providing a response to the network (not the viewer), for requests that are served from the origin, not the CloudFront cache. This is also known as first byte latency, or time-to-first-byte.
- Error rate by status code
-
The percentage of all viewer requests for which the response’s HTTP status code is a particular code in the
4xx
or5xx
range. This metric is available for all of the following error codes:401
,403
,404
,502
,503
, and504
.
Enabling additional metrics
You can enable additional metrics in the CloudFront console, with the AWS Command Line Interface (AWS CLI), or with the CloudFront API.
To enable additional metrics
-
Sign in to the AWS Management Console and open the Monitoring page in the CloudFront console
. -
Choose the distribution to enable additional metrics for, and then choose View distribution metrics.
-
Choose Enable additional metrics.
-
In the Enable additional metrics window, choose Enable, and then choose Save.
After you enable the additional metrics, they are shown in graphs. On each graph, the totals are displayed at 1-minute granularity. In addition to viewing the graphs, you can also download metrics reports as CSV files.
You can customize the graphs by doing the following:
-
To change the time range for the information displayed in the graphs, choose 1h (1 hour), 3h (3 hours), or another range, or specify a custom range.
-
To change how often CloudFront updates the information in the graph, choose the down arrow next to the refresh icon, and then choose a refresh rate. The default refresh rate is 1 minute, but you can choose 10 seconds, 2 minutes, or other options.
To view CloudFront graphs in the CloudWatch console, choose Add to dashboard.
To manage additional metrics with the AWS Command Line Interface (AWS CLI), use one of the following commands.
To enable additional metrics for a distribution
-
Use the create-monitoring-subscription command, as in the following example. Replace
EDFDVBD6EXAMPLE
with the ID of the distribution that you are enabling additional metrics for.aws cloudfront create-monitoring-subscription --distribution-id
EDFDVBD6EXAMPLE
--monitoring-subscription RealtimeMetricsSubscriptionConfig={RealtimeMetricsSubscriptionStatus=Enabled}
To see whether additional metrics are enabled for a distribution
-
Use the get-monitoring-subscription command, as in the following example. Replace
EDFDVBD6EXAMPLE
with the ID of the distribution that you are checking.aws cloudfront get-monitoring-subscription --distribution-id
EDFDVBD6EXAMPLE
To disable additional metrics for a distribution
-
Use the delete-monitoring-subscription command, as in the following example. Replace
EDFDVBD6EXAMPLE
with the ID of the distribution that you are disabling additional metrics for.aws cloudfront delete-monitoring-subscription --distribution-id
EDFDVBD6EXAMPLE
To manage additional metrics with the CloudFront API, use one of the following API operations.
-
To enable additional metrics for a distribution, use CreateMonitoringSubscription.
-
To see whether additional metrics are enabled for a distribution, use GetMonitoringSubscription.
-
To disable additional metrics for a distribution, use DeleteMonitoringSubscription.
For more information about these API calls, see the API reference documentation for your AWS SDK or other API client.
Estimating cost for the additional CloudFront metrics
When you enable additional metrics for a distribution, CloudFront sends up to 8 metrics to CloudWatch
in the US East (N. Virginia) Region. CloudWatch charges a low, fixed rate for each metric. This rate
is charged only once per month, per metric (up to 8 metrics per distribution).
This is a fixed rate, so your cost remains the same regardless of the number of
requests or responses that the CloudFront distribution receives or sends. For the
per-metric rate, see the Amazon CloudWatch pricing page
Viewing the default Lambda@Edge function metrics
The following default metrics are shown in graphs for each Lambda@Edge function on the
Monitoring page in the CloudFront console
-
5xx
error rate for Lambda@Edge -
Lambda execution errors
-
Lambda invalid responses
-
Lambda throttles
The graphs include the number of invocations, errors, throttles, and so on. On each graph, the totals are displayed at 1-minute granularity, grouped by AWS Region.
If you see a spike in errors that you want to investigate, you can choose a function and then view log files by AWS Region, until you determine which function is causing the problems and in which AWS Region. For more information about troubleshooting Lambda@Edge errors, see:
You can customize the graphs by doing the following:
-
To change the time range for the information displayed in the graphs, choose 1h (1 hour), 3h (3 hours), or another range, or specify a custom range.
-
To change how often CloudFront updates the information in the graph, choose the down arrow next to the refresh icon, and then choose a refresh rate. The default refresh rate is 1 minute, but you can choose 10 seconds, 2 minutes, or other options.
To view the graphs in the CloudWatch console, choose Add to dashboard. You must use the US East (N. Virginia) Region (us-east-1) to view the graphs in the CloudWatch console.