View CloudFront and edge function metrics
You can view operational metrics about your CloudFront distributions and edge functions
To view CloudFront and edge function metrics in CloudFront
Sign in to the AWS Management Console and open the CloudFront console at https://console.aws.amazon.com/cloudfront/v4/home
. -
In the navigation pane, choose Monitoring.
-
To view graphs about the activity for a specific CloudFront distribution or edge function, choose one, and then choose View distribution metrics or View metrics.
-
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 other options.
-
-
To view CloudFront graphs in the CloudWatch console, choose Add to dashboard. You must use the US East (N. Virginia) Region to view the graphs in the CloudWatch console.
Topics
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 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 of the CloudFront console.. 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.
Turn on additional CloudFront distribution metrics
In addition to the default metrics, you can turn on additional metrics for an additional cost. For more information about the cost, see Estimate the cost for the additional CloudFront metrics.
These additional metrics must be turned on 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
.
You can turn on additional metrics in the CloudFront console, with AWS CloudFormation, with the AWS Command Line Interface (AWS CLI), or with the CloudFront API.
Estimate the cost for the additional CloudFront metrics
When you turn on 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
Default Lambda@Edge function metrics
You can use CloudWatch metrics to monitor, in real time, problems with your Lambda@Edge functions. There's no additional charge for these metrics.
When you attach a Lambda@Edge function to a cache behavior in a CloudFront distribution,
Lambda begins sending metrics to CloudWatch automatically. Metrics are available for all
Lambda Regions, but to view metrics in the CloudWatch console or get the metric data from
the CloudWatch API, you must use the US East (N. Virginia) Region (us-east-1
). The metric
group name is formatted as:
AWS/CloudFront/
,
where distribution-ID
distribution-ID
is the ID of the CloudFront distribution
that the Lambda@Edge function is associated with. For more information about CloudWatch
metrics, see the Amazon CloudWatch User Guide.
The following default metrics are shown in graphs for each Lambda@Edge function on the Monitoring page of 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:
Default CloudFront Functions metrics
CloudFront Functions sends operational metrics to Amazon CloudWatch so that you can monitor your functions. Viewing these metrics can help you troubleshoot, track, and debug issues. CloudFront Functions publishes the following metrics to CloudWatch:
-
Invocations (
FunctionInvocations
) – The number of times the function was started (invoked) in a given time period. -
Validation errors (
FunctionValidationErrors
) – The number of validation errors produced by the function in a given time period. Validation errors occur when the function runs successfully but returns invalid data (an invalid event object). -
Execution errors (
FunctionExecutionErrors
) – The number of execution errors that occurred in a given time period. Execution errors occur when the function fails to complete successfully. -
Compute utilization (
FunctionComputeUtilization
) – The amount of time that the function took to run as a percentage of the maximum allowed time. For example, a value of 35 means that the function completed in 35% of the maximum allowed time. This metric is a number between 0 and 100.If this value reaches or is near 100, the function has used or is close to using the allowed execution time and subsequent requests might be throttled. If your function is running at 80% or more utilization, we recommend that you review your function to reduce the execution time and improve utilization. For example, you might want to only log errors, simplify any complex regex expressions, or remove unnecessary parsing of complex JSON objects.
-
Throttles (
FunctionThrottles
) – The number of times that the function was throttled in a given time period. Functions can be throttled for the following reasons:-
The function continuously exceeds the maximum time allowed for execution
-
The function results in compilation errors
-
There is an unusually high number of requests per second
-
CloudFront KeyValueStore also sends the following operational metrics to Amazon CloudWatch:
-
Read requests (
KvsReadRequests
) – The number of times the function successfully read from the key value store within a given time period. -
Read errors (
KvsReadErrors
) – The number of times the function failed to read from the key value store within a given time period.
All of these metrics are published to CloudWatch in the US East (N. Virginia) Region
(us-east-1
), in the CloudFront namespace. You can also view these metrics
in the CloudWatch console. In the CloudWatch console, you can view the metrics per function or
per function per distribution.
You can also use CloudWatch to set alarms based on these metrics. For example, you can
set an alarm based on the execution time (FunctionComputeUilization
)
metric, which represents the percentage of available time that your function took to
run. When the execution time reaches a certain value for a certain amount of time.
For example, if you choose greater than 70% of available time for 15
continuous minutes, the alarm is triggered. You specify the alarms value and its
time unit when you create the alarm.
Note
CloudFront Functions sends metrics to CloudWatch only for functions in the
LIVE
stage that run in response to production requests and
responses. When you test a function, CloudFront
doesn't send any metrics to CloudWatch. The test output contains information about
errors, compute utilization, and function logs (console.log()
statements), but this information isn't sent to CloudWatch.
For information about how to get these metrics with the CloudWatch API, see Get metrics by using the Amazon CloudWatch API.