Monitoring CloudFront Activity Using CloudWatch
Amazon CloudFront integrates with Amazon CloudWatch metrics so that you can monitor your website or application. CloudFront currently provides six free metrics, and these metrics don't count against CloudWatch limits. When viewing metrics, you can specify a time interval of as little as one minute for time periods in the previous two weeks.
You can view the following CloudFront metrics in the CloudWatch console:
Requests – Number of requests for all HTTP methods and for both HTTP and HTTPS requests
BytesDownloaded – Number of bytes downloaded by viewers for
BytesUploaded – Number of bytes uploaded to your origin with CloudFront using
TotalErrorRate – Percentage of all requests for which the HTTP status code is
4xxErrorRate – Percentage of all requests for which the HTTP status code is
5xxErrorRate – Percentage of all requests for which the HTTP status code is
CloudFront is a global service, and metrics are available only when you choose the US East (N. Virginia) region in the AWS console. If you choose another region, no CloudFront metrics will appear in the CloudWatch console.
To view metrics for a distribution in the CloudWatch console
Sign in to the AWS Management Console and open the CloudFront console at https://console.aws.amazon.com/cloudfront/.
In the navigation pane, click Monitoring and Alarms.
In the CloudFront Metrics and Alarms From CloudWatch pane, specify the following values:
- From and To
Select the date and time range for which you want to display CloudWatch metrics.
Specify the interval of the data points, for example, one per minute or one per hour. Note that the time period that you choose affects the available granularity. For example, if you choose to view data for two weeks, the finest granularity is one hour, and if you choose to view data for 24 hours, the finest granularity is one minute.
- Web Distribution
Select the distribution that you want to display metrics for.
Click Update Graph to refresh the graph based on the settings that you specified.
To receive an Amazon Simple Notification Service (Amazon SNS) notification based on a CloudFront metric
On the CloudFront Metrics and Alarms From CloudWatch page, expand the list of existing alarms to confirm that the alarm that you want to create doesn't already exist.
Click Create Alarm.
In the Create Alarm dialog box, specify the following values:
Choose the metric for which you want to create the alarm.
Choose the CloudFront distribution for which you want to create the alarm.
- Name of alarm
Enter a name for the alarm.
- Send notification to
Choose the existing Amazon SNS topic that you want to send notification to if the status of this metric triggers an alarm.
- Whenever metric
Specify when CloudWatch should trigger an alarm and send a notification to the specified email list. For example, to receive notification when the 5xx error rate exceeds 1%, you'd specify the following:
Whenever Average of 5xxErrorRate
Note the following about specifying values for
Enter only 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 you specify is in units, for example, 1000000000 bytes.
- For at least
xconsecutive periods of
Specify how many consecutive time periods of the specified duration the metric must meet the criteria before CloudWatch sends notification. When you choose a value, you need to find an appropriate balance between a value that produces frequent notifications for fleeting problems and delayed notifications for real problems.
If you created a new Amazon SNS topic, when you click Create, Amazon SNS sends you an email with information about the new topic. Follow the instructions in the email.
Downloading Data in CSV Format
You can download the CloudWatch Metrics report in CSV format. This section explains how to download the report and describes the values in the report.
To download the CloudWatch Metrics report in CSV format
While viewing the CloudWatch metrics, click CSV.
In the Opening file name dialog box, choose whether to open or save the file.
Information About the Report
The first few rows of the report include the following information:
The CloudFront reporting version.
The name of the report.
The ID of the distribution that you ran the report for.
The beginning of the date range for which you ran the report, in Coordinated Universal Time (UTC).
The end of the date range for which you ran the report, in Coordinated Universal Time (UTC).
The date and time on which you ran the report, in Coordinated Universal Time (UTC).
The time period for each row in the report, for example, ONE_MINUTE.
Data in the CloudWatch Metrics Report
The report includes the following values:
The ID of the distribution that you ran the report for.
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.
The hour or the day that data applies to, in Coordinated Universal Time (UTC).
The total number of requests for all HTTP status codes (for example, 200 or 404) and all methods (for example, GET, HEAD, or POST) during the time period.
The number of bytes that viewers downloaded for the specified distribution during the time period.
The number of bytes that viewers uploaded to your origin for the specified distribution during the time period.
Requests for which the HTTP status code was a 4xx or 5xx error for the specified distribution during the time period.
Requests for which the HTTP status code was a 4xx error for the specified distribution during the time period.
Requests for which the HTTP status code was a 5xx error for the specified distribution during the time period.