[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M77Z4A3E2ZXPRKBYPQ7JH4S6":3,"skill-same:01M77Z4A3E2ZXPRKBYPQ7JH4S6":45},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":25,"repositoryHtmlUrl":26,"repositoryHomepageUrl":27,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M77Z4A3E2ZXPRKBYPQ7JH4S6","yuyonghao-observability",null,"Lord1Egypt\u002Fawesome-skill-forge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M75GRFNHC8VZNWEB8DKDE433",3,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fy\u002Fyuyonghao-observability\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"# Observability - 可观测性系统\n\n一个完整的 AI Agent 可观测性解决方案，提供结构化日志、性能指标、分布式追踪、告警管理和实时监控面板。\n\n## 版本\n\n- **当前版本**: 0.2.0\n- **Node.js 要求**: >= 18.0.0\n- **作者**: 小蒲萄 (Clawd)\n\n## 功能特性\n\n### 核心组件\n\n1. **StructuredLogger** - 结构化日志系统\n   - JSON 格式日志\n   - 多级别日志（error\u002Fwarn\u002Finfo\u002Fdebug）\n   - 自动日志轮转\n   - 上下文追踪（traceId\u002FspanId）\n\n2. **MetricsCollector** - 指标收集器\n   - Counter（计数器）\n   - Gauge（仪表）\n   - Histogram（直方图）\n   - Prometheus 格式导出\n   - 自动聚合和百分位数计算\n\n3. **Tracer** - 分布式追踪\n   - Trace\u002FSpan 管理\n   - 链路追踪\n   - 采样率控制\n   - 父子关系追踪\n\n4. **AlertManager** - 告警管理\n   - 阈值告警（支持 Counter\u002FGauge\u002FHistogram）\n   - 规则引擎（gt\u002Flt\u002Feq\u002Fgte\u002Flte）\n   - 多渠道通知（Console\u002FFile\u002FWebhook）\n   - 告警抑制和恢复\n   - 告警历史记录\n\n5. **Dashboard** - 监控面板\n   - 实时指标展示\n   - 多 Tab 视图（概览\u002FLLM\u002FMCP\u002FA2A\u002F告警\u002F日志）\n   - 自动刷新\n   - RESTful API\n\n### OpenClaw 集成\n\n- **LLM 调用监控**: Token 消耗、延迟、错误率、成本估算\n- **MCP 工具监控**: 工具调用统计、执行时间、成功率\n- **A2A 通信监控**: 消息延迟、成功率、会话管理\n\n## 安装\n\n```bash\n# 进入技能目录\ncd skills\u002Fobservability\n\n# 安装依赖\nnpm install\n\n# 运行测试\nnpm test\n\n# 启动 Dashboard\nnpm start\n```\n\n## 快速开始\n\n### 基础用法\n\n```javascript\nconst { ObservabilitySystem } = require('.\u002Fsrc\u002Findex');\n\n\u002F\u002F 创建可观测性系统\nconst obs = new ObservabilitySystem({\n  logging: {\n    level: 'info',\n    console: true,\n    file: true\n  },\n  metrics: {\n    enabled: true,\n    prefix: 'agent'\n  },\n  alerts: {\n    enabled: true,\n    createDefaultRules: true\n  }\n});\n\n\u002F\u002F 开始追踪\nconst trace = obs.startTrace('agent.execute', { query: 'test' });\n\n\u002F\u002F 执行业务逻辑...\nconst result = await doSomething();\n\n\u002F\u002F 结束追踪\ntrace.end({ result: 'success' });\n\n\u002F\u002F 获取系统状态\nconst status = obs.getStatus();\nconsole.log(status);\n```\n\n### 包装函数自动追踪\n\n```javascript\nconst wrappedFunction = obs.wrap(async (data) => {\n  \u002F\u002F 你的业务逻辑\n  return await processData(data);\n}, 'processData');\n\n\u002F\u002F 调用会自动追踪\nconst result = await wrappedFunction(input);\n```\n\n### 添加告警规则\n\n```javascript\n\u002F\u002F 添加自定义告警规则\nobs.addAlertRule({\n  name: 'High Latency Alert',\n  description: 'Triggered when latency exceeds threshold',\n  metric: 'agent.calls.latency',\n  metricType: 'histogram',\n  condition: 'gt',\n  threshold: 1000,\n  severity: 'warning',\n  channels: ['console', 'file'],\n  cooldown: 60000  \u002F\u002F 1分钟冷却\n});\n\n\u002F\u002F 手动触发告警\nobs.fireAlert('rule-id', 1500, 'Latency is too high');\n```\n\n### LLM 监控\n\n```javascript\n\u002F\u002F 记录 LLM 调用\nconst call = obs.startLLMCall('session-1', 'gpt-4', { temperature: 0.7 });\n\n\u002F\u002F 调用 LLM...\nconst response = await llm.chat(...);\n\n\u002F\u002F 结束记录\ncall.end({\n  usage: {\n    prompt_tokens: 100,\n    completion_tokens: 50,\n    total_tokens: 150\n  }\n});\n\n\u002F\u002F 获取 LLM 统计\nconst llmStats = obs.getStatus().llm;\nconsole.log(`Total tokens: ${llmStats.totalTokens}`);\nconsole.log(`Total cost: $${llmStats.totalCost.toFixed(4)}`);\n```\n\n### MCP 工具监控\n\n```javascript\n\u002F\u002F 记录 MCP 工具调用\nconst call = obs.startMCPCall('filesystem', 'readFile', { path: '\u002Ftest.txt' });\n\n\u002F\u002F 执行工具...\nconst result = await mcpTool.execute(...);\n\n\u002F\u002F 结束记录\ncall.end(result);\n\n\u002F\u002F 获取 MCP 统计\nconst mcpStats = obs.getStatus().mcp;\nconsole.log(`Success rate: ${mcpStats.overallSuccessRate.toFixed(1)}%`);\n```\n\n### A2A 通信监控\n\n```javascript\n\u002F\u002F 记录 A2A 消息\nconst msg = obs.sendA2AMessage({\n  id: 'msg-1',\n  type: 'request',\n  from: 'agent-a',\n  to: 'agent-b',\n  sessionId: 'session-1',\n  payload: { ... }\n});\n\n\u002F\u002F 接收响应\nobs.a2aMonitor.receiveResponse(msg.messageId, msg, response);\n\n\u002F\u002F 记录事件\nobs.recordA2AEvent({\n  type: 'notification',\n  from: 'agent-a',\n  payload: { ... }\n});\n```\n\n## Dashboard\n\n启动 Dashboard 服务器：\n\n```bash\nnpm start\n# 或\nnode src\u002Fdashboard.js\n```\n\n访问 http:\u002F\u002Flocalhost:3001 查看监控面板。\n\n### API 端点\n\n| 端点 | 方法 | 描述 |\n|------|------|------|\n| `\u002F` | GET | Dashboard UI |\n| `\u002Fapi\u002Fstatus` | GET | 系统状态（包含所有模块统计） |\n| `\u002Fapi\u002Fmetrics` | GET | 指标数据（JSON） |\n| `\u002Fapi\u002Flogs` | GET | 最近日志 |\n| `\u002Fapi\u002Fprometheus` | GET | Prometheus 格式指标 |\n| `\u002Fapi\u002Falerts` | GET | 告警历史 |\n\n## 配置选项\n\n```javascript\n{\n  \u002F\u002F 日志配置\n  logging: {\n    level: 'info',        \u002F\u002F debug\u002Finfo\u002Fwarn\u002Ferror\n    console: true,        \u002F\u002F 输出到控制台\n    file: true,           \u002F\u002F 输出到文件\n    logDir: '.\u002Flogs',     \u002F\u002F 日志目录\n    elasticsearch: false  \u002F\u002F 输出到 ES（待实现）\n  },\n  \n  \u002F\u002F 指标配置\n  metrics: {\n    enabled: true,        \u002F\u002F 启用指标\n    prefix: 'agent',      \u002F\u002F 指标前缀\n    autoReport: false,    \u002F\u002F 自动报告\n    reportInterval: 60000 \u002F\u002F 报告间隔（毫秒）\n  },\n  \n  \u002F\u002F 追踪配置\n  tracing: {\n    enabled: true,        \u002F\u002F 启用追踪\n    sampleRate: 1.0,      \u002F\u002F 采样率（0-1）\n    maxTraces: 1000       \u002F\u002F 最大追踪数\n  },\n  \n  \u002F\u002F 告警配置\n  alerts: {\n    enabled: true,              \u002F\u002F 启用告警\n    checkInterval: 30000,       \u002F\u002F 检查间隔（毫秒）\n    createDefaultRules: true,   \u002F\u002F 创建默认规则\n    maxHistory: 1000            \u002F\u002F 最大历史记录数\n  },\n  \n  \u002F\u002F LLM 监控配置\n  llm: {\n    enabled: true         \u002F\u002F 启用 LLM 监控\n  },\n  \n  \u002F\u002F MCP 监控配置\n  mcp: {\n    enabled: true         \u002F\u002F 启用 MCP 监控\n  },\n  \n  \u002F\u002F A2A 监控配置\n  a2a: {\n    enabled: true         \u002F\u002F 启用 A2A 监控\n  }\n}\n```\n\n## 项目结构\n\n```\nskills\u002Fobservability\u002F\n├── src\u002F\n│   ├── index.js           # 主入口\n│   ├── logger.js          # 结构化日志\n│   ├── metrics.js         # 指标收集\n│   ├── tracer.js          # 分布式追踪\n│   ├── alert-manager.js   # 告警管理\n│   ├── llm-monitor.js     # LLM 监控\n│   ├── mcp-monitor.js     # MCP 监控\n│   ├── a2a-monitor.js     # A2A 监控\n│   └── dashboard.js       # 监控面板\n├── test\u002F\n│   └── observability.test.js  # 测试套件\n├── logs\u002F                  # 日志目录\n├── package.json\n└── SKILL.md\n```\n\n## 测试\n\n运行完整测试套件：\n\n```bash\nnpm test\n```\n\n测试覆盖率：\n\n- Logger: ~95%\n- MetricsCollector: ~95%\n- Tracer: ~90%\n- AlertManager: ~90%\n- LLMMonitor: ~90%\n- MCPToolsMonitor: ~90%\n- A2AMonitor: ~90%\n- ObservabilitySystem: ~95%\n\n**总体覆盖率: >90%**\n\n## 默认告警规则\n\n系统预置以下告警规则：\n\n1. **High Latency Alert** - 平均延迟超过 1000ms\n2. **High Error Rate** - 错误次数超过 10\n3. **High Token Usage** - Token 使用量超过 10000\n4. **MCP Tool Errors** - MCP 工具错误超过 5\n\n## 性能指标\n\n### 日志性能\n- 异步写入，不影响主流程\n- 自动轮转，单文件最大 10MB\n- 保留最近 5 个日志文件\n\n### 指标性能\n- 内存存储，纳秒级操作\n- 自动清理过期追踪\n- 可配置的采样率\n\n### Dashboard 性能\n- 支持 1000+ 并发连接\n- 5 秒自动刷新\n- 响应式 UI 设计\n\n## 扩展开发\n\n### 自定义通知渠道\n\n```javascript\nclass AlertManager {\n  constructor() {\n    this.notificationHandlers = {\n      console: this._notifyConsole.bind(this),\n      file: this._notifyFile.bind(this),\n      webhook: this._notifyWebhook.bind(this),\n      custom: this._notifyCustom.bind(this)  \u002F\u002F 添加自定义处理器\n    };\n  }\n\n  _notifyCustom(alert, rule) {\n    \u002F\u002F 实现自定义通知逻辑\n    sendToSlack(alert.message);\n  }\n}\n```\n\n### 自定义指标导出\n\n```javascript\n\u002F\u002F 导出到 InfluxDB\nmetrics.onReport((metricsData) => {\n  influxDB.writePoints([\n    {\n      measurement: 'agent_metrics',\n      fields: metricsData,\n      timestamp: Date.now()\n    }\n  ]);\n});\n```\n\n## 许可证\n\nMIT License\n\n## 作者\n\n小蒲萄 (Clawd) - OpenClaw 项目\n",{},"master","4aa004da461d820f4ea5499e58eb8d196cf99016","community\u002Fclawhub\u002Fy\u002Fyuyonghao-observability",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge","https:\u002F\u002Fskill-explorer-rho.vercel.app","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-10 08:21:01",{"source":7,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add Lord1Egypt\u002Fawesome-skill-forge --skill yuyonghao-observability",{"tool":37,"command":38},"bunx","bunx skills add Lord1Egypt\u002Fawesome-skill-forge --skill yuyonghao-observability",{"tool":40,"command":41},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fawesome-skill-forge --skill yuyonghao-observability","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fy\u002Fyuyonghao-observability\u002FSKILL.md",true,[],[46,53,60,67,74,81],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":18},"01M785WKJB99G3STR1NF9NRTJW","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":18},"01M785WEFHB0G2S9YA6EPR3H0E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":18},"01M785W98EDN4EFJXJPMQEHCRC","touchdesigner-mcp","Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":18},"01M785W5S9FP3QBH2V191E025P","test-driven-development","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":18},"01M785W2AS08NSSH9YATCV6FJB","teams-meeting-pipeline","Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fteams-meeting-pipeline\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":18},"01M785VXKW4T34BTP1SCHW1R7F","systematic-debugging","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[]]