An intelligent log analysis tool with LLM-powered keyword extraction, context retrieval, and automated issue analysis.
- Python 3.10+ (3.11, 3.12, or 3.13 recommended)
- pip (Python package installer)
- Optional: Local LLM server (LM Studio or Ollama) for keyword extraction
# Clone the repository
git clone <repository-url>
cd log_analyzer
# Create virtual environment (recommended)
python -m venv log_analyzer_env
# Activate virtual environment
# Windows:
log_analyzer_env\Scripts\activate
# macOS/Linux:
source log_analyzer_env/bin/activate
# Install dependencies
pip install -r requirements.txt# Start the web server
python ui/app.py
# Open browser to: http://localhost:5000Usage:
- Upload a log file
- Describe the issue
- Select filter method:
- LLM keywords: Extracts keywords and filters log (requires LLM setup)
- Vector DB: Semantic search (mock implementation)
- Configure analysis options
- Click "Analyze Logs"
# Basic usage
python main.py --log-file app.log --keywords "error,timeout"
# Advanced usage
python main.py --log-file app.log --keywords "snapshot,periodic" \
--start-date 2025-10-15 --end-date 2025-10-16 \
--max-tokens 3500 --deduplicate --prioritize-severitylog_analyzer/
├── main.py # CLI entry point
├── log_analyzer_system.py # Orchestration layer (for web UI)
│
├── modules/ # Core modules (REPLACEABLE)
│ ├── __init__.py # Exports all modules
│ ├── domain.py # Data models (Request, Result)
│ ├── result_handler.py # Result parsing & saving
│ ├── log_analyzer.py # Log filtering & analysis
│ ├── keyword_extractor.py # LLM-based keyword extraction
│ ├── context_retriever.py # Context from JSON files
│ └── prompt_generator.py # Prompt generation for LLM
│
├── ui/
│ ├── app.py # Flask web application
│ └── templates/
│ └── index.html # Web UI
│
├── assets/
│ ├── context/ # JSON context files
│ │ ├── components/ # Codebase components
│ │ ├── docs/ # Documentation
│ │ └── errors/ # Error patterns
│ ├── uploads/ # Uploaded log files
│ └── results/ # Analysis results
│
├── requirements.txt
└── README.md
main.py- CLI tool for command-line log analysisui/app.py- Web UI server (Flask application)
log_analyzer_system.py- Orchestrates analysis workflow, coordinates all modules
domain.py- Data models (AnalysisRequest, AnalysisResult)log_analyzer.py- Filters and analyzes log files using keyword matchingkeyword_extractor.py- Extracts keywords from issue descriptions using LLMvector_filter.py- Filters logs using vector DB semantic search (mock)context_retriever.py- Retrieves relevant context from JSON filesprompt_generator.py- Generates prompts for LLM analysisresult_handler.py- Parses and saves analysis results
assets/context/components.json- Codebase componentsassets/context/documentation.json- Documentationassets/context/errors.json- Error patterns and solutions
All modules in modules/ can be independently replaced.
- Create new file:
modules/my_keyword_extractor.py - Implement the same interface:
class MyKeywordExtractor:
def extract_keywords(self, issue_description: str) -> List[ExtractedKeyword]:
# Your implementation
pass
def is_llm_available(self) -> bool:
# Your implementation
pass- Update
modules/__init__.py:
from .my_keyword_extractor import MyKeywordExtractor
__all__ = [..., 'MyKeywordExtractor']- Update imports in
log_analyzer_system.py:
from modules import MyKeywordExtractor
self.keyword_extractor = MyKeywordExtractor()Replace MockVectorLogFilter in modules/vector_filter.py:
class MyVectorLogFilter(VectorLogFilter):
def filter(self, issue_description: str, log_file_path: str) -> str:
# Connect to your vector DB
# Embed issue description
# Find similar log entries
# Return filtered logs
pass| Module | Key Methods |
|---|---|
| KeywordExtractor | extract_keywords(description) -> List[ExtractedKeyword], is_llm_available() -> bool |
| VectorLogFilter | filter(issue_description, log_file_path) -> str |
| ContextRetriever | retrieve_codebase_context(keywords) -> dict, retrieve_documentation_context(keywords) -> dict, retrieve_error_context(keywords) -> dict |
| PromptGenerator | format_context(context, type) -> str, generate_prompt(analysis_data) -> str |
| LogAnalyzer | analyze(keywords, start_date, end_date) -> str |
| ResultHandler | parse_filtered_logs(logs) -> dict, save_result(result, output_dir, timestamp) -> str |
- Install dependencies:
pip install -r requirements.txt - Run web UI:
python ui/app.py - Open browser:
http://localhost:5000 - Upload log file and describe issue
- Get AI-powered analysis
The system uses LLM for keyword extraction. Configure it in the web UI:
- Start LM Studio or Ollama
- Enter LLM URL (default:
http://127.0.0.1:1234) - Enter model name
- Click "Analyze Logs"
Without LLM, the system will prompt you to enter keywords manually.
- CLI: Saves filtered logs to
filtered_logs.txt(or custom path) - Web UI: Saves full analysis results to
assets/results/analysis_result_<timestamp>.json
Import errors: Make sure you're in the project root and have activated the virtual environment.
Flask not found: Run pip install -r requirements.txt
Port 5000 in use: Change port in ui/app.py or kill the process using that port.
LLM connection failed: Ensure your LLM server (LM Studio/Ollama) is running and the URL/model are correct.