Reputation: 96
I have unix server running nginx Debian GNU/Linux 9
I am trying to get requests count per IP per request in Nginx access.log file for analysis, so I have 2 questions:
IP count 127.0.0.1 4 127.0.0.2 5 127.0.0.3 6
i found this, but it just counts ips
sudo awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -nr
Upvotes: 3
Views: 11866
Reputation: 63
Yes, you can use grep in the first command :
grep '12/Jan/2021' access.log | awk '{print $1}' | sort | uniq -c | sort -nr
and for certain date using extended regular expression :
grep -E '11/Jan/2021|12/Jan/2021' access.log | awk '{print $1}' | sort | uniq -c | sort -nr | head -20
Upvotes: 6