π« The Pain Point
Your server generated 10GB of logs. You need to find all ERROR entries, count occurrences, and identify the most common issues. Scrolling through millions of lines is impossible.
π Agentic Solution
A Log Parser that filters, aggregates, and summarizes log data.
Key Features:
- Pattern Matching: Custom regex for your log format.
- Level Filtering: ERROR, WARNING, INFO, DEBUG.
- Aggregation: Count by type, time period, source.
βοΈ Phase 1: Commander (Quick Fix)
For quick analysis.
Prompt:
βI have a log file
server.logwith format[TIMESTAMP] [LEVEL] Message. Write a Python script to:
- Parse: Extract timestamp, level, message.
- Filter: Show only ERROR and WARNING entries.
- Aggregate: Count by level and by hour.
- Output: Save filtered entries to
errors.csvand summary tosummary.txt.Handle malformed lines (skip with warning).β
Result: Actionable insights from massive logs.
ποΈ Phase 2: Architect (Permanent Tool)
For DevOps Engineers.
Engineering Prompt:
**Role:** Python GUI Developer (PyQt6 Specialist)
**Task:** Create "Log Analyzer Studio" Desktop App
**Objective:** A powerful log viewer and analyzer to parse gigabytes of server logs efficiently.
**Tech Stack:**
* Language: Python 3.10+
* GUI Library: PyQt6 (Cross-platform)
* Data Engine: Pandas (chunking), Regex
* Packaging: PyInstaller
**Functional Requirements:**
1. **UI Layout (PyQt6):**
* **Input:** Log File Selector.
* **Parser:** Regex Pattern Builder (with "Test line" feature).
* **Filters:** Date Range Picker, Log Level Checkboxes (ERR, WARN).
* **Visuals:** Time-series Bar Chart of error counts.
* **Grid:** Data table with filtering/sorting.
2. **Core Logic:**
* **Chunk Processing:** Read file in blocks (e.g., 10MB) to handle large files without RAM explosion.
* Parse lines to DataFrame segments.
* **Threading:** Analysis runs in background thread; UI updates progressively.
3. **Deliverables:**
* `main.py`: Complete source code.
* `requirements.txt`: Dependencies.
* **Build Instructions:**
* Windows: `pyinstaller --onefile --noconsole main.py`
* macOS: `pyinstaller --windowed --noconsole main.py`
π§ Prompt Decoding
- Stream Parsing: Donβt load entire file into memory. Process line by line.
π οΈ Instructions
- Copy Prompt β Adjust regex for your format β Run.