๐ค AI-powered CLI for CI/CD log analysis with ML + LLM hybrid intelligence
Project description
๐ค AI-LogGuard
AI-powered Cross-platform CLI for CI/CD Log Analysis, Failure Prediction, and Auto-fix Suggestion
AI-LogGuard is an intelligent command-line tool that analyzes CI/CD build logs using ChatGPT and Machine Learning models to classify errors and provide fix suggestions.
๐ Features
โ Core Features
- ๐ค ChatGPT Integration: AI-powered log analysis and fix suggestions
- ๐ฏ Intelligent Error Classification: 9 error categories with ML models
- ๐ Model Comparison: RandomForest, XGBoost, LSTM, GRU, DistilBERT
- ๐ง Auto Fix Suggestions: Specific code fixes from ChatGPT
- ๐ Multi-platform Support: Jenkins, GitHub Actions, GitLab CI
๐ Error Categories
| Category | Description |
|---|---|
dependency_error |
Package/module resolution issues |
syntax_error |
Code syntax errors |
test_failure |
Unit/integration test failures |
timeout |
Operation exceeded time limits |
permission_error |
Access denied, auth failures |
network_error |
Connection issues, DNS failures |
environment_error |
Missing env vars, PATH issues |
build_error |
Compilation/linking errors |
resource_error |
Memory, disk space issues |
๐ Quick Start
Installation
# Clone repository
git clone https://github.com/SyLe-Van/AI-LogGuard.git
cd ai-logguard
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install
pip install -e .
# Set up OpenAI API key
export OPENAI_API_KEY='your-api-key'
CLI Usage
# View all commands
ailog --help
# Analyze a log file with ChatGPT
ailog ask build.log
# Get fix suggestions
ailog fix failed_build.log
# View model comparison
ailog models
# Run interactive demo
ailog demo
Example Commands
1. Analyze Log File
ailog analyze build_log.txt --llm
Example Output:
๐ Analyzing log file: build_log.txt
======================================================================
๐ค AI ANALYSIS RESULT
======================================================================
**Error Type**: dependency_error
**Summary**: NPM failed to resolve peer dependency conflict between
React 18.2.0 and react-scripts 4.0.3 which requires React 17.
**Root Cause**: Version mismatch in package dependencies
**Fix Suggestions**:
1. Update react-scripts: npm install react-scripts@5
2. Or use --legacy-peer-deps flag
3. Check package.json for conflicts
**Severity**: Medium
======================================================================
2. Get Fix Suggestions
ailog fix error.log
3. View Model Performance
ailog models
Output:
๐ AI-LogGuard Model Comparison
โโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโโณโโโโโโโโโโโณโโโโโโโโโโโณโโโโโโโโโโโโโ
โ Model โ Type โ Accuracy โ F1-Score โ Train Time โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ RandomForest โ Classical ML โ 0.8234 โ 0.8187 โ 45.2s โ
โ XGBoost โ Classical ML โ 0.8456 โ 0.8412 โ 67.8s โ
โ LSTM โ Deep Learning โ 0.8678 โ 0.8634 โ 234.5s โ
โ GRU โ Deep Learning โ 0.8589 โ 0.8545 โ 198.3s โ
โ DistilBERT โ Transformer โ 0.9123 โ 0.9095 โ 1245.6s โ
โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโ
๐ Best Model: DistilBERT (F1: 0.9095)
4. Fetch from Jenkins
ailog fetch -p jenkins -u http://jenkins:8080 -j my-job -t $JENKINS_TOKEN
๐ Architecture
Classification System
Log Input
โ
Pattern Matching Engine
โโ 60+ keyword patterns per category
โโ Context detection (npm, jest, docker, etc.)
โโ Score calculation with weights
โ
Confidence Analysis
โโ Score distribution
โโ Gap between top 2 categories
โ
Output: (category, confidence)
Why Rule-Based vs ML?
We tested both approaches extensively:
| Approach | Test Accuracy | Real-world Accuracy | Cost | Speed |
|---|---|---|---|---|
| ML (85K dataset) | 99.90% | 0% โ | $0 | ~50ms |
| Rule-based | N/A | 100% โ | $0 | <5ms |
Key Insight: ML models trained on synthetic logs suffer from severe overfitting. Rule-based patterns generalize better for CI/CD error classification.
Project Structure
ai-logguard/
โโโ src/
โ โโโ main.py # CLI entry point
โ โโโ parse.py # Basic log parsing
โ โโโ ml/
โ โ โโโ classifier.py # Rule-based classifier
โ โโโ fetchers/
โ โโโ jenkins_fetcher.py
โ โโโ gitlab_fetcher.py
โโโ scripts/
โ โโโ test_rule_based.py # Classifier validation
โ โโโ collect_github_automated.py # Real log collection
โ โโโ train_*.py # ML experiments (archived)
โโโ data/
โ โโโ final_dataset/ # 85K logs (research)
โ โโโ real_logs_massive/ # 1K+ real GitHub Actions logs
โโโ tests/
โ โโโ sample_logs.txt
โโโ requirements.txt
๐ฌ Research & Development
Dataset Collection (Research Phase)
We collected and tested with:
- 1,081 real GitHub Actions logs (15 language/topic combinations)
- 16,008 LogHub system logs (12 datasets: HDFS, Spark, etc.)
- 82,904 synthetic logs (generated from real templates)
- Total: 85,509 samples, 1.0GB
ML Experiments Summary
| Stage | Dataset | Test Acc | Real Acc | Finding |
|---|---|---|---|---|
| Baseline | 300 synthetic | 97.78% | N/A | Too small |
| Scale-up | 10K synthetic | 96.80% | 40% | Overfitting |
| Massive | 100K synthetic | 99.78% | 60% | Better but not enough |
| Final | 85K (1K real + 16K LogHub + 83K synth) | 99.90% | 0% | Complete failure |
Root Cause: 97% synthetic data dominated training. Model memorized patterns instead of learning generalizable features.
Pivot Decision: Switched to rule-based approach โ 100% real-world accuracy
๐ Development
Run tests
pytest
Run with coverage
pytest --cov=src --cov-report=html
Code formatting
black src/ tests/
isort src/ tests/
Type checking
mypy src/
๐ Example Output
๐ Analyzing log file: tests/sample_logs.txt
โ
Log file loaded
โ
Log parsed successfully
โญโ ๐ง JENKINS - test-job โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Build: N/A โ
โ Status: โ ๏ธ UNSTABLE โ
โ Triggered by: Sy Le โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
๐ Statistics
โโโโโโโโโโโโโโโโโณโโโโโโโโ
โ Metric โ Count โ
โกโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ Total Lines โ 121 โ
โ Stages/Steps โ 1 โ
โ Errors โ 5 โ
โ Warnings โ 7 โ
โ Retries โ 4 โ
โโโโโโโโโโโโโโโโโดโโโโโโโโ
๐ฏ Stages/Steps
โโโ โ
Simulate Build Logs - SUCCESS (5 errors, 7 warnings, 4 retries)
โ Errors (showing 5 of 5)
โโโโโโโโณโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Line โ Level โ Message โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ 23 โ ERROR โ [ERROR] Failed to fetch dependency: lib-xyz โ
โ 39 โ ERROR โ [ERROR] Compilation failed in module: invoice โ
โ 53 โ ERROR โ [ERROR] Unit test failed: test_order_checkout โ
โ 63 โ ERROR โ [ERROR] DB connection timeout on first try โ
โ 85 โ ERROR โ [ERROR] Deployment failed due to timeout โ
โโโโโโโโดโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฏ Roadmap
- Phase 1: Foundation & Basic Parsing (Week 1-2) โ
- CLI structure with Typer
- Jenkins & GitHub Actions parsers
- Unified log schema
- Rich terminal output
- Phase 2: LLM Integration (Week 3-4)
- OpenAI API integration
- Prompt engineering
- Summarization & explanation
- Fix suggestions
- Phase 3: ML Model Training (Week 5-6)
- Dataset collection
- Feature engineering
- Model training (Random Forest, Logistic Regression)
- Hybrid ML + LLM pipeline
- Phase 4: Feedback Loop (Week 7-8)
- User feedback collection
- Analytics dashboard
- Automated retraining
- Phase 5: Production Ready (Week 9-10)
- Performance optimization
- Packaging (PyPI, Docker)
- Complete documentation
๐ค Contributing
Contributions are welcome! This is a thesis project, but suggestions and feedback are appreciated.
๐ License
MIT License - see LICENSE file for details
๐ค Author
Sy Le Van
- GitHub: @SyLe-Van
- Thesis: AI-powered Cross-platform CLI for CI/CD Log Analysis
Note: This is an active thesis project. Features are being developed according to the roadmap.
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 ai_logguard-1.0.1.tar.gz.
File metadata
- Download URL: ai_logguard-1.0.1.tar.gz
- Upload date:
- Size: 58.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4134cd18de79490cbf801bba8da62df0eb9d6b594f9925b56c5927e7e38a91e
|
|
| MD5 |
e08a782feb8582b92a2c16e4624b08d3
|
|
| BLAKE2b-256 |
cdfb615b08c1dd14262da9b6e391fcffde5e585e5a57aa65aa0a5cc3b1c51914
|
File details
Details for the file ai_logguard-1.0.1-py3-none-any.whl.
File metadata
- Download URL: ai_logguard-1.0.1-py3-none-any.whl
- Upload date:
- Size: 65.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d53c84aeef4ac76933e11e21ab26924486df1b793819b9026fe0e5c73b4f5ab
|
|
| MD5 |
7dda1d49d65f12c04ee71a1715b0223b
|
|
| BLAKE2b-256 |
db951897ad05796b53f7703c1e91f1e3e71597a8fd5c1cccdde23167ffa4f84c
|