Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bodnar1212/c2022ca61df1b6647b3015cc834799a7 to your computer and use it in GitHub Desktop.
Save bodnar1212/c2022ca61df1b6647b3015cc834799a7 to your computer and use it in GitHub Desktop.
# 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
awk -F'"' '{print $6}' /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 | awk -F'"' '{print $6}' | sort | uniq -c | sort -rn | head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment