Forked from hvelarde/web server log analysis cheat sheet
Created
May 24, 2017 19:06
-
-
Save rodfersou/9a3bad07d1aae026c66156b8a18828a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get total requests by status code | |
awk '{print $9}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | |
# get top requesters by IP | |
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head | |
# get top requesters by user agent | |
cut -d' ' -f12- /var/log/nginx/access.log | sort | uniq -c | sort -rn | head | |
# get top requests by URL | |
awk '{print $7}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head | |
# get top IP addresses requesting non-existent content | |
awk '($9 ~ /404/) {print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head | |
# get top URL returning 404 Not Found | |
awk '($9 ~ /404/) {print $7}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head | |
# get top user agents requesting non-existent content | |
awk '($9 ~ /404/)' /var/log//nginx/access.log | cut -d' ' -f12- | sort | uniq -c | sort -rn | head |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment