Forked from hvelarde/web server log analysis cheat sheet
          
        
    
          Created
          June 23, 2023 20:24 
        
      - 
      
- 
        Save bodnar1212/c2022ca61df1b6647b3015cc834799a7 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or 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 | |
| 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