Git Product home page Git Product logo

log-parser's Introduction

Log-parser

This repository contains tools to parse and aggregate nginx log data locally and serve the results locally over HTTP from a Docker container running simple python http module.

Repository layout:

logs/nginx.log # source log file
web/index.html
    . scripts for web server or configuration
log_parse.py # script to parse and aggregate nginx log then output for web server to display
Dockerfile # docker file to build docker container to run web server

Approach

To print occurrences of each IP and distinct IP from subnets

$ python log_parse.py

To enable access the results from web server

Build the image using the following command.

$ docker build --tag log:v1 .

Run the Docker container using the command shown below.

$ docker run --name log-result -p 8080:8080 log:v1

The result data will be accessible at http:localhost:8080 via browser or curl -i http://localhost:8080

Improvements and ideas

  1. The log parser is only able to parse and process IP address based on the regex, this can be extended to other fields in nginx log, e.g. data, status code.
  2. The log parser is only take one file, and the name and path are hard-coded in the function, this can be improved to take multiple files in a directory.
  3. Once the web server is built, the output result cannot be changed till the docker image is rebuilt as the html file is copied while building the image.
  4. The web server could be improved to use other framework, e.g. flask, apache to give a dynamic way to display the result. For example, getting the python script result while calling the http endpoint.

log-parser's People

Contributors

jadydj avatar jadyliu avatar

Watchers

James Cloos avatar  avatar

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.