Skip to main content

High-performance log analysis and visualization toolkit

Project description

๐Ÿ“Š snap-analog

Advanced Log Analysis & Visualization Toolkit for Apache Logs

Python Version License: MIT Code style: black Platform Status

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

Dashboard Example

Terminal Output

Terminal UI


๐Ÿš€ 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:

  1. Status Groups Pie Chart โ€” 2xx, 3xx, 4xx, 5xx distribution
  2. Top IPs Bar Chart โ€” Most active IP addresses
  3. Top URLs Bar Chart โ€” Most requested endpoints
  4. Time-Series Traffic โ€” Requests over time
  5. HTTP Methods Distribution โ€” GET, POST, PUT, DELETE breakdown
  6. 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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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


โญ 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

GitHub followers GitHub stars

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snap_analog-2.1.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snap_analog-2.1.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

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

Hashes for snap_analog-2.1.0.tar.gz
Algorithm Hash digest
SHA256 1886e218fe6f1481634dbada3a249c4b1fb3ac2741037b5d1d39e6ebc6b7819e
MD5 43aa98f4444f423da43108ec3aeac32c
BLAKE2b-256 3a03c2cd6232fab70e9c60dac557ed41b16395943572c3ccde1163fbf669bd32

See more details on using hashes here.

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

Hashes for snap_analog-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0af7367e531cf207ba94f030d94cd2f5c7207c6448bae0b764628bed915061fe
MD5 cd7f15f3708717ee369e5f1de62c8363
BLAKE2b-256 fe6143888f2b220cbd73c35040f2faccea103bc031941de8d09011db9dd9d538

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page