Imported from TheOwlOps/Boom (
skills/log-analyzer/SKILL.md). Install upstream withnpx skills add TheOwlOps/Boom --skill log-analyzer. Copyright stays with the author (MIT).
Log Analyzer
Phân tích file log (app, server, worker) để trích xuất tín hiệu quan trọng:
- Đếm
errors/warningstheo mức độ. - Gom nhóm message lỗi lặp lại (
top_errors). - Phát hiện stack trace Python/JS.
- Phát hiện operation chậm (
slow_ops) theo ngưỡng thời gian.
Cách dùng
from analyzer import analyze_log
result = analyze_log("/var/log/app.log", slow_threshold_ms=1000)
print(result["total_lines"], result["errors"], result["warnings"])
Dùng terminal để mở file log và read_file để xem đoạn log quanh lỗi
lớn nhất. Kết quả trả về là dict:
{
"total_lines": 1234,
"errors": 12,
"warnings": 34,
"top_errors": [{"message": "...", "count": 5}],
"stack_traces": 3,
"slow_ops": [{"operation": "...", "duration_ms": 2500, "line": 42}],
}
Quy ước nhận diện
- Mức độ: từ khóa
ERROR,WARN/WARNING,CRITICAL,EXCEPTION(không phân biệt hoa/thường). - Slow op: dòng chứa
duration/elapsed/took/in/after+ số + đơn vị vượtslow_threshold_ms. - Message được chuẩn hoá trước khi gom nhóm: bỏ timestamp, PID, số request-id để các bản sao của cùng một lỗi gom vào một bucket.
