SlideShare una empresa de Scribd logo
1 de 22
COLLECTING BIG DATA WITH
S3/CLOUDFRONT LOGGING
Moty Michaely, VP R&D
Xplenty Data Integration-as-a-Service
In our recent article, “Scale Your Data Collection on the Cloud
Like a Champ”, we reviewed several ways of collecting big
data, the most promising of which was S3/CloudFront
logging. It’s low cost and quick to implement. Now we’d like
to dig deeper and show how to setup S3/CloudFront logging
with your application.
DEFINE APP DATA
Sit back and think - which data would you like to collect? Which app
events should be logged? These could be page visits, mouse clicks, logins,
errors, etc. Some of them may include parameters such as the page visit
URL. Write them all down. Be as thorough as possible so you don’t lose
any precious data.
CREATE AN AWS ACCOUNT
If you don’t already have an AWS (Amazon Web Services) account, you
can sign up here. Registration is free with the basic support package.
CREATE AN S3 BUCKET
Go to the S3 dashboard and create a bucket for saving the logs. Note that
the bucket must have a unique name across Amazon’s service and adhere
to DNS rules: 3-63 characters, only letters numbers and periods, shouldn't
look like an IP address, and no underscores. Don’t turn on logging - we will
do so via CloudFront.
(See the screenshot on the next slide for a visual explanation)
CREATE AN S3 BUCKET (SCREENSHOT)
CREATE EVENT IMAGES
Set up directories in the image bucket, for example /mouse, to organize
events by categories, and create 1x1 pixel images (see previous post) for
all the events that you defined in the first step, e.g. click.png, login.png,
error.png. Don’t worry about event parameters at the moment, we will
deal with them shortly.
All files uploaded to S3 are set as private, so make sure to change the file
permissions to public. You may use tools such as CloudBerry
Explorer or S3 Browser to do so and much more.
CREATE EVENT IMAGES CONT.
Set HTTP headers for all the images so that they will be cached by
CloudFront, thus saving GET requests from CloudFront edge locations to
S3. Go to the relevant bucket, check the image files on the left, click
Actions at the top, choose Properties, and open the Metadata section.
Add the following metadata line and click save:
▪ Cache-Control: max-age=31536000
CREATE EVENT IMAGES (SCREENSHOT)
CREATE A CLOUDFRONT DISTRIBUTION
Creating a CloudFront distribution costs extra, but it’s mandatory - it logs
the query string, adds extra log info such as edge locations, and helps to
deliver files via Amazon’s CDN to shorten load times. Access
the CloudFront dashboard and create a web distribution for the image S3
bucket. Make sure that Use Origin Cache Headers is set under Object
Caching (it’s the default setting).
CREATE A CLOUDFRONT DISTRIBUTION
CONT.
Note that the distribution gets a random domain name. It could take a
while before it starts working because the DNS servers need to be
updated to support it. You can also set a more friendly domain using the
Alternate Domain Names (CNAMEs) option under Distribution Settings,
though it requires configuring your DNS settings so that your domain
points to CloudFront’s domain name. See Amazon’s documentation for
more info.
CREATE A CLOUDFRONT DISTRIBUTION
(SCREENSHOT 1)
CREATE A CLOUDFRONT DISTRIBUTION
(SCREENSHOT 2)
TURN LOGGING ON
Still in the CloudFront dashboard, check the distribution on the left, click
Distribution Settings at the top, click Edit under the General tab, enable
logging, and insert the bucket where you want to store the logs.
TURN LOGGING ON (SCREENSHOT 1)
TURN LOGGING ON (SCREENSHOT 2)
CODE A FUNCTION TO CALL EVENTS
Time to get your hands dirty and write a method that registers events, or
call one of your app’s developers to do it for you. The code could be on
the client side, server side, or both depending on the architecture. The
method should simply send an asynchronous HTTP GET request to the
relevant image URL, e.g. to http://logs.xplenty.com/mouse/click.png (links
in this format for demo purposes only, not operational).
If you need to send additional event parameters, use the query
string (don’t forget URL encoding), e.g.
http://logs.xplenty.com/mouse/click.png?id=login&url=http%3A%2F%2Fw
ww.example.com%2Flogin
EXAMPLE CODE TO CALL EVENTS
$.CloudFrontLog = function (attr) {
var url = 'http://logs.xplenty.com/' + attr.category + '/' + attr.action +
'.png',
data = {
id: attr.id,
url: attr.url
};
return $.get(url, data);
};
CALL THE EVENTS
Dig through your app’s code and add event calls using the method
that you’ve just written. This will collect the data that you defined in
step 1. Here’s a jQuery code sample for logging client-side button
clicks:
$('.btn').click(function(e) {
var id = $(this).attr('id');
$.CloudFrontLog({
action: 'click',
category: 'mouse',
id: id,
url: location.href
});
});
TEST
Use your staging environment to call events via the application and check
that the logs are generated accordingly. Patience young padawan, it may
take an hour or so until Amazon writes them.
GO LIVE!
Everything should be ready for you to collect big data like a champ -
update the production environment and let the logging begin. Don't know
what to do with the data? See how to analyze AWS logs in 15 minutes.
XPLENTY DATA
WWW.XPLENTY.COM

Más contenido relacionado

Destacado

(MBL311) Workshop: Build an Android App Using AWS Mobile Services | AWS re:In...
(MBL311) Workshop: Build an Android App Using AWS Mobile Services | AWS re:In...(MBL311) Workshop: Build an Android App Using AWS Mobile Services | AWS re:In...
(MBL311) Workshop: Build an Android App Using AWS Mobile Services | AWS re:In...Amazon Web Services
 
Challenges In Pharmacovigilance Dr Vishwas, by Dr. Vishwas Sovani MD ,VP P...
Challenges In Pharmacovigilance   Dr Vishwas, by Dr. Vishwas Sovani  MD ,VP P...Challenges In Pharmacovigilance   Dr Vishwas, by Dr. Vishwas Sovani  MD ,VP P...
Challenges In Pharmacovigilance Dr Vishwas, by Dr. Vishwas Sovani MD ,VP P...Until ROI
 
Why Flow with Salesforce Flow
Why Flow with Salesforce FlowWhy Flow with Salesforce Flow
Why Flow with Salesforce FlowAjeet Singh
 
Diminishing marginal utility
Diminishing marginal utilityDiminishing marginal utility
Diminishing marginal utilityjijopr
 
Adverse Drug Reactions - Identifying, Causality & Reporting
Adverse Drug Reactions - Identifying, Causality & ReportingAdverse Drug Reactions - Identifying, Causality & Reporting
Adverse Drug Reactions - Identifying, Causality & ReportingRuella D'Costa Fernandes
 
Bring the Customer Journey to Life with Salesforce Marketing Cloud
Bring the Customer Journey to Life with Salesforce Marketing CloudBring the Customer Journey to Life with Salesforce Marketing Cloud
Bring the Customer Journey to Life with Salesforce Marketing CloudSalesforce Marketing Cloud
 
Mobile Enterprise Trends 2015 - Emergence Capital
Mobile Enterprise Trends 2015 - Emergence CapitalMobile Enterprise Trends 2015 - Emergence Capital
Mobile Enterprise Trends 2015 - Emergence CapitalEmergence Capital
 
How Salesforce CRM works & who should use it?
How Salesforce CRM works & who should use it?How Salesforce CRM works & who should use it?
How Salesforce CRM works & who should use it?Suyati Technologies
 
Presentation introduction to six sigma
Presentation   introduction to six sigmaPresentation   introduction to six sigma
Presentation introduction to six sigmajpanchpor
 
(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT
(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT
(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoTAmazon Web Services
 
Basic Six Sigma Presentation
Basic Six Sigma PresentationBasic Six Sigma Presentation
Basic Six Sigma Presentationvivekissar
 
Six Sigma the best ppt
Six Sigma the best pptSix Sigma the best ppt
Six Sigma the best pptRabia Sgh S
 
A Planner's Playbook - Everything I learned about planning at Miami Ad School...
A Planner's Playbook - Everything I learned about planning at Miami Ad School...A Planner's Playbook - Everything I learned about planning at Miami Ad School...
A Planner's Playbook - Everything I learned about planning at Miami Ad School...Sytse Kooistra
 

Destacado (16)

(MBL311) Workshop: Build an Android App Using AWS Mobile Services | AWS re:In...
(MBL311) Workshop: Build an Android App Using AWS Mobile Services | AWS re:In...(MBL311) Workshop: Build an Android App Using AWS Mobile Services | AWS re:In...
(MBL311) Workshop: Build an Android App Using AWS Mobile Services | AWS re:In...
 
Challenges In Pharmacovigilance Dr Vishwas, by Dr. Vishwas Sovani MD ,VP P...
Challenges In Pharmacovigilance   Dr Vishwas, by Dr. Vishwas Sovani  MD ,VP P...Challenges In Pharmacovigilance   Dr Vishwas, by Dr. Vishwas Sovani  MD ,VP P...
Challenges In Pharmacovigilance Dr Vishwas, by Dr. Vishwas Sovani MD ,VP P...
 
Why Flow with Salesforce Flow
Why Flow with Salesforce FlowWhy Flow with Salesforce Flow
Why Flow with Salesforce Flow
 
Diminishing marginal utility
Diminishing marginal utilityDiminishing marginal utility
Diminishing marginal utility
 
Cardinal utility analysis
Cardinal utility analysisCardinal utility analysis
Cardinal utility analysis
 
Adverse Drug Reactions - Identifying, Causality & Reporting
Adverse Drug Reactions - Identifying, Causality & ReportingAdverse Drug Reactions - Identifying, Causality & Reporting
Adverse Drug Reactions - Identifying, Causality & Reporting
 
Bring the Customer Journey to Life with Salesforce Marketing Cloud
Bring the Customer Journey to Life with Salesforce Marketing CloudBring the Customer Journey to Life with Salesforce Marketing Cloud
Bring the Customer Journey to Life with Salesforce Marketing Cloud
 
Mobile Enterprise Trends 2015 - Emergence Capital
Mobile Enterprise Trends 2015 - Emergence CapitalMobile Enterprise Trends 2015 - Emergence Capital
Mobile Enterprise Trends 2015 - Emergence Capital
 
Utility analysis ppt
Utility analysis pptUtility analysis ppt
Utility analysis ppt
 
How Salesforce CRM works & who should use it?
How Salesforce CRM works & who should use it?How Salesforce CRM works & who should use it?
How Salesforce CRM works & who should use it?
 
Presentation introduction to six sigma
Presentation   introduction to six sigmaPresentation   introduction to six sigma
Presentation introduction to six sigma
 
(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT
(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT
(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT
 
Six sigma ppt
Six sigma pptSix sigma ppt
Six sigma ppt
 
Basic Six Sigma Presentation
Basic Six Sigma PresentationBasic Six Sigma Presentation
Basic Six Sigma Presentation
 
Six Sigma the best ppt
Six Sigma the best pptSix Sigma the best ppt
Six Sigma the best ppt
 
A Planner's Playbook - Everything I learned about planning at Miami Ad School...
A Planner's Playbook - Everything I learned about planning at Miami Ad School...A Planner's Playbook - Everything I learned about planning at Miami Ad School...
A Planner's Playbook - Everything I learned about planning at Miami Ad School...
 

Último

Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramMoniSankarHazra
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxolyaivanovalion
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Delhi Call girls
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...shivangimorya083
 
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Onlineanilsa9823
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxMohammedJunaid861692
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 

Último (20)

Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 

Collecting Big Data with S3/CloudFront Logging

  • 1. COLLECTING BIG DATA WITH S3/CLOUDFRONT LOGGING Moty Michaely, VP R&D Xplenty Data Integration-as-a-Service
  • 2. In our recent article, “Scale Your Data Collection on the Cloud Like a Champ”, we reviewed several ways of collecting big data, the most promising of which was S3/CloudFront logging. It’s low cost and quick to implement. Now we’d like to dig deeper and show how to setup S3/CloudFront logging with your application.
  • 3. DEFINE APP DATA Sit back and think - which data would you like to collect? Which app events should be logged? These could be page visits, mouse clicks, logins, errors, etc. Some of them may include parameters such as the page visit URL. Write them all down. Be as thorough as possible so you don’t lose any precious data.
  • 4. CREATE AN AWS ACCOUNT If you don’t already have an AWS (Amazon Web Services) account, you can sign up here. Registration is free with the basic support package.
  • 5. CREATE AN S3 BUCKET Go to the S3 dashboard and create a bucket for saving the logs. Note that the bucket must have a unique name across Amazon’s service and adhere to DNS rules: 3-63 characters, only letters numbers and periods, shouldn't look like an IP address, and no underscores. Don’t turn on logging - we will do so via CloudFront. (See the screenshot on the next slide for a visual explanation)
  • 6. CREATE AN S3 BUCKET (SCREENSHOT)
  • 7. CREATE EVENT IMAGES Set up directories in the image bucket, for example /mouse, to organize events by categories, and create 1x1 pixel images (see previous post) for all the events that you defined in the first step, e.g. click.png, login.png, error.png. Don’t worry about event parameters at the moment, we will deal with them shortly. All files uploaded to S3 are set as private, so make sure to change the file permissions to public. You may use tools such as CloudBerry Explorer or S3 Browser to do so and much more.
  • 8. CREATE EVENT IMAGES CONT. Set HTTP headers for all the images so that they will be cached by CloudFront, thus saving GET requests from CloudFront edge locations to S3. Go to the relevant bucket, check the image files on the left, click Actions at the top, choose Properties, and open the Metadata section. Add the following metadata line and click save: ▪ Cache-Control: max-age=31536000
  • 9. CREATE EVENT IMAGES (SCREENSHOT)
  • 10. CREATE A CLOUDFRONT DISTRIBUTION Creating a CloudFront distribution costs extra, but it’s mandatory - it logs the query string, adds extra log info such as edge locations, and helps to deliver files via Amazon’s CDN to shorten load times. Access the CloudFront dashboard and create a web distribution for the image S3 bucket. Make sure that Use Origin Cache Headers is set under Object Caching (it’s the default setting).
  • 11. CREATE A CLOUDFRONT DISTRIBUTION CONT. Note that the distribution gets a random domain name. It could take a while before it starts working because the DNS servers need to be updated to support it. You can also set a more friendly domain using the Alternate Domain Names (CNAMEs) option under Distribution Settings, though it requires configuring your DNS settings so that your domain points to CloudFront’s domain name. See Amazon’s documentation for more info.
  • 12. CREATE A CLOUDFRONT DISTRIBUTION (SCREENSHOT 1)
  • 13. CREATE A CLOUDFRONT DISTRIBUTION (SCREENSHOT 2)
  • 14. TURN LOGGING ON Still in the CloudFront dashboard, check the distribution on the left, click Distribution Settings at the top, click Edit under the General tab, enable logging, and insert the bucket where you want to store the logs.
  • 15. TURN LOGGING ON (SCREENSHOT 1)
  • 16. TURN LOGGING ON (SCREENSHOT 2)
  • 17. CODE A FUNCTION TO CALL EVENTS Time to get your hands dirty and write a method that registers events, or call one of your app’s developers to do it for you. The code could be on the client side, server side, or both depending on the architecture. The method should simply send an asynchronous HTTP GET request to the relevant image URL, e.g. to http://logs.xplenty.com/mouse/click.png (links in this format for demo purposes only, not operational). If you need to send additional event parameters, use the query string (don’t forget URL encoding), e.g. http://logs.xplenty.com/mouse/click.png?id=login&url=http%3A%2F%2Fw ww.example.com%2Flogin
  • 18. EXAMPLE CODE TO CALL EVENTS $.CloudFrontLog = function (attr) { var url = 'http://logs.xplenty.com/' + attr.category + '/' + attr.action + '.png', data = { id: attr.id, url: attr.url }; return $.get(url, data); };
  • 19. CALL THE EVENTS Dig through your app’s code and add event calls using the method that you’ve just written. This will collect the data that you defined in step 1. Here’s a jQuery code sample for logging client-side button clicks: $('.btn').click(function(e) { var id = $(this).attr('id'); $.CloudFrontLog({ action: 'click', category: 'mouse', id: id, url: location.href }); });
  • 20. TEST Use your staging environment to call events via the application and check that the logs are generated accordingly. Patience young padawan, it may take an hour or so until Amazon writes them.
  • 21. GO LIVE! Everything should be ready for you to collect big data like a champ - update the production environment and let the logging begin. Don't know what to do with the data? See how to analyze AWS logs in 15 minutes.