Here's a quick breakdown of how to get the usage of your different Amazon CloudFront Edge locations within AWStats. I confess that I get some crazy pleasure from collecting statistics, still though, bandwidth usage is of interest in this case, as well as hits and that it can be interesting to see which regions most of the visitors come from.
I use the cluster functionality in AWStats to display the CloudFront Edges, as can be seen in the screenshot to the right.
I'm running AWStats on an Ubuntu server and this guide assumes that you are already collecting your CloudFront logs to a server and processes them with AWStats. If not, check out my other article dealing with that.
Let's work with our hypothetical CloudFront distribution named cdn.example.com.
In Ubuntu AWStats stores the configurations files in /etc/awstats/ so I will assume there is a file located there named
which processes the CloudFront log already.
If you have configured the above .conf file properly for CloudFront, %cluster is collected in the LogFormat which contains all information needed to be able to display the edges. So now we only need to tell AWStats to start using that information.
First in the awstats.cdn.example.com.conf, enable cluster statistics by finding ShowClusterStats=0 and change it to:
And then continue down to the plugin section and uncomment
Now we only need to tell AWStats the name of the edges, so they make sense when checking the statistics later on. In AWStats DirData directory, create a file named clusterinfo.[your awstats config name].txt
Which in our example would be
This file shall contain a tab separated list of cluster numbers and then a text to display for each cluster. At the time of writing this article this is the complete list to paste into that file for all available CloudFront Edges. If Amazon adds more edges in the future they will have to be added at that time.
DFW3 USA: Dallas/Fort Worth, TX
EWR2 USA: Newark, NJ
IAD2 USA: Ashburn, VA
JAX1 USA: Jacksonville, FL
JFK1 USA: New York, NY
LAX1 USA: Los Angeles, CA
MIA3 USA: Miami, FL
SEA4 USA: Seattle, WA
SFO4 USA: Palo Alto, CA
STL2 USA: St. Louis, MO
AMS1 Europe: Amsterdam
DUB2 Europe: Dublin
FRA2 Europe: Frankfurt
LHR3 Europe: London
HKG1 Asia: Hong Kong
NRT4 Asia: Tokyo
SIN2 Asia: Singapore
Okay, that's it, the next time AWStats updates the statistics output you should start getting Edge usage outputted in the Cluster section, like in the screenshot above.