๐Ÿ“„

Log Analyzer

Filter massive server log files (GBs in size) to extract errors, warnings, or specific events without crashing your editor.

Document โญโญ Intermediate โฑ๏ธ 5 minutes

๐Ÿ˜ซ The Pain Point

Server crashed. The log file server.log is 500MB. Notepad freezes when trying to open it. You need to find what happened at โ€œ10:00 AMโ€.

๐Ÿš€ Agentic Solution

Stream Reader: Reads file line-by-line, never loading the whole thing into RAM. Fast and lightweight.

Key Features:

  • Filter: Show only lines containing โ€œERRORโ€ or โ€œCRITICALโ€.
  • Time Window: Extract logs between 09:00 and 10:00.

โš”๏ธ Phase 1: Commander (Quick Fix)

For Sysadmins in a hurry.

Prompt:

โ€œRead server.log. Extract all lines containing the word โ€˜ERRORโ€™. Save these lines to errors.txt. Handle the file line-by-line to avoid memory issues.โ€

Result: A small, readable error log.

๐Ÿ—๏ธ Phase 2: Architect (Permanent Tool)

For DevOps/QA.

Engineering Prompt:

**Role:** Python Backend Developer
**Task:** Create a "Large Log Filter Tool".
**Requirements:**
1.  **GUI:**
    *   Select Log File.
    *   Input Keywords (comma separated, e.g., "ERROR, FAIL").
    *   "Extract" button.
2.  **Logic:**
    *   Use `open(file, 'r')` iterator to read line-by-line (RAM Safe).
    *   Check if keyword in line.
    *   Write matching lines to output file.
    *   Show "Lines Scanned" counter.
3.  **Deliverables:** `log_filter.py`, `run.bat` (Windows), `run.sh` (Mac).

๐Ÿง  Prompt Decoding

  • Memory Safe: When handling Big Data (Text files > 100MB), read() crashes computers. The โ€œline-by-lineโ€ instruction is the key engineering constraint here.

๐Ÿ› ๏ธ Instructions

  1. Copy Prompt -> Paste -> Run.
  2. Select Log -> Keyword โ€œERRORโ€ -> Scan.

Related Workflows

Explore other categories

๐Ÿ“ฌ

Get Started with Agentic Working

Subscribe to receive updates from AgenticWorking.io

๐Ÿ“– Free eBook Guide ๐Ÿ“ฆ 7 Ready-to-use Scripts ๐Ÿ”” Weekly Tips

No spam, unsubscribe anytime. Join 1,000+ subscribers.