

# Monitor CloudFront metrics with Amazon CloudWatch
<a name="monitoring-using-cloudwatch"></a>

Amazon CloudFront is integrated with Amazon CloudWatch and automatically publishes operational metrics for distributions and edge functions (both [Lambda@Edge and CloudFront Functions](edge-functions.md)). You can use these metrics to troubleshoot, track, and debug issues. Many of these metrics are displayed in a set of graphs in the CloudFront console, and are also accessible by using the CloudFront API or CLI. All of these metrics are available in the [CloudWatch console](https://console.aws.amazon.com/cloudwatch/home) or through the CloudWatch API or CLI. CloudFront metrics don't count against [CloudWatch quotas (formerly known as limits)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_limits.html) and don't incur any additional cost.

In addition to the default metrics for CloudFront distributions, you can turn on additional metrics for an additional cost. The additional metrics apply to CloudFront distributions, and must be turned on for each distribution separately. For more information about the cost, see [Estimate the cost for the additional CloudFront metrics](viewing-cloudfront-metrics.md#monitoring-console.distributions-additional-pricing).





You can also set alarms based on these metrics in the CloudFront console, or in the CloudWatch console, API, or CLI. For example, you can set an alarm based on the `5xxErrorRate` metric, which represents the percentage of all viewer requests for which the response's HTTP status code is in the range of `500` to `599`, inclusive. When the error rate reaches a certain value for a certain amount of time, for example, 5% of requests for 5 continuous minutes, the alarm is triggered. You specify the alarm's value and its time unit when you create the alarm. 

**Notes**  
When you create a CloudWatch alarm in the CloudFront console, it creates one for you in the US East (N. Virginia) Region (`us-east-1`). If you create an alarm from the CloudWatch console, you must use the same Region. Because CloudFront is a global service, metrics for the service are sent to US East (N. Virginia).
When creating alarms, [standard CloudWatch pricing](https://aws.amazon.com/cloudwatch/pricing/) applies.

**Topics**
+ [

# View CloudFront and edge function metrics
](viewing-cloudfront-metrics.md)
+ [

# Create alarms for metrics
](receiving-notifications.md)
+ [

# Download metrics data in CSV format
](cloudwatch-csv.md)
+ [

# Types of metrics for CloudFront
](programming-cloudwatch-metrics.md)

# View CloudFront and edge function metrics
<a name="viewing-cloudfront-metrics"></a>

You can view operational metrics about your CloudFront distributions and [edge functions](https://aws.amazon.com/cloudfront/features/#Edge_Computing) in the CloudFront console. 

**To view CloudFront and edge function metrics in CloudFront**

1. Sign in to the AWS Management Console and open the CloudFront console at [https://console.aws.amazon.com/cloudfront/v4/home](https://console.aws.amazon.com/cloudfront/v4/home).

1. In the navigation pane, choose **Monitoring**.

1. 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**.

1. You can customize the graphs by doing the following:

   1. 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. 

   1. 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.

1. 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
](#monitoring-console.distributions)
+ [

## Turn on additional CloudFront distribution metrics
](#monitoring-console.distributions-additional)
+ [

## Default Lambda@Edge function metrics
](#monitoring-console.lambda-at-edge)
+ [

## Default CloudFront Functions metrics
](#monitoring-console.cloudfront-functions)

## Default CloudFront distribution metrics
<a name="monitoring-console.distributions"></a>

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` and `HEAD` requests.

**Bytes uploaded**  
The total number of bytes that viewers uploaded to CloudFront, using `OPTIONS`, `POST` and `PUT` 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` or `5xx`.

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](cloudwatch-csv.md).

## Turn on additional CloudFront distribution metrics
<a name="monitoring-console.distributions-additional"></a>

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](#monitoring-console.distributions-additional-pricing).

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` and `PUT` 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` or `5xx` range. This metric is available for all of the following error codes: `401`, `403`, `404`, `502`, `503`, and `504`.

You can turn on additional metrics in the CloudFront console, with CloudFormation, with the AWS Command Line Interface (AWS CLI), or with the CloudFront API.

------
#### [ Console ]

**To turn on additional metrics**

1. Sign in to the AWS Management Console and open the CloudFront console at [https://console.aws.amazon.com/cloudfront/v4/home](https://console.aws.amazon.com/cloudfront/v4/home).

1. In the navigation pane, choose **Monitoring**.

1. Choose the distribution to turn on additional metrics for, and then choose **View distribution metrics**.

1. Choose **Manage additional metrics**.

1. In the **Manage additional metrics** window, turn on **Enabled**. After you turn on the additional metrics, you can close the **Manage additional metrics** window.

   After you turn on 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](cloudwatch-csv.md).

------
#### [ CloudFormation ]

To turn on additional metrics with CloudFormation, use the `AWS::CloudFront::MonitoringSubscription` resource type. The following example shows the CloudFormation template syntax, in YAML format, for enabling additional metrics.

```
Type: AWS::CloudFront::MonitoringSubscription
Properties: 
  DistributionId: EDFDVBD6EXAMPLE
  MonitoringSubscription:
    RealtimeMetricsSubscriptionConfig:
      RealtimeMetricsSubscriptionStatus: Enabled
```

------
#### [ CLI ]

To manage additional metrics with the AWS Command Line Interface (AWS CLI), use one of the following commands:

**To turn on 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're enabling additional metrics for.

  ```
  aws cloudfront create-monitoring-subscription --distribution-id EDFDVBD6EXAMPLE --monitoring-subscription RealtimeMetricsSubscriptionConfig={RealtimeMetricsSubscriptionStatus=Enabled}
  ```

**To see whether additional metrics are turned on for a distribution**
+ Use the **get-monitoring-subscription** command, as in the following example. Replace *EDFDVBD6EXAMPLE* with the ID of the distribution that you're checking.

  ```
  aws cloudfront get-monitoring-subscription --distribution-id EDFDVBD6EXAMPLE
  ```

**To turn off 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're turning off additional metrics for.

  ```
  aws cloudfront delete-monitoring-subscription --distribution-id EDFDVBD6EXAMPLE
  ```

------
#### [ API ]

To manage additional metrics with the CloudFront API, use one of the following API operations.
+ To turn on additional metrics for a distribution, use [CreateMonitoringSubscription](https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CreateMonitoringSubscription.html).
+ To see whether additional metrics are turned on for a distribution, use [GetMonitoringSubscription](https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_GetMonitoringSubscription.html).
+ To turn off additional metrics for a distribution, use [DeleteMonitoringSubscription](https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_DeleteMonitoringSubscription.html).

For more information about these API operations, see the API reference documentation for your AWS SDK or other API client.

------

### Estimate the cost for the additional CloudFront metrics
<a name="monitoring-console.distributions-additional-pricing"></a>

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](https://aws.amazon.com/cloudwatch/pricing/) and the [CloudWatch pricing calculator](https://aws.amazon.com/cloudwatch/pricing/#Pricing_calculator). Additional API charges apply when you retrieve the metrics with the CloudWatch API.

## Default Lambda@Edge function metrics
<a name="monitoring-console.lambda-at-edge"></a>

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/distribution-ID`, where *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](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/).

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:
+ [How to determine the type of failure](lambda-edge-testing-debugging.md#lambda-edge-testing-debugging-failure-type)
+ [Four Steps for Debugging your Content Delivery on AWS](https://aws.amazon.com/blogs/networking-and-content-delivery/four-steps-for-debugging-your-content-delivery-on-aws/)

## Default CloudFront Functions metrics
<a name="monitoring-console.cloudfront-functions"></a>

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](functions-event-structure.md)).
+ **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 (`FunctionComputeUtilization`) 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](test-function.md), 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 [Types of metrics for CloudFront](programming-cloudwatch-metrics.md).

# Create alarms for metrics
<a name="receiving-notifications"></a>

In the CloudFront console, you can set alarms to notify you by Amazon Simple Notification Service (Amazon SNS) based on specific CloudFront metrics.

**To create alarms for metrics**

1. Sign in to the AWS Management Console and open the CloudFront console at [https://console.aws.amazon.com/cloudfront/v4/home](https://console.aws.amazon.com/cloudfront/v4/home).

1. In the navigation pane, choose **Alarms**.

1. Choose **Create alarm**.

1. For **Details**, specify the following: 

   1. **Alarm name** – A name for the alarm.

   1. **Distribution** – The CloudFront distribution that you're creating the alarm for.

1. For **Condition**, specify the following:

   1. **Metric** – The metric that you're creating the alarm for.

   1. **"IF" <condition>** – The threshold when CloudWatch should trigger an alarm and send a notification to the Amazon SNS topic. For example, to receive a notification when the `5xx` error rate exceeds 1%, specify the following:

      **5xx error rate** **> 1**

   1. **"FOR" consecutive periods** – The period of time that the condition must be met before triggering an alarm. When you choose a value, aim for an appropriate balance between a value that doesn't alarm for temporary problems, but will alarm for sustained or real problems.

   1. (Optional) **Notify** – The Amazon SNS topic to send notification to if this metric triggers an alarm.

1. Choose **Create alarm**.

**Notes**  
When you enter the values for the condition, use whole numbers without punctuation. For example, to specify one thousand, enter **1000**.
For `4xx`, `5xx`, and total error rates, the value that you specify is a percentage.
For requests, bytes downloaded, and bytes uploaded, the value that you specify is units. For example, 1073742000 bytes.

For more information about creating Amazon SNS topics, see [Creating an Amazon SNS topic](https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html) in the *Amazon Simple Notification Service Developer Guide*.

# Download metrics data in CSV format
<a name="cloudwatch-csv"></a>

You can download the CloudWatch metrics data for a CloudFront distribution in CSV format. 

**To download metrics data in CSV format**

1. Sign in to the AWS Management Console and open the CloudFront console at [https://console.aws.amazon.com/cloudfront/v4/home](https://console.aws.amazon.com/cloudfront/v4/home).

1. In the navigation pane, choose **Monitoring**.

1. Choose the distribution and then choose **View distribution metrics**.

1. Choose **Download CSV** and then choose the time period (for example, **For last 1 day (1 hour period)**.

1. After your file downloads, open it to view the following information.

**Topics**
+ [

## Information about the report
](#cloudwatch-csv-header)
+ [

## Data in the metrics report
](#cloudwatch-csv-data)

## Information about the report
<a name="cloudwatch-csv-header"></a>

The first few rows of the report include the following information:

**Version**  
The CloudFront reporting version.

**Report**  
The name of the report.

**DistributionID**  
The ID of the distribution for which you ran the report.

**StartDateUTC**  
The beginning of the date range for which you ran the report, in Coordinated Universal Time (UTC).

**EndDateUTC**  
The end of the date range for which you ran the report, in Coordinated Universal Time (UTC).

**GeneratedTimeUTC**  
The date and time on which you ran the report, in Coordinated Universal Time (UTC).

**Granularity**  
The time period for each row in the report, for example, `ONE_MINUTE`.

## Data in the metrics report
<a name="cloudwatch-csv-data"></a>

The report includes the following values:

**DistributionID**  
The ID of the distribution for which you ran the report.

**FriendlyName**  
An alternate domain name (CNAME) for the distribution, if any. If a distribution has no alternate domain names, the list includes an origin domain name for the distribution.

**TimeBucket**  
The hour or the day that the data applies to, in Coordinated Universal Time (UTC).

**Requests**  
The total number of requests for all HTTP status codes (for example, `200`, `404`, and so on) and all methods (for example, `GET`, `HEAD`, `POST`, and so on) during the time period.

**BytesDownloaded**  
The number of bytes that viewers downloaded for the specified distribution during the time period.

**BytesUploaded**  
The number of bytes that viewers uploaded for the specified distribution during the time period.

**TotalErrorRatePct**  
The percentage of requests for which the HTTP status code was a `4xx` or `5xx` error for the specified distribution during the time period.

**4xxErrorRatePct**  
The percentage of requests for which the HTTP status code was a `4xx` error for the specified distribution during the time period.

**5xxErrorRatePct**  
The percentage of requests for which the HTTP status code was a `5xx` error for the specified distribution during the time period.

If you have [turned on additional metrics](viewing-cloudfront-metrics.md#monitoring-console.distributions-additional) for your distribution, then the report also includes the following additional values:

**401ErrorRatePct**  
The percentage of requests for which the HTTP status code was a `401` error for the specified distribution during the time period.

**403ErrorRatePct**  
The percentage of requests for which the HTTP status code was a `403` error for the specified distribution during the time period.

**404ErrorRatePct**  
The percentage of requests for which the HTTP status code was a `404` error for the specified distribution during the time period.

**502ErrorRatePct**  
The percentage of requests for which the HTTP status code was a `502` error for the specified distribution during the time period.

**503ErrorRatePct**  
The percentage of requests for which the HTTP status code was a `503` error for the specified distribution during the time period.

**504ErrorRatePct**  
The percentage of requests for which the HTTP status code was a `504` error for the specified distribution during the time period.

**OriginLatency**  
The total time spent, in milliseconds, from when CloudFront received a request to when it started providing a response to the network (not the viewer), for requests that were served from the origin, not the CloudFront cache. This is also known as *first byte latency*, or *time-to-first-byte*.

**CacheHitRate**  
The percentage of all cacheable requests for which CloudFront served the content from its cache. HTTP `POST` and `PUT` requests, and errors, are not considered cacheable requests.

# Types of metrics for CloudFront
<a name="programming-cloudwatch-metrics"></a>

You can use the CloudWatch API or AWS Command Line Interface (AWS CLI) to get the CloudFront metrics in programs or applications that you build. You can use the raw data to build your own custom dashboards, your own alarming tools, and so on. 

For more information, see [get-metric-data](https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/get-metric-data.html) in the *AWS CLI Command Reference* or the [GetMetricData](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html) API operation in the *Amazon CloudWatch API Reference*.

**Topics**
+ [

## Values for all CloudFront metrics
](#cloudfront-metrics-global-values)
+ [

## Values for CloudFront distribution metrics
](#cloudfront-metrics-distribution-values)
+ [

## Values for CloudFront function metrics
](#cloudfront-metrics-function-values)

**Note**  
To get the CloudFront metrics from the CloudWatch API, you must use the US East (N. Virginia) Region (`us-east-1`). You also need to know certain values and types for each metric.

## Values for all CloudFront metrics
<a name="cloudfront-metrics-global-values"></a>

The following values apply to all CloudFront metrics:

**`Namespace`**  
The value for `Namespace` is always `AWS/CloudFront`.

**Dimensions**  
Each CloudFront metric has the following dimensions:    
**`DistributionId`**  
The ID of the CloudFront distribution for which you want to get metrics.  
**`FunctionName`**  
The name of the function (in CloudFront Functions) for which you want to get metrics.  
This dimension applies only to functions.  
**`Region`**  
The value for `Region` is always `Global`, because CloudFront is a global service.

## Values for CloudFront distribution metrics
<a name="cloudfront-metrics-distribution-values"></a>

Use information from the following list to get details about specific CloudFront distribution metrics from the CloudWatch API. Some of these metrics are available only when you have turned on additional metrics for the distribution.

**Note**  
Only one statistic, `Average` or `Sum`, is applicable for each metric. The following list specifies which statistic is applicable to that metric.

**4xx error rate**  
The percentage of all viewer requests for which the response's HTTP status code is `4xx`.  
+ Metric name: `4xxErrorRate`
+ Valid statistic: `Average`
+ Unit: `Percent`

**401 error rate**  
The percentage of all viewer requests for which the response's HTTP status code is `401`. To get this metric, you must first [turn on additional metrics](viewing-cloudfront-metrics.md#monitoring-console.distributions-additional).  
+ Metric name: `401ErrorRate`
+ Valid statistic: `Average`
+ Unit: `Percent`

**403 error rate**  
The percentage of all viewer requests for which the response's HTTP status code is `403`. To get this metric, you must first [turn on additional metrics](viewing-cloudfront-metrics.md#monitoring-console.distributions-additional).  
+ Metric name: `403ErrorRate`
+ Valid statistic: `Average`
+ Unit: `Percent`

**404 error rate**  
The percentage of all viewer requests for which the response's HTTP status code is `404`. To get this metric, you must first [turn on additional metrics](viewing-cloudfront-metrics.md#monitoring-console.distributions-additional).  
+ Metric name: `404ErrorRate`
+ Valid statistic: `Average`
+ Unit: `Percent`

**5xx error rate**  
The percentage of all viewer requests for which the response's HTTP status code is `5xx`.  
+ Metric name: `5xxErrorRate`
+ Valid statistic: `Average`
+ Unit: `Percent`

**502 error rate**  
The percentage of all viewer requests for which the response's HTTP status code is `502`. To get this metric, you must first [turn on additional metrics](viewing-cloudfront-metrics.md#monitoring-console.distributions-additional).  
+ Metric name: `502ErrorRate`
+ Valid statistic: `Average`
+ Unit: `Percent`

**503 error rate**  
The percentage of all viewer requests for which the response's HTTP status code is `503`. To get this metric, you must first [turn on additional metrics](viewing-cloudfront-metrics.md#monitoring-console.distributions-additional).  
+ Metric name: `503ErrorRate`
+ Valid statistic: `Average`
+ Unit: `Percent`

**504 error rate**  
The percentage of all viewer requests for which the response's HTTP status code is `504`. To get this metric, you must first [turn on additional metrics](viewing-cloudfront-metrics.md#monitoring-console.distributions-additional).  
+ Metric name: `504ErrorRate`
+ Valid statistic: `Average`
+ Unit: `Percent`

**Bytes downloaded**  
The total number of bytes downloaded by viewers for `GET` and `HEAD` requests.  
+ Metric name: `BytesDownloaded`
+ Valid statistic: `Sum`
+ Unit: `None`

**Bytes uploaded**  
The total number of bytes that viewers uploaded to CloudFront, using `OPTIONS`, `POST` and `PUT` requests.  
+ Metric name: `BytesUploaded`
+ Valid statistic: `Sum`
+ Unit: `None`

**Cache hit rate**  
The percentage of all cacheable requests for which CloudFront served the content from its cache. HTTP `POST` and `PUT` requests, and errors, are not considered cacheable requests. To get this metric, you must first [turn on additional metrics](viewing-cloudfront-metrics.md#monitoring-console.distributions-additional).  
+ Metric name: `CacheHitRate`
+ Valid statistic: `Average`
+ Unit: `Percent`

**Origin latency**  
The total time spent, in milliseconds, 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*. To get this metric, you must first [turn on additional metrics](viewing-cloudfront-metrics.md#monitoring-console.distributions-additional).  
+ Metric name: `OriginLatency`
+ Valid statistic: `Percentile`
+ Unit: `Milliseconds`
To get a `Percentile` statistic from the CloudWatch API, use the `ExtendedStatistics` parameter, not `Statistics`. For more information, see [GetMetricStatistics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html) in the *Amazon CloudWatch API Reference*, or the reference documentation for the [AWS SDKs](https://docs.aws.amazon.com/#sdks).

**Requests**  
The total number of viewer requests received by CloudFront, for all HTTP methods and for both HTTP and HTTPS requests.  
+ Metric name: `Requests`
+ Valid statistic: `Sum`
+ Unit: `None`

**Total error rate**  
The percentage of all viewer requests for which the response's HTTP status code is `4xx` or `5xx`.  
+ Metric name: `TotalErrorRate`
+ Valid statistic: `Average`
+ Unit: `Percent`

## Values for CloudFront function metrics
<a name="cloudfront-metrics-function-values"></a>

Use information from the following list to get details about specific CloudFront function metrics from the CloudWatch API.

**Note**  
Only one statistic, `Average` or `Sum`, is applicable for each metric. The following list specifies which statistic is applicable to that metric.

**Invocations**  
The number of times the function was started (invoked) in a given time period.  
+ Metric name: `FunctionInvocations`
+ Valid statistic: `Sum`
+ Unit: `None`

**Validation errors**  
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).  
+ Metric name: `FunctionValidationErrors`
+ Valid statistic: `Sum`
+ Unit: `None`

**Execution errors**  
The number of execution errors that occurred in a given time period. Execution errors occur when the function fails to complete successfully.  
+ Metric name: `FunctionExecutionErrors`
+ Valid statistic: `Sum`
+ Unit: `None`

**Compute utilization**  
The amount of time (0-100) 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.  
+ Metric name: `FunctionComputeUtilization`
+ Valid statistic: `Average`
+ Unit: `Percent`

**Throttles**  
The number of times that the function was throttled in a given time period.  
+ Metric name: `FunctionThrottles`
+ Valid statistic: `Sum`
+ Unit: `None`