{"id":61940,"date":"2024-05-24T09:35:09","date_gmt":"2024-05-24T04:05:09","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=61940"},"modified":"2024-05-29T09:03:48","modified_gmt":"2024-05-29T03:33:48","slug":"maximizing-visibility-with-aws-cloudfronts-real-time-logging-capabilities","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/maximizing-visibility-with-aws-cloudfronts-real-time-logging-capabilities\/","title":{"rendered":"Maximizing Visibility with AWS CloudFront\u2019s Real-Time Logging Capabilities"},"content":{"rendered":"<h3><b>Introduction<\/b><\/h3>\n<p style=\"text-align: justify;\">In the modern digital era, having websites load quickly and smoothly is essential for a good user experience. Amazon CloudFront is a service designed to make this happen. It acts as a high-speed delivery system for web content, ensuring that websites load faster by storing copies of content closer to users. This reduces the distance data has to travel, resulting in quicker access to information, whether it&#8217;s a video, image, or webpage. CloudFront works quietly behind the scenes, improving the efficiency of the internet for everyone.<\/p>\n<h3 style=\"text-align: justify;\"><b>Problem Statement<\/b><\/h3>\n<p>We need to know where each request to our website is coming from, like which city and country.<br \/>\nHowever, just by checking the CDN log, we can only see the IP address of the request and some other details, but not where it&#8217;s actually originating from. We&#8217;re missing the information about the location of the users making those requests.<\/p>\n<h3 style=\"text-align: justify;\"><b>Solution Approach<\/b><\/h3>\n<p style=\"text-align: justify;\">With CDN&#8217;s real-time logging, we can see where requests are coming from, including the country and city, and even details like longitude and latitude. This information is very accurate, helping us pinpoint exactly where the requests originate from.<\/p>\n<h3 style=\"text-align: justify;\"><b>Prerequisites<\/b><\/h3>\n<ul style=\"text-align: justify;\">\n<li>Logging Configuration Knowledge: Understand the log format and configuration options available for real-time logging. This includes specifying which fields to include in the logs, log retention policies, and any customization options provided by your CDN provider.<\/li>\n<li>Resource Allocation: Consider the resource allocation required for processing and storing real-time logs. Depending on the volume of traffic and the granularity of logs, you may need to allocate sufficient resources to handle the incoming log data effectively.<\/li>\n<li>Understand Log Delivery Options: Familiarize yourself with the different log delivery options offered by your CDN provider. Some CDNs may offer integration with services like Amazon Kinesis Data Firehose or direct delivery to a specified endpoint.<\/li>\n<\/ul>\n<h3 style=\"text-align: justify;\"><b>Steps by Step Procedure<\/b><\/h3>\n<p>1. We need to create a Kinesis data stream for storing the real time cloudfront logs.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-61936 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-4.46.34\u202fPM-1024x966.png\" alt=\"CDN Demo\" width=\"625\" height=\"590\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-4.46.34\u202fPM-1024x966.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-4.46.34\u202fPM-300x283.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-4.46.34\u202fPM-768x725.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-4.46.34\u202fPM-624x589.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-4.46.34\u202fPM-24x24.png 24w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-4.46.34\u202fPM.png 1241w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>2. Now enable real-time logging and define the headers you want to add to CloudFront logs.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-61937 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.01.38\u202fPM-993x1024.png\" alt=\"demo\" width=\"625\" height=\"645\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.01.38\u202fPM-993x1024.png 993w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.01.38\u202fPM-291x300.png 291w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.01.38\u202fPM-768x792.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.01.38\u202fPM-624x643.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.01.38\u202fPM-24x24.png 24w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.01.38\u202fPM.png 1259w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>3. Once we enable real-time logging by defining all the details, logs are now visible on the Kinesis Data Stream.<\/p>\n<p>4. Now we have to create a Kinesis Data Firehose to send logs to an S3 bucket.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-61938\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.06.19\u202fPM-1024x1000.png\" alt=\"demo\" width=\"625\" height=\"610\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.06.19\u202fPM-1024x1000.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.06.19\u202fPM-300x293.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.06.19\u202fPM-768x750.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.06.19\u202fPM-624x610.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.06.19\u202fPM-24x24.png 24w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.06.19\u202fPM-48x48.png 48w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-23-at-5.06.19\u202fPM.png 1248w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>5. After creating the Kinesis Data Firehose, we can find the logs in the S3 bucket.<\/p>\n<p>6. Create an Athena table for S3 and perform operations on the real-time logs.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-61956\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-4.56.58\u202fPM-1024x741.png\" alt=\"demo\" width=\"625\" height=\"452\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-4.56.58\u202fPM-1024x741.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-4.56.58\u202fPM-300x217.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-4.56.58\u202fPM-768x556.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-4.56.58\u202fPM-1536x1111.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-4.56.58\u202fPM-2048x1482.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-4.56.58\u202fPM-624x451.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>In the above image, if we expand the &#8216;cs_headers&#8217; column, we can find details such as country, city, postal code, longitude, etc. Please refer to the image below for all the details.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-61947 \" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-11.01.13\u202fAM-1024x689.png\" alt=\"demo\" width=\"862\" height=\"580\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-11.01.13\u202fAM-1024x689.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-11.01.13\u202fAM-300x202.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-11.01.13\u202fAM-768x517.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-11.01.13\u202fAM-1536x1033.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-11.01.13\u202fAM-2048x1378.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2024\/05\/Screenshot-2024-05-24-at-11.01.13\u202fAM-624x420.png 624w\" sizes=\"(max-width: 862px) 100vw, 862px\" \/><\/p>\n<p>Please find below the headers that provide us with information about the viewer, such as country and city.<\/p>\n<ul>\n<li>CloudFront-Viewer-Country-Name: Provides the country name of the viewer<\/li>\n<li>CloudFront-Viewer-City: Provides the city name of the viewer<\/li>\n<li>CloudFront-Viewer-Postal-Code: Provides the postal code of the viewer<\/li>\n<li>CloudFront-Viewer-Time-Zone: Provides the time zone of the viewer<\/li>\n<li>CloudFront-Viewer-Latitude: Provides the latitude of the viewer<\/li>\n<li>CloudFront-Viewer-Longitude: Provides the longitude of the viewer<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">In the above image, we can see the country, city, postal code for each request, which is not possible without real-time logging.<\/p>\n<h3 style=\"text-align: justify;\"><b>Conclusion<\/b><\/h3>\n<p style=\"text-align: justify;\">CloudFront real-time logging empowers you with actionable insights into your CDN traffic and performance. By leveraging real-time logs, you can monitor web performance, troubleshoot issues promptly, and optimize content delivery for an exceptional user experience. Incorporating real-time logging into your CDN strategy is a proactive step towards achieving faster, more reliable, and more secure web delivery in today&#8217;s dynamic digital environment.<\/p>\n<p style=\"text-align: justify;\">\n","protected":false},"excerpt":{"rendered":"<p>Introduction In the modern digital era, having websites load quickly and smoothly is essential for a good user experience. Amazon CloudFront is a service designed to make this happen. It acts as a high-speed delivery system for web content, ensuring that websites load faster by storing copies of content closer to users. This reduces the [&hellip;]<\/p>\n","protected":false},"author":1603,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":20},"categories":[2348],"tags":[248,2645,1892],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/61940"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1603"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=61940"}],"version-history":[{"count":11,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/61940\/revisions"}],"predecessor-version":[{"id":61991,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/61940\/revisions\/61991"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=61940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=61940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=61940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}