Lecturer: Okay, so let's talk about
Access Logs for CloudFront.
So the idea is that when you enable it
the same way you would do for S3 bucket
or for a load balancer, for example,
well, CloudFront is going to log every request made
to your origin into a logging S3 buckets.
This was going to work
is that your users are going to access your website
through the CloudFront URL, okay?
And then each edge location around the world
is going to send its log file,
so the distribution log data
to a central S3 bucket that you to define.
Now, your S3 bucket is going to be a logging bucket,
but it can be different
and it should be different than your origin buckets,
which is maybe where the content is originated from, okay?
So there are two types of buckets in Amazon S3,
your Origin bucket that is linked to CloudFront distribution
and your Logs bucket to send you like files too.
And you could have a second website
with a second CloudFront distribution,
do the exact same thing, okay?
And send it out to your Logs buckets.
The idea is that you could separate your distribution
by adding a prefix within your Logs buckets.
So CloudFront has a lot of reports
and it's possible to generate reports
on Cache Statistics Reports,
Popular Object Reports,
Top Referrer Reports,
Usage Reports,
and Viewers Reports.
And to create these reports,
CloudFront is going to use the data from the Access Logs,
but you don't need to enable Access Logs
to be sent into S3 to have these reports being generated.
Okay?
So no matter what, you will find that these reports.
And for some troubleshooting,
well, CloudFront will set a world cache,
the HTTP 400 and 500 status codes returned by S3
or the origin server.
So that means that if there isn't an available file
at the origin,
then that response is going to be cached no matter what.
So 4xx will indicate that the user doesn't have access to
the underlying buckets, for example, 403,
or that the user is requesting an object
that is not existing, so 404, okay?
And 5xx will indicate Gateway issues.
So let's have a look in the console
to see where all these options are.
So let's have a look at the Logging setting
for our CloudFront distribution.
And for this under settings,
I will click on Edit
and then scroll down
and I will have the Standard logging option.
So we can say On,
and we can have a S3 buckets
that we'd choose, for example,
that you have created previously.
So Stephane-cloudfront-logs
and then you can have a log prefix if you wanted to,
to send the logs into the S3 buckets.
And what's going to happen is that if you go
into this S3 CloudFront log,
so I've already did create this before.
So let me just put back the settings.
So I will have this settings as save right now
and click on Save changes.
So when logging is enabled,
what's going to happen is that the objects
are going to be logged into your S3 buckets.
And then in your S3 bucket,
you're going to get a lot of files, okay,
corresponding to some important logging information
regarding your distribution.
So you can just get any of these files downloaded
and then you would unzip it and look at the content.
So if you have a look at this file,
so we had the Fields,
so each column is going to be represented here, okay?
So we have the date, the time,
we get some information around those was get requests
from this URL at this path right here,
from, it was a 403.
The results, it was from Mozilla and so on.
And so you get a lot of information
around your requests overall, okay?
So this is a classic access log,
and you could use a service like Athena
to analyze this access log.
Now let's have a look at the reports in analytics
from some real distribution.
So if I go to Cache Statistics
and I choose a distribution that I have
that actually is being used in a real world,
we can have a look at the report for example,
of the number of requests in the past seven days.
So we can have a look at, for example,
they had 80,000 requests
on this day on my distribution,
and we can get a daily granularity
or an hourly granularity to get more information
around the patterns of how objects are being requested.
Okay?
We can have some information around the cache hits
versus the cache misses and the error.
So the distribution says,
we can see average about 75, 80% of cache hits
and about, you know, less 20%, 15% of cache misses,
which is really good.
So that means that's my distribution is working correctly.
And most of the content being served
is coming from the cache.
We can have a look at the bytes transferred to the viewer.
So how much is transferred from the you're directly from
CloudFront or from the cache misses.
And then we can get some information
around the HTTP status codes we're getting.
So whether or not we get some 2xx, 3xx, 4xx and 5xx
and so on.
Okay.
Now let's look at Popular objects.
So this gives us some information around
which objects have been popular in my cache
and which ones have been hits or misses and so on.
Top referrers, which is giving me some information around
which websites are sending data into my cache.
Then we have Usage,
which is showing me the usage
in terms of data transfer by protocol.
So it's quite nice.
That means that every day I get 9 GB or 8 GB of data
being served over HTTPS and none of it's over HTTP.
So that means that my distribution is only secure,
and we can get some more information as well
from the location.
So where is the data flowing?
Is it from CloudFront to users,
or is it from CloudFront to your origin
and all the data.
So just some information in here.
And then Viewers,
which is giving me some information around
which type of user I have.
So Desktop, Bot, Mobile and so on.
And then some trends that I get for these information,
the web browser that are accessing my distribution,
the operating systems, as well as a view location.
So it gave me some information around which countries
are accessing my distribution,
and India, U.K. and United States
are the biggest locations from this distribution.
And then finally,
we can have a look at some monitoring
associated with that distribution.
So if I click on it
and look at the distribution metrics,
where we can see in here
are going to be the sum of requests over time,
the data transfers,
the error rates,
the 4xx error rates,
and the 5xx error rates,
the latency to the origin
and the cache error rate, okay?
So that's all you need to know for CloudFront Reports,
Logging and Monitoring.
I hope you liked it.
And I will see you in the next lecture.