36 / 48
再看仔細一點web access log - nginx
— IP 時間 Request status size referer user-agent
— 222.127.217.62 - - [14/Aug/2015:08:27:22 +0000] GET /marvel/QueryTeam?lang=en HTTP/1.1 200 6143
https://www.reddit.com/r/FutureFight/comments/3ewpsl/tier_list/ Mozilla/5.0 (Windows NT 6.1)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36”
IP:222.127.217.62
時間:14/Aug/2015:08:27:22 +0000
Request: GET /marvel/QueryTeam?lang=en HTTP/1.1
Status: 200 (成功)
Size: 6143
Referer: https://www.reddit.com/r/FutureFight/comments/3ewpsl/tier_list/
User-agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36
— 115.134.175.252 - - [14/Aug/2015:13:28:18 +0000] GET /marvel/heroList.jsp?lang=en HTTP/1.1 200 3101
https://www.reddit.com/r/FutureFight/comments/3ewpsl/tier_list/ Mozilla/5.0 (Windows NT 6.1)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36”
— 115.134.175.252 - - [14/Aug/2015:13:28:40 +0000] GET /marvel/heroList.jsp?lang=en HTTP/1.1 200 3101
https://www.reddit.com/r/FutureFight/comments/3ewpsl/tier_list/ Mozilla/5.0 (Windows NT 6.1)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36”
37.
37 / 48
必須收集什麼才有用呢?
— 身份識別
¡ Cookie id
(或者用Google Analytics的也可, cookie: _ga)
¡ Member id(沒有也無所謂)
¡ Session id
— Timestamp
— Request(含參數)
— User agent
— Referer (很重要喔!)
38.
38 / 48
指定成你要的樣子log format
— Google 請搜尋: nginx web access log format
— Ref:
http://nginx.org/en/docs/http/
ngx_http_core_module.html#variables
— $remote_addr: 遠端的IP位置
— $time_local: 時間
— $request: request
— $query_string: 參數
— $http_referer: 從哪裡來
— $http_user_agent: user agent, 區分瀏覽器或者裝置
— $cookie_NAME ( ex: $cookie_cookieid ) 抓cookie
39.
39 / 48
Howto store web access log
Web server 1~N
web access log
Kafka Cluster
Web log
Producer
Topic:
Page log
Page log
Consumer
Page
log
DB
Product
log
DB
DB可以是impala,
或者PostgreSQL,
或MySQL, 或混合
其 他 投影 片 可 參 考 這 裡
h t t p : / / w w w . s l i d e s h a r e . n e t / e t h a n t s u i 7
有 任 何 問 題 , 可 以 與 我 聯 絡
E m a i l : e t h a n 7 7 @ g m a i l . c o m
F a c e b o o k : e t h a n . t s u i . 7
E t h a n Y i n - H a o T s u i ( 崔 殷 豪 )
參數Ref 才是王道啊!
Q A