Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |
wiki:nginx_log_parsing [2022/04/14 08:19] – [nginx log parsing] add log example antisa | wiki:nginx_log_parsing [2022/04/14 09:41] (current) – [nginx log parsing] add WRAP tags to nginx log line antisa |
---|
Get number of request per second by country if you have geoip logging enabled, with log line looking like this | Get number of request per second by country if you have geoip logging enabled, with log line looking like this |
| |
| <WRAP prewrap> |
| <code> |
"14/Apr/2022:00:01:29 +0200" client=114.119.147.209 country=CN is_bot=1 method=GET request="GET /marken/giorgio-armani/kurzarmhemden/ HTTP/1.1" request_length=414 status=200 bytes_sent=37876 body_bytes_sent=37376 referer=- user_agent=Mozilla/5.0 (Linux; Android 7.0;) AppleWebKit/537.36 (KHTML, like Gecko) Mobile Safari/537.36 (compatible; PetalBot;+https://webmaster.petalsearch.com/site/petalbot) upstream_addr=127.0.0.1:8443 upstream_status=200 request_time=0.146 upstream_response_time=0.144 upstream_connect_time=0.004 upstream_header_time=0.140 upstream_cache_status=MISS cookie_mbbauth_present=0 isFilter=1 main_upstream=filter cookie_gender=- cookie_abtest=- | "14/Apr/2022:00:01:29 +0200" client=114.119.147.209 country=CN is_bot=1 method=GET request="GET /marken/giorgio-armani/kurzarmhemden/ HTTP/1.1" request_length=414 status=200 bytes_sent=37876 body_bytes_sent=37376 referer=- user_agent=Mozilla/5.0 (Linux; Android 7.0;) AppleWebKit/537.36 (KHTML, like Gecko) Mobile Safari/537.36 (compatible; PetalBot;+https://webmaster.petalsearch.com/site/petalbot) upstream_addr=127.0.0.1:8443 upstream_status=200 request_time=0.146 upstream_response_time=0.144 upstream_connect_time=0.004 upstream_header_time=0.140 upstream_cache_status=MISS cookie_mbbauth_present=0 isFilter=1 main_upstream=filter cookie_gender=- cookie_abtest=- |
| </code> |
| </WRAP> |
| |
| then use this command: |
| |
cat /var/log/nginx/access.log | awk '{print $4}' | uniq -c | sort -rn | head | cat /var/log/nginx/access.log | awk '{print $4}' | uniq -c | sort -rn | head |