Code Monkey home page Code Monkey logo

nginx-parser's Introduction

Nginx Parser

NGINX Parser Preview

How to use

  • Install the nginx-monitor package from pip pip install nginx-monitor.
  • Run it nginx-parser --file=/path/to/nginx/access.log -n 1000
Available command line arguments
usage: nginx-parser [-h] [-f FILE] [-d DELAY] [-n N] [-c CONFIG]

optional arguments:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  The path to the Nginx log file
  -d DELAY, --delay DELAY
                        Seconds to wait between updates
  -n N                  Number of lines to start tailing from
  -c CONFIG, --config CONFIG
                        The path to your configuration file

Configure for different Nginx log formats

nginx-parser works for different Nginx log formats. You can also configure the parser to pull extra variables from your Nginx access log.

Example:

$ cat config.yaml

nginx:
  log_format: '$remote_addr - $remote_user "$time_local" "$request" $status $bytes_sent "$http_referer" "$http_user_agent" "$gzip_ratio" $geo_ip $variable_you_want_to_track'
  extra_variables:
    geoip_org:
      title: ORGs
      width: 50
    variable_you_want_to_track:
      title: My other variable
      width: 55

Then just use your config: nginx-parser --file=/path/to/nginx/access.log -n 1000 --config=config.yaml

TODO

  • Ability to filter by status_code/IP address/URL
  • Better visualizations

nginx-parser's People

Contributors

davarisg avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nginx-parser's Issues

Small Fixes

Installation for the readme says to run: pip install nginx-monitor, but it appears it should be nginx-parser instead: https://pypi.org/project/nginx-parser/0.1/

The time parser cannot handle offsets, instead of '%d/%b/%Y:%H:%M:%S +0000' it should be '%d/%b/%Y:%H:%M:%S %z' here:

TIME_LOCAL_FORMAT = '%d/%b/%Y:%H:%M:%S +0000'
according to documentation on strptime(): https://www.programiz.com/python-programming/datetime/strptime

It would make sense to also be able to override that time string in the configuration too as is done for LOG_FORMAT. Something like:

    def get_time_local_format(self):
        if self.time_local_format is not None:
            return self.time_local_format
        try:
            self.time_local_format = self.yaml_config['nginx']['time_local_format']
        except (KeyError, TypeError):
            self.time_local_format self.TIME_LOCAL_FORMAT
        return self.time_local_format

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.