How do I log all Cloudfront viewer requests with country/device info when that info is only available on cache misses?

323 Views Asked by At

I'm running into a certain problem with Cloudfront. I'd like to have it so that all viewer requests to Cloudfront get logged alongside with information about the viewer request, like country and device details.

On cache misses, when Cloudfront has to make an origin request, it's trivial because you can easily configure Cloudfront to send headers like CloudFront-Viewer-Country and CloudFront-Is-Mobile-Viewer along with that origin request. However, I have no idea how to access that information on cache hits (since no origin request is made then) given what's available in the viewer request/viewer response.

The best I can get seems to be in the Cloudfront logs, where x-edge-location gives me a rough idea of the location of each request, but that really doesn't have the desired granularity I'm looking for, and ideally I wouldn't have to go to a third party for IP lookups or anything. Is there any way to get the desired logging information even for requests that don't go to the origin? Thanks!

0

There are 0 best solutions below