A log analysis tool with both command-line and web interface capabilities for processing, analyzing, and visualizing log files.
-
Log Processing
- Ingest log files from multiple sources
- Process and transform log data
- Support for various log formats
- Efficient parsing and data extraction
-
Analysis Capabilities
- Pattern detection and anomaly identification
- Component-wise error analysis
- Time-based log distribution analysis
- Statistical analysis of log patterns
-
Web Dashboard
- Interactive real-time statistics
- Visual log pattern analysis
- Component-wise error visualization
- Time-based distribution charts
- Anomaly detection display
- Filterable log entries
- Clone the repository:
git clone https://github.com/yourusername/python-log-analyzer.git
cd python-log-analyzer
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
Analyze log files and generate reports:
python -m src.main --log-dir ./data --output-dir ./output
--log-dir
: Directory containing log files (default: ./data)--output-dir
: Directory to save output files (default: ./output)--anomaly-threshold
: Threshold for anomaly detection in standard deviations (default: 3.0)--verbose
: Enable verbose output--log-format
: Format of the log files (default: standard)
Launch the interactive web dashboard:
python -m src.main --web --log-dir ./data --log-format standard
Then open your browser to http://localhost:5000
processed_logs.csv
: All processed log entriescomponent_stats.csv
: Statistics for each log componentanomalies.csv
: Detected anomalies in log patterns- Various visualization charts
- Real-time statistics display
- Interactive charts and graphs
- Filterable log entry table
- Component-wise analysis
- Time-based distribution views
- Anomaly detection visualization
- Standard format:
YYYY-MM-DD HH:MM:SS [LEVEL] component: message
- Custom formats can be added by extending the parser
python-log-analyzer/
├── data/ # Log files directory
├── src/ # Source code
│ ├── analysis.py # Log analysis logic
│ ├── parser.py # Log parsing logic
│ └── web/ # Web interface
└── tests/ # Test files
python -m pytest tests/
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Flask for the web interface
- Uses Chart.js for data visualization
- Pandas for data analysis
To generate sample log files for testing:
python scripts/sample_logs.py
This will create 15,000 sample log entries across 3 files in the data
directory, simulating various log patterns and anomalies.