A high-performance Rust CLI tool for parsing and analyzing server log files (Nginx, Apache, and custom formats). It provides statistical insights, error extraction, anomaly detection, and export capabilities to JSON or CSV.
- Multi-format Support: Parse Nginx, Apache, and custom log formats using regex patterns
- Parallel Processing: Utilizes Rayon for fast, parallel log parsing with progress indicators
- Comprehensive Analysis:
- Request statistics (total requests, error rates, average response sizes)
- Error extraction and summarization
- Anomaly detection based on patterns
- Export Options: Export analysis reports to JSON or CSV formats
- CLI Interface: Simple command-line interface with Clap
Ensure you have Rust installed (edition 2021 or later). Then:
git clone <repository-url>
cd log-analyzer
cargo build --releaseThe binary will be available at target/release/log-analyzer.
cargo install --git <repository-url> log-analyzerAnalyze a log file with default settings (Nginx format, JSON export):
log-analyzer analyze --file /path/to/access.logFor Apache logs:
log-analyzer analyze --file /path/to/access.log --format apacheFor custom format:
log-analyzer analyze --file /path/to/custom.log --format customExport to CSV:
log-analyzer analyze --file /path/to/access.log --output report.csv --export-format csvExport to JSON:
log-analyzer analyze --file /path/to/access.log --output report.json --export-format jsonFocus on error entries only:
log-analyzer analyze --file /path/to/access.log --errors-onlylog-analyzer analyze \
--file /var/log/nginx/access.log \
--format nginx \
--output analysis.json \
--export-format json \
--errors-onlyThe tool will output a summary table to stdout and optionally save detailed results to the specified file.
The analysis report includes:
- Statistics: Total requests, error count and rate, average response size
- Errors: Summarized error information
- Anomalies: Detected unusual patterns in the logs
We welcome contributions! Please follow these guidelines:
-
Clone the repository:
git clone <repository-url> cd log-analyzer
-
Build the project:
cargo build
-
Run tests:
cargo test -
Run benchmarks:
cargo bench
- Follow Rust standard formatting:
cargo fmt - Run clippy for linting:
cargo clippy - Ensure all tests pass before submitting
- Create a feature branch:
git checkout -b feature/your-feature - Implement your changes
- Add tests for new functionality
- Update documentation if needed
- Submit a pull request
- Use GitHub issues for bug reports and feature requests
- Include log samples and error messages when reporting bugs
- Specify your Rust version and OS
This project is licensed under the MIT License. See LICENSE file for details.
clap: Command-line argument parsingregex: Regular expression matchingserde&serde_json: Serializationcsv: CSV exportchrono: Date/time handlinganyhow&thiserror: Error handlingrayon: Parallel processingindicatif: Progress bars