How to use Rhit to efficiently visualize Nginx log viewing tool
This article focuses on "how to use Rhit efficient visualization Nginx log viewing tool", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use Rhit to effectively visualize the Nginx log viewing tool.
Catalogue
Brief introduction
Installation
Show field
Screening
Sort key
Brief introduction
Rhit can read Nginx log files from standard folders (or gzipped compressed files), analyze and count them, and display them in a visual table in the console without generating any extra temporary files or data.
It can be filtered and analyzed by date, response value, request source, and so on. Rhit is very efficient and can process millions of lines of log data per second.
The following is the result of finding the status code of 1xx and 2xx in the January log:
The project address is:
Https://github.com/Canop/rhit
Installation
Download the compiled binaries directly, but you need to make sure that shell can find the rhit binaries, and an easier way to handle it is to put it in the / usr/local/bin directory and add executable permissions to it.
Chmod + x rhit / / download address https://dystroy.org/rhit/download
Install from crates.io, depending on the Rust environment, use the following command to install:
Cargo install rhit
Install the source code, depending on the Rust environment. After clone the github source code, go to the rhit folder and run the following command:
Cargo install-- path. Show field
Rhit can automatically open the nginx log file in the default directory, or you can specify the log path in the command line parameters:
Rhit my/archived/logs
The common log lines for nginx are as follows:
178.133.125.122-[21/Jan/2021:05:49:52 + 0000] "HEAD / broot/download/x86_64-pc-windows-gnu/broot.exe HTTP/1.1" 2000 "-" Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) "
It consists of several fields: date, remote IP address, path, bytes sent, and so on. Rhit can perform a list of fields sorted by the table, which, if not specified, is displayed by default by date, status code, source, and path. If you want to specify multiple fields, split them with commas, such as-f date,status; to show all fields, and use-f all.
Based on date. Use-- field date, or abbreviated to-f date. By default, the length of the bar chart is counted based on the number of hits, or you can modify the sort key to count based on the number of bytes sent.
Based on IP. Remote IP is not displayed by default, but can be displayed using rhit-f ip.
Based on the request method. The HTTP request method is not displayed by default, but can be displayed using rhit-f method.
Based on path. The command is rhit-f path
Based on Referer. The command is rhit-f ref
Based on the status code. The command is rhit-f status
Screening
Rhit provides filters to filter the list of results and show some data that you want to see or don't want to see.
Filter by date. Accurate to the day, the date format is year / month / day, such as filtering data from 2021-2-15 to 2021-2-20, you can also filter greater than a certain time, less than a certain time, or does not include a certain time (using'>','