This project offers a solution for on-demand log monitoring across multiple unix-based servers. With this service, it is no longer necessary to individually access each server and manually open the log files located at /var/log. Instead, by sending a simple REST request to a server, you can easily retrieve its /var/log files. This makes tracking and debugging system events considerably more efficient and user-friendly.
- Install Python 3.10.x
- Install Poetry - Poetry is used for dependency management.
curl -sSL https://install.python-poetry.org | python -
- Install the project dependencies
poetry install
- Run the server
poetry run python app.py
Alternatively you can use poetry shell
to activate the environment and run python commands as you normally would: python app.py
Make a GET request to /logs
to retrieve logs from /var/log
. You can use the following query parameters:
filename
: Specify a filename within/var/log
.term
: Filter results based on this text/keyword.limit
: Specify the last n number of matching entries to retrieve within the log.
For example:
curl http://localhost:5000/logs?filename=syslog&term=error&limit=5
.
├── .env # Environment variables
├── README.md # This file
├── app.py # The main application script
├── views # Request & response handling
└── tests # Tests for the app
└── var
└── log # Directory for local testing of logs
Be sure to create this file for local testing and development.
You can use the .env.example
file to help you get started, just rename it to .env
This file contains environment variables for local development. It is read by dotenv.load_dotenv()
at the start of app.py
.
The environment variables are:
TESTING
: Determines whether the app is running in a local development environment. IfTrue
, the app will read from the localtests/var/log
directory for log files. IfFalse
or not set, the app will read from/var/log
.
This file provides information about the project, including this description of the file structure.
This is the main script for the Flask application. It defines the route for the log reading API and handles requests to that route. The log reading functionality is controlled by environment variables.
This directory is used for local testing of the log reading functionality. When TESTING
is True
, the app will attempt to read log files from this directory. You can place any files you want to test with in this directory.
poetry run python -m unittest
Please open an issue to discuss potential contributions before submitting a pull request.
This project is licensed under the terms of the MIT license.