Skip to content

Instantly share code, notes, and snippets.

@peerasan
Last active May 25, 2020 02:59
Show Gist options
  • Select an option

  • Save peerasan/675a7860991dac6b242d643e672abb0d to your computer and use it in GitHub Desktop.

Select an option

Save peerasan/675a7860991dac6b242d643e672abb0d to your computer and use it in GitHub Desktop.
nginx log HIT and MISS status
awk '{print $3}' /var/log/nginx/domain.cache.log | sort | uniq -c | sort -r
#OUTPUT
132960 HIT
33117 MISS
log_format rt_cache '$remote_addr - $upstream_cache_status [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
server {
access_log /var/log/nginx/domain.cache.log rt_cache;
}
# OUTPUT domain.cache.log
# xxx.xxx.xxx.xxx - HIT [25/May/2020:07:13:49 +0700] "GET /mediacache/........."
# xxx.xxx.xxx.xx - MISS [25/May/2020:07:13:49 +0700] "GET /mediacache/........."
# xxx.xx.xxx.xxx - HIT [25/May/2020:07:13:49 +0700] "GET /mediacache/........."
# xxx.x.xxx.xxx - MISS [25/May/2020:07:13:49 +0700] "GET /mediacache/........."
# xxx.xx.xx.x - HIT [25/May/2020:07:13:49 +0700] "GET /mediacache/........."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment