Rhit efficient visualization Nginx log viewing tool

Rhit efficient visualization Nginx log viewing tool

Introduction

Rhit can read Nginx log files from standard folders (gzipped compressed files are also acceptable), analyze and count them, and display them in a visual table in the console without generating any unnecessary temporary files or data.

You can filter and match by date, response value, request source, etc. and perform analysis. Rhit is very efficient and can process millions of lines of log data per second.

The following are the results of searching for status codes 1xx and 2xx in the logs for January:

The project address is:

https://github.com/Canop/rhit

Install

Download and use the compiled binary file directly, but you need to make sure that the shell can find the rhit binary file. An easier way to deal with 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

Source code installation depends on the Rust environment. After cloning the GitHub source code, enter the rhit folder and run the following command:

cargo install --path .  

Display Fields

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  

Common nginx log lines 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" 200 0 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"

It consists of several fields: date, remote IP address, path, bytes sent, etc. rhit can execute a list of fields to sort the table. If not specified, it will be displayed by date, status code, source and path by default. If you want to specify multiple fields, separate them with commas, such as -f date,status; to display all fields, use -f all.

Date based. Use --field date, or -f date for short. By default, the length of the bar graph is based on the number of hits, but you can modify the sort key to be based on the number of bytes sent.

IP-based. By default, the remote IP is not displayed. You can use rhit -f ip to display it.

Based on the request method. The HTTP request method is not displayed by default. You can use rhit -f method to display it.

Path based. The command is rhit -f path

Based on Referer. The command is rhit -f ref

Based on status code. The command is rhit -f status

filter

Rhit provides some filters to filter the result list and display some data 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 data greater than a certain time, less than a certain time, or not containing a certain time (using '>', '<', '!' symbols):

Filter by remote IP. The parameter is -i, which filters a specific IP, or excludes a specific IP (using the '!' symbol).

Filter by request method. The parameter is -m, which filters specific methods or excludes specific methods.

To filter by request path, use the -p parameter, which can be exact match or regular expression (for example, all paths start with "download" and end with "exe":, the parameter is -p 'download.*exe$'):

Filter by Referer. The parameter is -r, which is consistent with the syntax for filtering by path:

Filter by status code. The parameter is -s, which filters specific status codes or excludes specific status codes.

Combined screening. The above methods can be combined in any way.

Sort Key

By default, all tables are sorted by hits, which is the sort key, and all values ​​of the sort key are shown in pink, including the histogram. If you are more interested in the number of bytes sent, you can change the sort key to bytes using -kb:

This is the end of this article about Rhit efficient visual Nginx log viewing tool. For more related Rhit Nginx log viewing tool content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed steps to enable Nginx to view access logs in real time

<<:  Two special values ​​in CSS are used to control the inherit and initial methods of the cascade

>>:  How to add links to FLASH in HTML and make it compatible with all major browsers

Recommend

How to assign a public IP address to an instance in Linux

describe When calling this interface, you need to...

Select web page drop-down list and div layer covering problem

Questions about select elements in HTML have been...

The difference and introduction of ARGB, RGB and RGBA

ARGB is a color mode, which is the RGB color mode...

Vue makes a simple random roll call

Table of contents Layout part: <div id="a...

JavaScript to implement limited time flash sale function

This article shares the specific code of JavaScri...

Solution to using html2canvas to process Dom elements with Baidu map into images

Problem 1: Baidu Map uses tiled images (the map i...

How to install babel using npm in vscode

Preface The previous article introduced the insta...

Nginx domain forwarding usage scenario code example

Scenario 1: Due to server restrictions, only one ...

mysql method to view the currently used configuration file my.cnf (recommended)

my.cnf is the configuration file loaded when MySQ...