Skip to content

Instantly share code, notes, and snippets.

@hopewise
Last active July 13, 2020 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hopewise/95db9d666c81e676307f86bd296d484a to your computer and use it in GitHub Desktop.
Save hopewise/95db9d666c81e676307f86bd296d484a to your computer and use it in GitHub Desktop.
NGINX access.log analysis:
For NGINX:
Show analysis of access.log file
goaccess -f /var/log/nginx/access.log --log-format='%h %^[%d:%t %^] "%r" %s %b"%R" "%u" "%f" "%T" "%T" "%T" ' --date-format=%d/%b/%Y --time-format=%T
Show analysis of specific route:
tail -25000 /var/log/nginx/access.log.1 | grep /webhooks | goaccess --log-format='%h %^[%d:%t %^] "%r" %s %b"%R" "%u" "%f" "%T" "%T" "%T" ' --date-format=%d/%b/%Y --time-format=%T
For specific time: >= 5PM <= 8PM, date 12/Jul/2020
cat /var/log/nginx/access.log.1 | awk -F'[: ]' '$4 ~ /12\/Jul\/2020/ && $5 >= 17 && $5 <= 20 { print }' | goaccess --log-format='%h %^[%d:%t %^] "%r" %s %b"%R" "%u" "%f" "%T" "%T" "%T" ' --date-format=%d/%b/%Y --time-format=%T
Show analysis against specific IPs, in csv, column $2, and $1 in access files
sudo cat ./access.* | awk -F, 'FNR==NR { lines[$2] ; next ; } $1 in lines { print }' ./specific_ips.csv FS=' ' - | goaccess --log-format='%h %^[%d:%t %^] "%r" %s %b"%R" "%u" "%f" ' --date-format=%d/%b/%Y --time-format=%T -a > ips-access.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment