This tool is a rewrite of ngxtop to make it easier to install and hopefully run faster. For those unfamiliar with the ngxtop, it is a tool that helps you parse NGINX access logs and print various statistics from them regardless of format. It is currently not as feature complete as the original version but it should have enough functionality to be usable.
There are a few ways to install it. The easiest way is to grab a release from here. Otherwise, you can install it from crates.io with a working Rust installation:
```sh cargo install topngx
cargo install topngx --features bundled-sqlite ```
SQLite development headers are easy to get on Mac and Linux:
```sh
brew install sqlite
sudo apt-get update && sudo apt-get install libsqlite3-dev ```
```sh topngx 0.3.0 Garrett Squire github@garrettsquire.com top for NGINX
USAGE: topngx [FLAGS] [OPTIONS] [SUBCOMMAND]
FLAGS: -t, --follow Tail the specified log file. You cannot tail standard input -h, --help Prints help information -V, --version Prints version information
OPTIONS:
-a, --access-log
SUBCOMMANDS: avg Print the average of the given fields help Prints this message or the help of the given subcommand(s) info List the available fields as well as the access log and format being used print Print out the supplied fields with the given limit query Supply a custom query sum Compute the sum of the given fields top Find the top values for the given fields ```
Some example queries are:
```sh
topngx < /path/to/access.log
count avgbytessent 2XX 3XX 4XX 5XX 2 346.5 2 0 0 0 requestpath count avgbytessent 2XX 3XX 4XX 5XX GET / HTTP/1.1 1 612 1 0 0 0 GET /somefile1 HTTP/1.1 1 81 1 0 0 0
topngx info < access.log
topngx -f '$remoteaddr - $remoteuser [$timelocal] "$request" $status $bytessent' info
access log file: STDIN access log format: $remoteaddr - $remoteuser [$timelocal] "$request" $status $bytessent available variables to query: remoteaddr, remoteuser, timelocal, requestpath, statustype, bytessent
topngx query -q 'select * from log where bytessent > 100' -f requestpath bytes_sent < access.log ```
There is no option to filter the data but this could be added in the future. The original version allowed for automatic detection of NGINX configuration files, log file paths, and log format styles. topngx currently has command line options for these and may add this functionality in a later version.
If you find any other issues or features that may be missing, feel free to open an issue. You can also utilize logging via the env_logger crate.
```sh
RUST_LOG=debug topngx < /path/to/access.log ```
MIT
The ngxtop license can be seen here.