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

Using JS to implement a simple calculator

Use JS to complete a simple calculator for your r...

Solution to the problem that Java cannot connect to MySQL 8.0

This article shares a collection of Java problems...

Implementation of CSS3 3D cool cube transformation animation

I love coding, it makes me happy! Hello everyone,...

Summary of the dockerfile-maven-plugin usage guide

Table of contents pom configuration Setting.xml c...

Introduction to HTML page source code layout_Powernode Java Academy

Introduction to HTML page source code layout This...

IDEA graphic tutorial on configuring Tomcat server and publishing web projects

1. After creating the web project, you now need t...

Example of using docker compose to build a consul cluster environment

Basic concepts of consul Server mode and client m...

Vendor Prefix: Why do we need a browser engine prefix?

What is the Vendor Prefix? Vendor prefix—Browser ...

Detailed explanation of Vue's sync modifier

Table of contents 1. Instructions 2. Modifiers 3....

Linux directory switching implementation code example

Switching files is a common operation in Linux. W...

JavaScript to implement a simple shopping form

This article shares the specific code of JavaScri...

HTML table tag tutorial (17): table title vertical alignment attribute VALIGN

The table caption can be placed above or below th...

Example of using Vue built-in component keep-alive

Table of contents 1. Usage of keep-alive Example ...