karszawa / sign-of-horns

ISUCON 7 Qual Repository :metal:
0 stars 1 forks source link

alp でアクセスログ解析 #10

Open karszawa opened 6 years ago

karszawa commented 6 years ago

なにをやるか

alpでアクセスログの解析を行う。

なぜやるか

どのパスへのアクセスが遅いか確認するため

どうやるか

nginx.conf に対し以下を追記

log_format ltsv "time:$time_local"
                "\thost:$remote_addr"
                "\tforwardedfor:$http_x_forwarded_for"
                "\treq:$request"
                "\tstatus:$status"
                "\tmethod:$request_method"
                "\turi:$request_uri"
                "\tsize:$body_bytes_sent"
                "\treferer:$http_referer"
                "\tua:$http_user_agent"
                "\treqtime:$request_time"
                "\tcache:$upstream_http_x_cache"
                "\truntime:$upstream_http_x_runtime"
                "\tapptime:$upstream_response_time"
                "\tvhost:$host";
access_log /var/log/nginx/access.log ltsv;

その上で、

sudo alp -f /var/log/nginx/access.log

とすると、どのアクセスパスが遅いか判別できる。