Log Analyzer

SkillFiles & storage

Analyzes error patterns in log files, supporting common formats such as JSON, syslog, and Nginx. Automatically detects and outputs error clustering, frequency statistics, and time distribution reports for troubleshooting and identifying peak periods. Triggered when a user uploads a .log file and ask

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Log Analyzer skill

What this skill tells your AI

The instructions your AI receives, as published by rongxinzy/rongxinai in SKILLs/log-diagnostic/SKILL.md and read by ahel’s review.

对日志文件进行自动化分析,提供错误聚类、频率统计和时间分布报告。

功能

  • 错误聚类:将相似的错误消息归类,消除噪声(IP、UUID、数字等动态部分),识别根本问题
  • 频率统计:按错误类型统计出现次数,按严重程度排序
  • 时间分布:展示错误在各小时和各日期的分布,帮助定位高发时段

支持的日志格式

格式说明自动检测
JSON每行一个 JSON 对象,含 timestamp/level/message 等字段{ 开头
syslogRFC 3164 格式,如 Jan 1 12:00:00 host proc[pid]: msg月份名开头
Nginxaccess log 或 error log 格式IP 开头或日期路径格式

使用方式

python scripts/analyze_logs.py <日志文件路径> [选项]

参数

参数说明默认值
log_file日志文件路径(必填)-
--format指定日志格式:auto/json/syslog/nginxauto
--top显示 Top N 错误聚类20
--output输出结果到 JSON 文件仅终端输出
--level过滤日志级别(如 ERRORWARN所有级别
--since只分析此时间之后的日志(ISO 格式)不限
--until只分析此时间之前的日志(ISO 格式)不限

示例

# 自动检测格式,分析整个日志文件
python scripts/analyze_logs.py /var/log/app.log

# 指定 Nginx 格式,只看 Top 10 错误
python scripts/analyze_logs.py /var/log/nginx/error.log --format nginx --top 10

# 只分析 ERROR 级别,输出 JSON 报告
python scripts/analyze_logs.py app.log --level ERROR --output report.json

# 分析指定时间范围内的日志
python scripts/analyze_logs.py app.log --since 2024-01-01T00:00:00 --until 2024-01-02T00:00:00

输出说明

终端输出

=======================================================
              日志分析报告
=======================================================

📊 概览
  检测格式: json
  总行数:   15,234
  已解析:   15,100 (解析失败: 134)
  匹配条目: 12,800
  错误数:   2,341
  时间范围: 2024-01-01 00:03:12 ~ 2024-01-01 23:58:45

🔴 Top 错误聚类 (共 47 类)
  #1   [×523  ] Connection refused to database at 10.0.1.5:5432
       首次: 2024-01-01T00:15:30  末次: 2024-01-01T23:45:12
  #2   [×312  ] Timeout waiting for response from user-service after 30000ms
       首次: 2024-01-01T02:10:00  末次: 2024-01-01T22:30:45
  #3   [×198  ] File not found: /data/uploads/img_99421.png
       首次: 2024-01-01T08:00:00  末次: 2024-01-01T20:15:33
  ...

⏰ 时间分布 (按小时)
  00:00  █████░░░░░░░░░░░░░░░  42
  01:00  ██░░░░░░░░░░░░░░░░░░  18
  ...
  14:00  ████████████████████  523
  ...

📅 时间分布 (按日期)
  2024-01-01  ████████████████████  2,341

JSON 输出

使用 --output 参数可导出结构化 JSON 报告,方便后续处理或接入监控系统。

Signals

GitHub stars
152
Forks
3
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
log-diagnostic
Source
github.com/rongxinzy/rongxinai