Ngxtop is a free, real-time server monitoring tool for NGINX. It automatically parses the access and error logs of NGINX server and tracks key server metrics such as request count, request URI, requests per status code, and more. In this article, we will look at how to install and configure Ngxtop to parse log files. You can use it to easily monitor NGINX log files.
How to Monitor NGINX Log Files Using NgxTop in Ubuntu
Here are the steps to monitor NGINX log files using Ngxtop in Ubuntu.
1. Install Python & PIP
Ngxtop is a python based tool so you need to install & pip tools. Every Ubuntu system comes installed with a system python & its corresponding pip tool. You may use it or install a different version separately. We will install python 3 and its pip for our requirement.
$ sudo apt-get install nginx python3 python3-pip -y
2. Install Ngxtop
Using pip, install Ngxtop with the following command.
$ sudo pip3 install ngxtop
Confirm installation with the following command, that displays its version.
$ sudo ngxtop --version
3. How to Use Ngxtop to Monitor NGINX log files
You can use Ngxtop by simply calling it from terminal
$ sudo ngxtop
You will see the following kind of output that displays summary information such as total number of requests, average number of bytes sent, no. of requests by status code. It also displays detailed information about the most requested URLs on your website/application.
If you have multiple log files, you can specify which log file to use with -l option followed by log file path.
$ sudo ngxtop -l /var/log/nginx/access.log
To list the top 10 IP’s accessing your server, run the following command.
$ sudo ngxtop --group-by remote_addr -l /var/log/nginx/access.log
To find top 10 most data consuming requests, run the following command.
$ sudo ngxtop --order-by 'avg(bytes_sent) * count' -l /var/log/nginx/access.log
If you need to know the list of all available options for ngxtop, just use –help option
$ sudo ngxtop --help
That’s it. In this article, we have seen how to install and use ngxtop tool to easily monitor NGINX server logs.
Ngxtop is a useful server log monitoring tool that allows you to easily parse and track key server metrics in real-time. It is highly recommended utility especially if you are using NGINX server.
Also read :
How to Install Apache Tomcat with NGINX in Debian Linux
How to Install OpenOffice in Ubuntu
Install Keepalived in CentOS 7 from source
How to Find Hardware Details in Ubuntu
How to Install Ghost Blog with NGINX
Related posts:
Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.