High-performance log analysis and visualization toolkit
Project description
๐ snap-analog
Advanced Log Analysis & Visualization Toolkit for Apache Logs
snap-analog is a powerful command-line toolkit for parsing, analyzing, optimizing, and visualizing large-scale Apache log files. It generates both beautiful visual dashboards and structured JSON datasets, making it perfect for DevOps monitoring, security analysis, and data analytics pipelines.
๐ Quick Links
โก Quick Start โข ๐ Features โข ๐ฏ Use Cases โข ๐ฆ Installation โข ๐งช Usage โข ๐ JSON Output โข ๐ก Performance โข ๐จ Visualization Features โข ๐งโ๐ป Development โข ๐ค Contributing โข ๐ License โข ๐ Roadmap โข ๐ Support & Contact โข โญ Show Your Support
โก Quick Start
# Install
git clone https://github.com/batuhannerkoc/snap-analog.git
cd snap-analog
pip install .
# Generate test data
snap-analog generate-test --lines 5000 --output test.log
# Analyze & visualize
snap-analog analyze test.log --visualize
# View dashboard in: reports/dashboard_*.png
That's it! ๐
๐ธ Screenshots
Dashboard Visualization
Terminal Output
๐ Features
- ๐ High-performance log parsing โ optimized for millions of lines
- ๐พ Memory-optimized modes โ
auto,balanced,full,aggressive - ๐ JSON export โ structured data for analytics pipelines and dashboards
- ๐จ Beautiful visualizations โ powered by Matplotlib + Seaborn
- ๐ง Traffic insights โ top IPs, URLs, methods, status groups, time-series
- โ ๏ธ Error rate detection โ automatic threshold alerts
- ๐งช Test log generator โ built-in random data generation
- ๐ Modern CLI โ colorful output with progress bars
- ๐ 6 chart types โ pie charts, bar charts, time-series, heatmaps
๐ฏ Use Cases
| Use Case | Description |
|---|---|
| ๐ฅ Web Server Monitoring | Track traffic patterns, identify bottlenecks |
| ๐ Security Analysis | Detect suspicious IPs, analyze attack patterns |
| ๐ SRE/DevOps Dashboards | Feed data into Grafana, Kibana, or custom tools |
| ๐ API Performance Tracking | Monitor endpoint response times and error rates |
| ๐ Data Analytics | Preprocess logs for ML pipelines |
| ๐งช Performance Testing | Generate realistic test data at scale |
๐ฆ Installation
โ Option 1 โ Virtual Environment (Recommended)
git clone https://github.com/batuhannerkoc/snap-analog.git
cd snap-analog
python3 -m venv venv
source venv/bin/activate # macOS/Linux
# .\venv\Scripts\activate # Windows
pip install -r requirements.txt
pip install .
Verify installation:
snap-analog --help
โ Option 2 โ Direct Install
pip install .
If you encounter "externally managed environment" error:
pip install --user .
โ Option 3 โ Development Mode
pip install -e .
๐งช Usage Examples
Generating Test Logs
# Apache format
snap-analog generate-test --lines 5000 --output logs/test.log --format apache
# JSON format
snap-analog generate-test --format json --lines 3000 --output logs/sample.json
Analyzing Logs
# Basic analysis
snap-analog analyze access.log
# With visualization
snap-analog analyze access.log --visualize
# Aggressive memory mode (for huge files)
snap-analog analyze access.log --mode aggressive
# Custom output path
snap-analog analyze access.log --output reports/result.json
# Quiet mode (no terminal output)
snap-analog analyze access.log --quiet
Visualizing Reports
# Basic visualization
snap-analog visualize reports/log_analysis_20250101_120000.json
# Custom theme and size
snap-analog visualize report.json --theme darkgrid --size large --dpi 200
๐ JSON Output Example
{
"summary": {
"total_lines": 50214,
"total_requests": 48711,
"memory_mode": "balanced",
"file": "access.log",
"analysis_date": "2025-01-12T10:30:45"
},
"health_metrics": {
"success_rate_2xx_3xx": "94.1%",
"client_error_rate_4xx": "3.2%",
"server_error_rate_5xx": "2.7%"
},
"traffic_analysis": {
"top_ips": [
{"ip": "192.168.1.1", "count": 1250},
{"ip": "10.0.0.5", "count": 980}
],
"top_urls": [
{"url": "/api/users", "count": 5420},
{"url": "/home", "count": 3210}
],
"methods": {
"GET": 35420,
"POST": 8940,
"PUT": 2130,
"DELETE": 1221
}
},
"elapsed_time": 3.51
}
๐ Full Schema: View complete JSON structure
๐ Project Structure
snap-analog/
โ
โโโ src/
โ โโโ cli.py # Main CLI entry point
โ โโโ log_analyzer.py # Memory-optimized analyzer
โ โโโ log_visualizer.py # Dashboard generator
โ
โโโ images/
โ โโโ dashboard.png # Dashboard screenshot
โ โโโ terminal.png # Terminal UI screenshot
โ
โโโ sample_logs/ # Sample Log files
โโโ requirements.txt
โโโ setup.py
โโโ LICENSE
โโโ README.md
โ๏ธ Requirements
matplotlib>=3.5.0
seaborn>=0.12.0
pandas>=1.4.0
numpy>=1.22.0
psutil>=5.9.0 # optional, for system info
Install all dependencies:
pip install -r requirements.txt
๐ก Performance Benchmarks
Tested on: MacBook Pro M4, 16GB RAM
| Log Size | Lines | Mode | Time | Memory |
|---|---|---|---|---|
| Small | 10K | auto | 0.5s | 45 MB |
| Medium | 100K | balanced | 2.1s | 120 MB |
| Large | 1M | balanced | 8.4s | 380 MB |
| Huge | 10M | aggressive | 42s | 850 MB |
๐จ Visualization Features
The dashboard includes:
- Status Groups Pie Chart โ 2xx, 3xx, 4xx, 5xx distribution
- Top IPs Bar Chart โ Most active IP addresses
- Top URLs Bar Chart โ Most requested endpoints
- Time-Series Traffic โ Requests over time
- HTTP Methods Distribution โ GET, POST, PUT, DELETE breakdown
- Error Rate Heatmap โ Visual error rate indicators
All visualizations support:
- Custom themes (
white,dark,darkgrid,whitegrid) - Adjustable DPI (72, 100, 150, 200, 300)
- Multiple sizes (
small,medium,large,xlarge)
๐งโ๐ป Development
Editable Install
git clone https://github.com/batuhannerkoc/snap-analog.git
cd snap-analog
pip install -e .
Run CLI Directly
python3 src/cli.py analyze logs/test.log
Code Style
This project follows Black code style:
pip install black
black src/
๐ค Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For bug reports or feature requests, please open an issue.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2025 Batuhan Erkoc
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
๐ Roadmap
- Support for Nginx logs
- Real-time monitoring mode (
snap-analog watch) - HTML report generation
- CSV export option
- Docker image
- PyPI package (
pip install snap-analog) - Filtering capabilities (
--filter "status=500") - Log comparison tool
๐ Support & Contact
- GitHub Issues: Report bugs or request features
- Email: batuhannerkoc@gmail.com
- LinkedIn: Batuhan Erkoc
โญ Show Your Support
If you find this project useful, please consider:
- โญ Starring the repository
- ๐ Reporting bugs
- ๐ก Suggesting new features
- ๐ Contributing code
Developed with โค๏ธ by Batuhan Erkoc
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snap_analog-2.1.0.tar.gz.
File metadata
- Download URL: snap_analog-2.1.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1886e218fe6f1481634dbada3a249c4b1fb3ac2741037b5d1d39e6ebc6b7819e
|
|
| MD5 |
43aa98f4444f423da43108ec3aeac32c
|
|
| BLAKE2b-256 |
3a03c2cd6232fab70e9c60dac557ed41b16395943572c3ccde1163fbf669bd32
|
File details
Details for the file snap_analog-2.1.0-py3-none-any.whl.
File metadata
- Download URL: snap_analog-2.1.0-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0af7367e531cf207ba94f030d94cd2f5c7207c6448bae0b764628bed915061fe
|
|
| MD5 |
cd7f15f3708717ee369e5f1de62c8363
|
|
| BLAKE2b-256 |
fe6143888f2b220cbd73c35040f2faccea103bc031941de8d09011db9dd9d538
|