Use real-time access logs
With CloudFront real-time access logs, you can get information about requests made to a distribution in real time (logs are delivered within seconds of receiving the requests). You can use real-time access logs to monitor, analyze, and take action based on content delivery performance.
CloudFront real-time access logs are configurable. You can choose:
-
The sampling rate for your real-time logs—that is, the percentage of requests for which you want to receive real-time access log records.
-
The specific fields that you want to receive in the log records.
-
The specific cache behaviors (path patterns) that you want to receive real-time logs for.
CloudFront real-time access logs are delivered to the data stream of your choice in Amazon Kinesis Data Streams. You can build your own Kinesis data stream consumer, or use Amazon Data Firehose to send the log data to Amazon Simple Storage Service (Amazon S3), Amazon Redshift, Amazon OpenSearch Service (OpenSearch Service), or a third-party log processing service.
CloudFront charges for real-time access logs, in addition to the charges you incur for using Kinesis Data Streams. For
more information about pricing, see Amazon
CloudFront Pricing
Important
We recommend that you use the logs to understand the nature of the requests for your content, not as a complete accounting of all requests. CloudFront delivers real-time access logs on a best-effort basis. The log entry for a particular request might be delivered long after the request was actually processed and, in rare cases, a log entry might not be delivered at all. When a log entry is omitted from real-time access logs, the number of entries in the real-time access logs won't match the usage that appears in the AWS billing and usage reports.
Topics
Create and use real-time access log configurations
To get information about requests made to a distribution in real time. you can use a real-time access log configurations. Logs are delivered within seconds of receiving the requests. You can create a real-time access log configuration in the CloudFront console, with the AWS Command Line Interface (AWS CLI), or with the CloudFront API.
To use a real-time access log configuration, you attach it to one or more cache behaviors in a CloudFront distribution.
Understand real-time access log configurations
To use CloudFront real-time access logs, you start by creating a real-time access log configuration. The real-time access log configuration contains information about which log fields you want to receive, the sampling rate for log records, and the Kinesis data stream where you want to deliver the logs.
Specifically, a real-time access log configuration contains the following settings:
Name
A name to identify the real-time access log configuration.
Sampling rate
The sampling rate is a whole number between 1 and 100 (inclusive) that determines the percentage of viewer requests that are sent to Kinesis Data Streams as real-time access log records. To include every viewer request in your real-time access logs, specify 100 for the sampling rate. You might choose a lower sampling rate to reduce costs while still receiving a representative sample of request data in your real-time access logs.
Fields
A list of the fields that are included in each real-time access log record. Each log record can contain up to 40 fields, and you can choose to receive all of the available fields, or only the fields that you need for monitoring and analyzing performance.
The following list contains each field name and a description of the information in that field. The fields are listed in the order in which they appear in the log records that are delivered to Kinesis Data Streams.
Fields 46-63 are common media client data (CMCD) that media player clients can send to CDNs with each request. You can use this data to understand each request, such as the media type (audio, video), playback rate, and streaming length. These fields will only appear in your real-time access logs if they're sent to CloudFront.
-
timestampThe date and time at which the edge server finished responding to the request.
-
c-ipThe IP address of the viewer that made the request, for example,
192.0.2.183or2001:0db8:85a3::8a2e:0370:7334. If the viewer used an HTTP proxy or a load balancer to send the request, the value of this field is the IP address of the proxy or load balancer. See also thex-forwarded-forfield. -
s-ipThe IP address of the CloudFront server that served the request, for example,
192.0.2.183or2001:0db8:85a3::8a2e:0370:7334. -
time-to-first-byteThe number of seconds between receiving the request and writing the first byte of the response, as measured on the server.
-
sc-statusThe HTTP status code of the server's response (for example,
200). -
sc-bytesThe total number of bytes that the server sent to the viewer in response to the request, including headers. For WebSocket and gRPC connections, this is the total number of bytes sent from the server to the client through the connection.
-
cs-methodThe HTTP request method received from the viewer.
-
cs-protocolThe protocol of the viewer request (
http,https,grpcs,ws, orwss). -
cs-hostThe value that the viewer included in the
Hostheader of the request. If you're using the CloudFront domain name in your object URLs (such as d111111abcdef8.cloudfront.net), this field contains that domain name. If you're using alternate domain names (CNAMEs) in your object URLs (such as www.example.com), this field contains the alternate domain name. -
cs-uri-stemThe entire request URL, including the query string (if one exists), but without the domain name. For example,
/images/cat.jpg?mobile=true.Note
In standard logs, the
cs-uri-stemvalue doesn't include the query string. -
cs-bytesThe total number of bytes of data that the viewer included in the request, including headers. For WebSocket and gRPC connections, this is the total number of bytes sent from the client to the server on the connection.
-
x-edge-locationThe edge location that served the request. Each edge location is identified by a three-letter code and an arbitrarily assigned number (for example, DFW3). The three-letter code typically corresponds with the International Air Transport Association (IATA) airport code for an airport near the edge location's geographic location. (These abbreviations might change in the future.)
-
x-edge-request-idAn opaque string that uniquely identifies a request. CloudFront also sends this string in the
x-amz-cf-idresponse header. -
x-host-headerThe domain name of the CloudFront distribution (for example, d111111abcdef8.cloudfront.net).
-
time-takenThe number of seconds (to the thousandth of a second, for example, 0.082) from when the server receives the viewer's request to when the server writes the last byte of the response to the output queue, as measured on the server. From the perspective of the viewer, the total time to get the full response will be longer than this value because of network latency and TCP buffering.
-
cs-protocol-versionThe HTTP version that the viewer specified in the request. Possible values include
HTTP/0.9,HTTP/1.0,HTTP/1.1,HTTP/2.0, andHTTP/3.0. -
c-ip-versionThe IP version of the request (IPv4 or IPv6).
-
cs-user-agentThe value of the
User-Agentheader in the request. TheUser-Agentheader identifies the source of the request, such as the type of device and browser that submitted the request or, if the request came from a search engine, which search engine. -
cs-refererThe value of the
Refererheader in the request. This is the name of the domain that originated the request. Common referrers include search engines, other websites that link directly to your objects, and your own website. -
cs-cookieThe
Cookieheader in the request, including name—value pairs and the associated attributes.Note
This field is truncated to 800 bytes.
-
cs-uri-queryThe query string portion of the request URL, if any.
-
x-edge-response-result-typeHow the server classified the response just before returning the response to the viewer. See also the
x-edge-result-typefield. Possible values include:-
Hit– The server served the object to the viewer from the cache. -
RefreshHit– The server found the object in the cache but the object had expired, so the server contacted the origin to verify that the cache had the latest version of the object. -
Miss– The request could not be satisfied by an object in the cache, so the server forwarded the request to the origin server and returned the result to the viewer. -
LimitExceeded– The request was denied because a CloudFront quota (formerly referred to as a limit) was exceeded. -
CapacityExceeded– The server returned a 503 error because it didn't have enough capacity at the time of the request to serve the object. -
Error– Typically, this means the request resulted in a client error (the value of thesc-statusfield is in the4xxrange) or a server error (the value of thesc-statusfield is in the5xxrange).If the value of the
x-edge-result-typefield isErrorand the value of this field is notError, the client disconnected before finishing the download. -
Redirect– The server redirected the viewer from HTTP to HTTPS according to the distribution settings. -
LambdaExecutionError– The Lambda@Edge function associated with the distribution didn't complete due to a malformed association, a function timeout, an AWS dependency issue, or another general availability problem.
-
-
x-forwarded-forIf the viewer used an HTTP proxy or a load balancer to send the request, the value of the
c-ipfield is the IP address of the proxy or load balancer. In that case, this field is the IP address of the viewer that originated the request. This field can contain multiple comma-separated IP addresses. Each IP address can be an IPv4 address (for example,192.0.2.183) or an IPv6 address (for example,2001:0db8:85a3::8a2e:0370:7334). -
ssl-protocolWhen the request used HTTPS, this field contains the SSL/TLS protocol that the viewer and server negotiated for transmitting the request and response. For a list of possible values, see the supported SSL/TLS protocols in Supported protocols and ciphers between viewers and CloudFront.
-
ssl-cipherWhen the request used HTTPS, this field contains the SSL/TLS cipher that the viewer and server negotiated for encrypting the request and response. For a list of possible values, see the supported SSL/TLS ciphers in Supported protocols and ciphers between viewers and CloudFront.
-
x-edge-result-typeHow the server classified the response after the last byte left the server. In some cases, the result type can change between the time that the server is ready to send the response and the time that it finishes sending the response. See also the
x-edge-response-result-typefield.For example, in HTTP streaming, suppose the server finds a segment of the stream in the cache. In that scenario, the value of this field would ordinarily be
Hit. However, if the viewer closes the connection before the server has delivered the entire segment, the final result type (and the value of this field) isError.WebSocket and gRPC connections will have a value of
Missfor this field because the content is not cacheable and is proxied directly to the origin.Possible values include:
-
Hit– The server served the object to the viewer from the cache. -
RefreshHit– The server found the object in the cache but the object had expired, so the server contacted the origin to verify that the cache had the latest version of the object. -
Miss– The request could not be satisfied by an object in the cache, so the server forwarded the request to the origin and returned the result to the viewer. -
LimitExceeded– The request was denied because a CloudFront quota (formerly referred to as a limit) was exceeded. -
CapacityExceeded– The server returned an HTTP 503 status code because it didn't have enough capacity at the time of the request to serve the object. -
Error– Typically, this means the request resulted in a client error (the value of thesc-statusfield is in the4xxrange) or a server error (the value of thesc-statusfield is in the5xxrange). If the value of thesc-statusfield is200, or if the value of this field isErrorand the value of thex-edge-response-result-typefield is notError, it means the HTTP request was successful but the client disconnected before receiving all of the bytes. -
Redirect– The server redirected the viewer from HTTP to HTTPS according to the distribution settings. -
LambdaExecutionError– The Lambda@Edge function associated with the distribution didn't complete due to a malformed association, a function timeout, an AWS dependency issue, or another general availability problem.
-
-
fle-encrypted-fieldsThe number of field-level encryption fields that the server encrypted and forwarded to the origin. CloudFront servers stream the processed request to the origin as they encrypt data, so this field can have a value even if the value of
fle-statusis an error. -
fle-statusWhen field-level encryption is configured for a distribution, this field contains a code that indicates whether the request body was successfully processed. When the server successfully processes the request body, encrypts values in the specified fields, and forwards the request to the origin, the value of this field is
Processed. The value ofx-edge-result-typecan still indicate a client-side or server-side error in this case.Possible values for this field include:
-
ForwardedByContentType– The server forwarded the request to the origin without parsing or encryption because no content type was configured. -
ForwardedByQueryArgs– The server forwarded the request to the origin without parsing or encryption because the request contains a query argument that wasn't in the configuration for field-level encryption. -
ForwardedDueToNoProfile– The server forwarded the request to the origin without parsing or encryption because no profile was specified in the configuration for field-level encryption. -
MalformedContentTypeClientError– The server rejected the request and returned an HTTP 400 status code to the viewer because the value of theContent-Typeheader was in an invalid format. -
MalformedInputClientError– The server rejected the request and returned an HTTP 400 status code to the viewer because the request body was in an invalid format. -
MalformedQueryArgsClientError– The server rejected the request and returned an HTTP 400 status code to the viewer because a query argument was empty or in an invalid format. -
RejectedByContentType– The server rejected the request and returned an HTTP 400 status code to the viewer because no content type was specified in the configuration for field-level encryption. -
RejectedByQueryArgs– The server rejected the request and returned an HTTP 400 status code to the viewer because no query argument was specified in the configuration for field-level encryption. -
ServerError– The origin server returned an error.
If the request exceeds a field-level encryption quota (formerly referred to as a limit), this field contains one of the following error codes, and the server returns HTTP status code 400 to the viewer. For a list of the current quotas on field-level encryption, see Quotas on field-level encryption.
-
FieldLengthLimitClientError– A field that is configured to be encrypted exceeded the maximum length allowed. -
FieldNumberLimitClientError– A request that the distribution is configured to encrypt contains more than the number of fields allowed. -
RequestLengthLimitClientError– The length of the request body exceeded the maximum length allowed when field-level encryption is configured.
-
-
sc-content-typeThe value of the HTTP
Content-Typeheader of the response. -
sc-content-lenThe value of the HTTP
Content-Lengthheader of the response. -
sc-range-startWhen the response contains the HTTP
Content-Rangeheader, this field contains the range start value. -
sc-range-endWhen the response contains the HTTP
Content-Rangeheader, this field contains the range end value. -
c-portThe port number of the request from the viewer.
-
x-edge-detailed-result-typeThis field contains the same value as the
x-edge-result-typefield, except in the following cases:-
When the object was served to the viewer from the Origin Shield layer, this field contains
OriginShieldHit. -
When the object was not in the CloudFront cache and the response was generated by an origin request Lambda@Edge function, this field contains
MissGeneratedResponse. -
When the value of the
x-edge-result-typefield isError, this field contains one of the following values with more information about the error:-
AbortedOrigin– The server encountered an issue with the origin. -
ClientCommError– The response to the viewer was interrupted due to a communication problem between the server and the viewer. -
ClientGeoBlocked– The distribution is configured to refuse requests from the viewer's geographic location. -
ClientHungUpRequest– The viewer stopped prematurely while sending the request. -
Error– An error occurred for which the error type doesn't fit any of the other categories. This error type can occur when the server serves an error response from the cache. -
InternalError– An internal CloudFront error occurred. This typically indicates that the error originated within CloudFront infrastructure, not from the origin or the viewer. -
InvalidRequest– The server received an invalid request from the viewer. -
InvalidRequestBlocked– Access to the requested resource is blocked. -
InvalidRequestCertificate– The distribution doesn't match the SSL/TLS certificate for which the HTTPS connection was established. -
InvalidRequestHeader– The request contained an invalid header. -
InvalidRequestMethod– The distribution is not configured to handle the HTTP request method that was used. This can happen when the distribution supports only cacheable requests. -
LambdaLimitExceeded– The request exceeded a Lambda@Edge function limit. -
OriginCommError– The request timed out while connecting to the origin, or reading data from the origin. -
OriginConnectError– The server couldn't connect to the origin. -
OriginContentRangeLengthError– TheContent-Lengthheader in the origin's response doesn't match the length in theContent-Rangeheader. -
OriginDnsError– The server couldn't resolve the origin's domain name. -
OriginError– The origin returned an incorrect response. -
OriginHeaderTooBigError– A header returned by the origin is too big for the edge server to process. -
OriginInvalidResponseError– The origin returned an invalid response. -
OriginReadError– The server couldn't read from the origin. -
OriginWriteError– The server couldn't write to the origin. -
OriginZeroSizeObjectError– A zero size object sent from the origin resulted in an error. -
SlowReaderOriginError– The viewer was slow to read the message that caused the origin error.
-
-
-
c-countryA country code that represents the viewer's geographic location, as determined by the viewer's IP address. For a list of country codes, see ISO 3166-1 alpha-2
. -
cs-accept-encodingThe value of the
Accept-Encodingheader in the viewer request. -
cs-acceptThe value of the
Acceptheader in the viewer request. -
cache-behavior-path-patternThe path pattern that identifies the cache behavior that matched the viewer request.
-
cs-headersThe HTTP headers (names and values) in the viewer request.
Note
This field is truncated to 800 bytes.
-
cs-header-namesThe names of the HTTP headers (not values) in the viewer request.
Note
This field is truncated to 800 bytes.
-
cs-headers-countThe number of HTTP headers in the viewer request.
-
primary-distribution-idWhen continuous deployment is enabled, this ID identifies which distribution is the primary in the current distribution.
-
primary-distribution-dns-nameWhen continuous deployment is enabled, this value shows the primary domain name that is related to the current CloudFront distribution (for example, d111111abcdef8.cloudfront.net).
-
origin-fblThe number of seconds of first-byte latency between CloudFront and your origin.
-
origin-lblThe number of seconds of last-byte latency between CloudFront and your origin.
-
asnThe autonomous system number (ASN) of the viewer.
-
CMCD fields in real-time access logs
For more information about these fields, see the CTA Specification Web Application Video Ecosystem - Common Media Client Data CTA-5004
document. -
cmcd-encoded-bitrateThe encoded bitrate of the requested audio or video object.
-
cmcd-buffer-lengthThe buffer length of the requested media object.
-
cmcd-buffer-starvationWhether the buffer was starved at some point between the prior request and the object request. This can cause the player to be in a rebuffering stat, which can stall the video or audio playback.
-
cmcd-content-idA unique string that identifies the current content.
-
cmcd-object-durationThe playback duration of the requested object (in milliseconds).
-
cmcd-deadlineThe deadline from the request time that the first sample of this object must be available, so that a buffer underrun state or other playback problems are avoided.
-
cmcd-measured-throughputThe throughput between the client and server, as measured by the client.
-
cmcd-next-object-requestThe relative path of the next requested object.
-
cmcd-next-range-requestIf the next request is a partial object request, this string denotes the byte range to be requested.
-
cmcd-object-typeThe media type of the current object being requested.
-
cmcd-playback-rate1 if real-time, 2 if double-speed, 0 if not playing.
-
cmcd-requested-maximum-throughputThe requested maximum throughput that the client considers sufficient for asset delivery.
-
cmcd-streaming-formatThe streaming format that defines the current request.
-
cmcd-session-idA GUID identifying the current playback session.
-
cmcd-stream-typeToken identifying segment availability.
v= all segments are available.l= segments become available over time. -
cmcd-startupKey is included without a value if the object is needed urgently during startup, seeking, or recovery after a buffer-empty event.
-
cmcd-top-bitrateThe highest bitrate rendition that the client can play.
-
cmcd-versionThe version of this specification used for interpreting the defined key names and values. If this key is omitted, the client and server must interpret the values as being defined by version 1.
-
r-hostThis field is sent for origin requests and it indicates the domain of the origin server used to serve the object. In case of errors, you can use this field to find the last origin attempted, for example:
.cd8jhdejh6a.mediapackagev2.us-east-1.amazonaws.com -
sr-reasonThis field provides a reason why the origin was selected. It's empty when a request to the primary origin succeeds.
If origin failover occurs, the field will contain the HTTP error code that led to the failover, such as
Failover:403orFailover:502. In case of origin failover, if the retried request also fails and you have not configured custom error pages, thenr-statusindicates the response of the second origin. However, if you have configured custom error pages along with origin failover, then this will contain the response of the second origin if the request failed and a custom error page was returned instead.If no origin failover occurs but media quality-aware resilience (MQAR) origin selection occurs, then this will be logged as
MediaQuality. For more information, see Media quality-aware resiliency. -
x-edge-mqcsThis field indicates the Media Quality Confidence Score (MQCS) (range: 0 – 100) for media segments that CloudFront retrieved in the CMSD response headers from MediaPackage v2. This field is available for requests matching a cache behavior that has an MQAR-enabled origin group. CloudFront logs this field for media segments that are also served from its cache in addition to origin requests. For more information, see Media quality-aware resiliency.
-
distribution-tenant-idThe ID of the distribution tenant.
-
connection-idA unique identifier for the TLS connection.
You must enable mTLS for your distributions before you can get information for this field. For more information, see Mutual TLS authentication with CloudFront (Viewer mTLS).
-
viewer-request-log-data