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.
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
$ python log_parse.py
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
- 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.
- 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.
- 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.
- 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.