Error Monitoring Agent
AI 代理实时错误监控与告警。自动检测、追踪、分析与修复错误。
概览
一套全面的错误监控系统,帮助代理实时捕获异常、追踪错误模式、设置智能告警并自动化修复流程。
功能
node monitor.js watch --source logs,api,workers --threshold 5/min
node monitor.js watch --pattern "UnhandledPromiseRejection|ENOTFOUND"
多源监控,支持阈值与模式匹配。
node monitor.js aggregate --group-by stacktrace --min-similarity 0.85
node monitor.js aggregate --time-window 1h --top 20
按相似度归并同类错误,降噪并识别模式。
node monitor.js alert --rule "error_rate > 10/min" --channel slack
node monitor.js alert --rule "new_error_type" --channel pagerduty --severity critical
node monitor.js alert --rule "error_spike > 3x_baseline" --channel email
可配置速率阈值、新错误检测与异常突增告警。
node monitor.js analyze --error-id err_abc123 --depth 5
node monitor.js analyze --correlate deploy-log,config-change
追踪错误链,关联部署与配置变更。
node monitor.js auto-resolve --strategy restart,retry,rollback
node monitor.js auto-resolve --known-fixes db --apply-approved
对已知错误模式自动执行已批准的修复策略。
配置
{
"monitoring": {
"sources": ["application", "infrastructure", "api"],
"sampling": 1.0,
"retention": "30d",
"alertRules": [
{ "condition": "error_rate > 10/min", "action": "page-oncall" },
{ "condition": "new_error_type", "action": "notify-channel" },
{ "condition": "error_spike > 3x", "action": "auto-investigate" }
],
"autoResolve": {
"enabled": true,
"approvedStrategies": ["restart-service", "retry-request", "rollback-deploy"]
}
}
}
使用场景
生产监控:7×24 监控线上系统错误
CI/CD 集成:发布后监控部署健康
Agent 健康:追踪 AI 代理错误与故障
事件响应:自动检测并响应事件
错误预算:按 SLO 目标跟踪错误率