Skip to content

How to Determine Request Region and Granular Usage Statistics for Each Client in CloudFront

0

Hi,

Based on the AWS documentation, the pricing for CloudFront depends on the region where the requests originate.

Is it possible to determine the region of a request for each client? While inspecting CloudFront logs using Athena, I noticed that the logs only include the client's IP address and not the region information. In the AWS Management Console for CloudFront, I can see usage statistics, but the granularity is limited to the entire distribution and not per client.

Thank you in advance for your help.

asked 2 years ago648 views
2 Answers
2
Accepted Answer

Hello,

To determine the region of a request for each client in CloudFront:

  1. Look at the x-edge-location field in CloudFront logs: This field tells you which edge location (a specific server) handled the request. The edge location is represented by a three-letter code (like DFW3), which generally matches an airport code near that location. By knowing the edge location, you can infer the region where the request originated.

  2. Map these codes to regions: You can create or use a reference list to map these edge location codes to specific geographic regions. This way, you'll know which region each request came from.

  3. Use Athena to analyze logs: Since you're already using Athena to inspect CloudFront logs, you can include the x-edge-location field in your queries to break down usage by region, giving you more granular insights per client.

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
EXPERT
reviewed 2 years ago
  • Thank you very much for your answer. Will try

2

One of the fields in CloudFront's standard logs (access logs) is the x-edge-location (field #3):

The 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.)

AWS
EXPERT
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.