How to get number of status messages of a Nginx reverse proxy or web server?

It is important to know the number of status messages of a Nginx reverse proxy or web server. Especially those of 301 and 404. By following these numbers, you may have information about the traffic which arrives at your server, and you may take action according to these numbers.

Note that, if you are using Nginx as a reverse-proxy or load-balancer in front of the Docker containers, you should check access.log file in each container’s /var/log/access.log

To see these numbers, you may the following “awk” bash code. To get further information about status codes

 [12:51:11] root:nginx # awk '{print $9}' /var/log/nginx/access.log | sort | uniq -c | sort - rn
 20125 200
 2240 301
 610 206
 552 404
 289 502
 247 499
 62 304
 26 302
 6 500
 2 405
 1 400
 [12:51:21] root:nginx #
 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s