nginx log field description
127.0.0.1 – – [31/Aug/2018:16:11:16 +0800] “GET /50x.html HTTP/1.1” 200 537 “-” “curl/7.29.0”
Access ip, access time, request method, request url, response status code, response body size, ua
Statistics based on access ip
cat access.log | awk ‘{count[$1]++}END{for(ip in count){print ip,count[ip]}}’
cat access.log | awk ‘{count[$1]++}END{for(ip in count){print ip”\t”count[ip]}}’|sort -rnk 2
Count the response status codes of nginx
cat access.log|awk ‘{count[$9]++}END{for(ip in count){print ip,count[ip]}}’ #Number of status codes
cat access.log|awk ‘{count[$9]++}END{for(status in count){print status,count[status]/NR*100″%”}}’ #Proportion statistics
cat access.log|awk ‘{count[$9]++}END{for(status in count){print status”\t”int(count[status]/NR*100)”%”}}’ #proportion statistics reserved integer
According to ua statistics
cat access.log|awk -F'”‘ ‘{print $(NF-1)}’
cat access.log|awk -F'”‘ ‘{count[$(NF-1)]++}END{for(ua in count){print ua,count[ua]}}’
According to time statistics, count the number of visits per minute and the number of visits per second
cat access.log |awk ‘{print $4}’|awk -F’:’ ‘{print $1″:”$2″:”$3}’|awk ‘{count[$1]++}END{for(time in count){print time,count[time]}}’ #Count the number of requests per minute
cat access.log|awk ‘{count[$4]++}END{ for(time in count){print time,count[time]} }’ #Request per second, concurrent
nginx log filtering
cat access.log|awk ‘$9~/^2/’ #Status code, normal request
cat access.log|awk ‘$9~/^5/’ #Status code, handle exception
cat access.log |awk -F'”‘ ‘$(NF-1) ~ /iPhone/’ #Filter ua containing iphone
Similar Posts:
- AWStats Vs Webalizer Vs Google Analytics Visito…
- Nginx an upstream response is buffered to a temporary file,nginx502 Error
- Visit the back-end application through nginx and report an error err_ CONTENT_ LENGTH_ MISMATCH
- What does HTTP status code 304 mean
- Nginx normal user startup configuration error: && springboot-swagger & Unable to infer base url
- 413 errors are reported in the service exposed by ingress
- [Solved] java.lang.Long cannot be cast to java.lang.Integer
- [Solved] syntax error, expect {, actual error, pos 0, fastjson-version 1.2.57
- [Solved] Nginx Log Error: open() “/opt/Nginx/nginx/nginx.pid” failed (2: No such file or directory)
- How to Solve Curl pass large JSON files Error