Skip to content

xXRoxXeRXx/log-scanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

91 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” Nextcloud Log Analyzer - Web Edition

Modern web-based log analysis tool for Nextcloud Server and Client logs with intelligent root cause detection.

Docker FastAPI Python Alpine.js Security


✨ Features

🎯 Intelligent Analysis

  • πŸ€– Root Cause Detection - Automatically identifies common issues:
    • πŸ”΄ Redis connection errors and cluster failures
    • πŸ’Ύ S3/ObjectStore problems (503 errors, connection issues)
    • 🌐 WebDAV protocol errors
    • 🐘 PHP errors (fopen, TypeError detection)
    • πŸ”’ File locking problems
    • πŸ“ Client sync errors (404, 403, network failures)
  • πŸ“Š Click-to-Filter - Click any root cause card to instantly filter affected logs
  • 🎨 Severity Levels - Color-coded cards (Critical/High/Medium/Low)
  • πŸ’‘ Solution Suggestions - Specific troubleshooting steps for each issue

πŸ”’ Security (v2.0.1+)

  • πŸ›‘οΈ CORS Protection - Configurable allowed origins (no more wildcards)
  • 🚦 Rate Limiting - DoS protection (5 uploads/min, 30 API calls/min)
  • πŸ” API Key Auth - Optional authentication for production
  • πŸ—‘οΈ Auto-Cleanup - Automatic deletion of old results (7 days default)
  • πŸ“ Size Limits - Enforced file size and type validation
  • See SECURITY.md for complete security guide

πŸ“ˆ Advanced Features

  • πŸ“ Multi-File Upload - Analyze up to 15 files simultaneously (2GB limit per file)
  • πŸ“¦ ZIP Archive Support - Direct upload of Nextcloud client debug.zip files
  • πŸ—œοΈ Compression Support - Direct processing of .gz / .gzip files
  • πŸ” Smart Filters - Date range, username, search text, category filters
  • πŸ“± Responsive Design - Works on desktop, tablet, and mobile
  • πŸ“Š Interactive Charts - Visual statistics with Chart.js
  • 🎭 Dual Format Support - JSON (Server) and Text (Client) logs
  • ⚑ High Performance - FastAPI backend with async processing
  • 🐳 Docker Ready - One-command deployment

🎨 Modern UI

  • πŸŒ™ Dark Mode Toggle - Switch between light and dark themes
  • πŸ’Ύ Download Results - Export as JSON or CSV
  • 🎨 Enhanced Drag & Drop - Visual feedback with file counter
  • Smooth Animations - Professional transitions and effects
  • Pagination - 100 entries per page for optimal performance

πŸš€ Quick Start

🐳 Docker Deployment (Recommended)

# Using Docker Compose
docker-compose up -d

# Or using the start script
./start-web.sh    # Linux/macOS
start-web.ps1     # Windows

Access: http://localhost:8000

See docs/DOCKER.md for detailed Docker documentation


πŸ’» Local Development

Requirements:

  • Python 3.11+ (3.11, 3.12 tested, 3.13 not yet supported due to pydantic-core compatibility)
  • pip

Setup:

# 1. Clone repository
git clone https://github.com/xXRoxXeRXx/log-scanner.git
cd log-scanner

# 2. Install dependencies
pip install -r requirements.txt

# 3. Start server
cd backend
python -m uvicorn main:app --reload --host 0.0.0.0 --port 8000

Access: http://localhost:8000


πŸ“– Usage Guide

1️⃣ Upload Logs

Drag & Drop:

  • Drag one or multiple log files into the upload area
  • Visual feedback shows file count during drag

File Selector:

  • Click "Choose Files" button
  • Select up to 15 files (max 2GB per file)

Supported Formats:

  • Server Logs - JSON format from Nextcloud server
  • Client Logs - Text format from desktop/mobile clients
  • Compressed - Automatic .gz decompression
  • ZIP Archives - Auto-extract Nextcloud client debug.zip

2️⃣ View Analysis

Root Cause Analysis:

  • Automatically appears at the top if issues detected
  • Color-coded cards show severity and frequency
  • Click any card to filter affected logs

Statistics Overview:

  • Total entries and category breakdown
  • Interactive pie chart
  • Only non-zero categories displayed

Log Entries:

  • Paginated table (100 per page)
  • Date, time, type, user, error code, message
  • Type-based color coding

3️⃣ Filter Results

Available Filters:

  • Date Range - From/To date picker
  • Username - Select specific user
  • Search - Free text search in messages
  • Category - Filter by log category

Quick Filter:

  • Click any root cause card to auto-filter
  • Shows only affected log entries

4️⃣ Export Data

  • πŸ’Ύ JSON - Download complete analysis as JSON
  • πŸ“Š CSV - Export filtered entries as CSV spreadsheet

πŸ”§ Configuration

Environment Variables

Create a .env file (copy from .env.example):

# Security
ALLOWED_ORIGINS=http://localhost:8000
ENABLE_AUTH=false
API_KEY=your-super-secret-key-here

# Rate Limiting
RATE_LIMIT_ENABLED=true
RATE_LIMIT_UPLOAD=5/minute
RATE_LIMIT_API=30/minute

# File Limits
MAX_FILE_SIZE_MB=2048
MAX_FILES=15

# Cleanup
AUTO_CLEANUP_ENABLED=true
RESULT_RETENTION_DAYS=7

# Timeouts
UVICORN_TIMEOUT_KEEP_ALIVE=300
REQUEST_TIMEOUT=600

See .env.example for complete documentation


πŸ“‚ Project Structure

log-scanner/
β”œβ”€β”€ backend/              # FastAPI application
β”‚   β”œβ”€β”€ static/          # Frontend (HTML/CSS/JS)
β”‚   β”‚   β”œβ”€β”€ index.html   # Upload page
β”‚   β”‚   └── results.html # Analysis results
β”‚   └── main.py          # API endpoints
β”œβ”€β”€ shared/               # Shared parsers
β”‚   β”œβ”€β”€ web_parser.py    # Main analysis logic
β”‚   β”œβ”€β”€ server_parser.py # Server log parser
β”‚   β”œβ”€β”€ client_parser.py # Client log parser
β”‚   └── data_store.py    # Data management
β”œβ”€β”€ tests/                # Test suite (44 tests)
β”œβ”€β”€ docs/                 # Documentation
β”‚   β”œβ”€β”€ DOCKER.md        # Docker guide
β”‚   └── CHANGELOG-SECURITY.md
β”œβ”€β”€ logs/                 # Application logs
β”œβ”€β”€ uploads/              # Uploaded files (temp)
β”œβ”€β”€ results/              # Analysis results
β”œβ”€β”€ Dockerfile            # Docker build
β”œβ”€β”€ docker-compose.yml    # Docker orchestration
└── requirements.txt      # Python dependencies

πŸ§ͺ Testing

# Run all tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=backend --cov=shared --cov-report=html

# Run specific test file
pytest tests/test_security_features.py -v

Test Suite:

  • 44 tests covering parsers, API, and security
  • Security tests for CORS, rate limiting, auth
  • Integration tests for file upload and analysis
  • See .github/workflows/ci-cd.yml for CI/CD

πŸ› Common Issues

Upload Timeout

Problem: Large files (>100MB) timeout during upload

Solution: Timeouts are set to 10 minutes (frontend) and 5 minutes (backend keep-alive)

  • Should handle files up to 500MB
  • For larger files, use local development mode

Missing server_info Entries

Problem: Only some log entries shown in results

Solution: Fixed in v2.0.3 - all entry categories now displayed

Python 3.13 Compatibility

Problem: Tests fail on Python 3.13 with pydantic-core error

Solution: Use Python 3.11 or 3.12 until pydantic-core adds 3.13 support


πŸ”’ Security

This project follows security best practices:

  • βœ… No wildcard CORS
  • βœ… Rate limiting on all endpoints
  • βœ… Optional API key authentication
  • βœ… Automatic cleanup of old data
  • βœ… Input validation and sanitization
  • βœ… Size limits enforced

See SECURITY.md for:

  • Security policy
  • Vulnerability reporting
  • Supported versions
  • Security features

πŸ“Š Statistics

  • Version: 2.0.3
  • Lines of Code: ~3,000
  • Test Coverage: 85%+
  • Test Suite: 44 tests
  • Docker Image: ~200MB
  • Supported Formats: .log, .txt, .json, .gz, .zip

🀝 Contributing

Contributions are welcome! Please:

  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

Please ensure:

  • All tests pass (pytest tests/)
  • Code follows project style
  • Security features are not compromised

πŸ“ Changelog

v2.0.3 (2025-11-20)

  • ✨ Added Dark Mode toggle with localStorage persistence
  • πŸ’Ύ Added download results as JSON/CSV
  • 🎨 Enhanced drag & drop feedback with file counter
  • πŸ› Fixed server_info entries not being returned
  • πŸ”§ Consolidated logs/uploads/results to absolute paths
  • πŸ“š Reorganized documentation structure

v2.0.2 (2025-11-19)

  • πŸ“Š Added upload progress bar (0-100%)
  • ⏱️ Increased upload timeout to 10 minutes
  • ⚑ Improved large file handling (up to 500MB)

v2.0.1 (2025-11-19)

  • πŸ”’ Comprehensive security hardening
  • πŸ›‘οΈ CORS protection (no more wildcards)
  • 🚦 Rate limiting (DoS protection)
  • πŸ” Optional API key authentication
  • πŸ—‘οΈ Auto-cleanup of old results
  • πŸ§ͺ Added 22 security tests
  • πŸ“ CI/CD pipeline with 5 jobs

See docs/CHANGELOG-SECURITY.md for detailed security changes


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • FastAPI - Modern, fast web framework
  • Alpine.js - Lightweight reactive framework
  • Chart.js - Beautiful charts
  • Docker - Containerization platform
  • Nextcloud Community - For the awesome platform

⭐ If you find this project useful, please give it a star on GitHub! ⭐

Report Bug Β· Request Feature Β· Docker Documentation

About

Nextcloud - Modern web-based log analysis tool for Nextcloud Server and Client logs with intelligent root cause detection.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors