Skip to main content

๐Ÿค– AI-LogGuard

Python 3.9+ License: MIT

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.


Metadata

Release files for ai-logguard 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai-logguard 1.0.1
File Size Uploaded Provenance Actions
ai_logguard-1.0.1.tar.gz 58.4 kB Without provenance Details for ai_logguard-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ai-logguard 1.0.1
File Interpreter ABI Platform Actions
ai_logguard-1.0.1-py3-none-any.whl Python 3 none any Details for ai_logguard-1.0.1-py3-none-any.whl

Total release size: 124.2 kB

Release files / ai_logguard-1.0.1.tar.gz

Download URL ai_logguard-1.0.1.tar.gz
Size 58.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e4134cd18de79490cbf801bba8da62df0eb9d6b594f9925b56c5927e7e38a91e
BLAKE2b-256 checksum
How to use checksums
cdfb615b08c1dd14262da9b6e391fcffde5e585e5a57aa65aa0a5cc3b1c51914
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ai_logguard-1.0.1-py3-none-any.whl

Download URL ai_logguard-1.0.1-py3-none-any.whl
Size 65.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d53c84aeef4ac76933e11e21ab26924486df1b793819b9026fe0e5c73b4f5ab
BLAKE2b-256 checksum
How to use checksums
db951897ad05796b53f7703c1e91f1e3e71597a8fd5c1cccdde23167ffa4f84c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Security for ai-logguard 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page