SLS + ARMS + 代码 + 数据库 全链路问题排查 查询阿里云SLS日志和ARMS调用链 → 定位源码问题 → 排查数据库异常 → 给出完整修复方案。 ⚠️ 关键规则(必须严格遵守) 1. 必须且只能通过执行下方 python 命令查询,禁止使用本地搜索或内置日志命令。 2. 用户给出的 trace id 是外部业务系统的 ID,禁止自行推断其来源、归属或意义,直接执行查询脚本。 3. 每个 logstore 的日志必须单独分组展示,严禁合并或去重。 4. 即使多条日志来自同一服务、同一时间,也必须逐条完整输出。 5. 输出报告中必须包含 里每个 logstore 的所有日志。 6. 所有交互提示必须严格按照下方模板输出,禁止自由发挥、禁止用自己的话改写、禁止添加语气词或额外解释。用户看到的提示必须和模板一字不差。 7. Step 5 代码搜索和 Step 6 数据库排查必须自动执行,禁止只输出"建议搜索xxx"之类的文字。发现异常后必须立即用 Grep/Glob/Read 工具实际搜索代码仓库。 8. 所有提供选项的提示必须带序号( …),用户可以直接回复序号操作。禁止输出不带序号的选项列表。禁止自编"继续操作"/"接下来"等不在模板中的提示文字。每个需要用户选择的场景都有对应模板,必须使用模板。 --- 执行步骤 Step 1:收集查询参数(交互式) 进入此 skil…

, text)\n if m:\n num = float(m.group(1))\n unit = m.group(2).strip()\n if unit in _DURATION_UNITS:\n return int(num * _DURATION_UNITS[unit])\n\n # 纯数字视为分钟\n try:\n return int(float(text))\n except ValueError:\n return None\n\n\n# ---------------------------------------------------------------------------\n# 主函数\n# ---------------------------------------------------------------------------\ndef main():\n parser = argparse.ArgumentParser(description=\"SLS + ARMS 联合问题定位\")\n # 查询入口:至少提供一个\n parser.add_argument(\"--trace-id\", dest=\"trace_id\",\n help=\"调用链 TraceID\")\n parser.add_argument(\"--wusid\", \"--wechat-user-space-id\", dest=\"wusid\",\n help=\"微信用户空间ID (wechat_user_space_id / promoter_wechat_user_space_id)\")\n parser.add_argument(\"--path\", dest=\"path\",\n help=\"请求路径 (data.request.path),支持精确或前缀匹配\")\n # 时间 & 范围\n parser.add_argument(\"--minutes\", type=int, default=None,\n help=\"查询最近 N 分钟(与 --duration 二选一)\")\n parser.add_argument(\"--duration\", type=str, default=None,\n help=\"自然语言时间范围,如:1小时/2天/1周/1星期/1个月/30m/6h/3d\")\n parser.add_argument(\"--start\", help=\"2024-01-15 14:00:00\")\n parser.add_argument(\"--end\", help=\"2024-01-15 15:00:00\")\n parser.add_argument(\"--logstores\", help=\"临时覆盖 SLS_LOGSTORE\")\n parser.add_argument(\"--skip-sls\", action=\"store_true\", help=\"跳过 SLS 查询\")\n parser.add_argument(\"--skip-arms\", action=\"store_true\", help=\"跳过 ARMS 查询\")\n parser.add_argument(\"--no-interactive\", action=\"store_true\",\n help=\"非交互模式:发现多 TraceID 时自动选第一条,不等待用户输入\")\n args = parser.parse_args()\n\n # 参数校验:\n # - 提供了 trace_id → 直接分析,wusid/path 作为附加 SLS 过滤条件\n # - 未提供 trace_id → wusid 必填(用于先检索 SLS 再让用户选择 TraceID)\n if not args.trace_id and not args.wusid and not args.path:\n parser.error(\"未指定 --trace-id 时,--wusid 或 --path 至少需要提供一个\")\n\n # 时间范围:--duration 优先,其次 --minutes,默认 1 周\n if args.duration:\n minutes = parse_duration(args.duration)\n if minutes is None:\n parser.error(\"无法识别时间格式 '{}',示例:1小时, 2天, 1周, 1星期, 1个月, 30m, 6h, 3d\".format(\n args.duration))\n elif args.minutes is not None:\n minutes = args.minutes\n else:\n minutes = 10080 # 默认 1 周\n\n now = datetime.now()\n if args.start and args.end:\n from_dt = datetime.strptime(args.start, \"%Y-%m-%d %H:%M:%S\")\n to_dt = datetime.strptime(args.end, \"%Y-%m-%d %H:%M:%S\")\n else:\n to_dt = now\n from_dt = now - timedelta(minutes=minutes)\n\n from_ts_s = int(from_dt.timestamp())\n to_ts_s = int(to_dt.timestamp())\n from_ts_ms = from_ts_s * 1000\n to_ts_ms = to_ts_s * 1000\n\n cfg = get_config(\n logstores_override=args.logstores,\n skip_sls=args.skip_sls,\n skip_arms=args.skip_arms,\n )\n\n trace_id = args.trace_id.strip() if args.trace_id else None\n wusid = args.wusid.strip() if args.wusid else None\n path = args.path.strip() if args.path else None\n\n result = {\n \"query\": {\n \"trace_id\": trace_id,\n \"wusid\": wusid,\n \"path\": path,\n },\n \"time_range\": \"{} ~ {}\".format(\n from_dt.strftime(\"%Y-%m-%d %H:%M:%S\"),\n to_dt.strftime(\"%Y-%m-%d %H:%M:%S\"),\n ),\n \"discovered_traces\": None,\n \"sls\": None,\n \"arms\": None,\n \"call_chain\": None,\n \"analysis\": None,\n \"summary\": \"\",\n }\n\n sls_result = None\n arms_spans = []\n errors_info = []\n all_arms_results = {}\n arms_trace_ids = [] # 在模式 A 中由 trace_id 直接确定,模式 B 中从 SLS 发现\n\n # ---- 模式 A(有 trace_id):SLS 和 ARMS 并行查询,大幅提速 ----\n sys.stderr.write(\"🚀 开始查询(时间范围:{})\\n\".format(result[\"time_range\"]))\n sys.stderr.flush()\n if trace_id:\n sls_query = None\n if not args.skip_sls:\n sls_query = build_sls_query(\n cfg[\"sls\"][\"trace_field\"] if not args.skip_sls else \"traceId\",\n trace_id=trace_id, wusid=wusid, path=path)\n\n with ThreadPoolExecutor(max_workers=2) as ex:\n sls_future = None\n arms_future = None\n\n if sls_query:\n sls_future = ex.submit(query_sls, cfg, sls_query, from_ts_s, to_ts_s)\n if not args.skip_arms:\n arms_future = ex.submit(query_arms, cfg, trace_id, from_ts_ms, to_ts_ms)\n\n if sls_future:\n try:\n sls_result = sls_future.result()\n result[\"sls\"] = sls_result\n except Exception as e:\n errors_info.append(\"SLS 查询失败: {}\".format(e))\n\n if arms_future:\n try:\n spans = arms_future.result()\n all_arms_results[trace_id] = spans\n arms_spans.extend(spans)\n except Exception as e:\n errors_info.append(\"ARMS 查询失败: {}\".format(e))\n\n # ---- 模式 B(无 trace_id):先查 SLS,再查 ARMS ----\n else:\n if not args.skip_sls:\n # 当 wusid 是主要查询条件时,使用多策略查询\n if wusid:\n sys.stderr.write(\"🔎 通过 wusid={} 多策略检索 SLS 日志...\\n\".format(wusid))\n sys.stderr.flush()\n try:\n sls_result = query_sls_by_wusid(cfg, wusid, from_ts_s, to_ts_s, path=path)\n result[\"sls\"] = sls_result\n except Exception as e:\n errors_info.append(\"SLS 查询失败: {}\".format(e))\n else:\n sls_query = build_sls_query(\n cfg[\"sls\"][\"trace_field\"] if not args.skip_sls else \"traceId\",\n trace_id=None, wusid=wusid, path=path)\n if sls_query:\n try:\n sls_result = query_sls(cfg, sls_query, from_ts_s, to_ts_s)\n result[\"sls\"] = sls_result\n except Exception as e:\n errors_info.append(\"SLS 查询失败: {}\".format(e))\n\n # 从 SLS 结果中发现 trace_id\n arms_trace_ids = []\n if not args.skip_arms and sls_result:\n trace_summaries = build_trace_summary(sls_result)\n if trace_summaries:\n result[\"discovered_traces\"] = trace_summaries\n if args.no_interactive:\n arms_trace_ids = [trace_summaries[0][\"trace_id\"]]\n else:\n arms_trace_ids = prompt_trace_selection(trace_summaries)\n else:\n errors_info.append(\"SLS 日志中未找到 trace_id 字段,跳过 ARMS 查询\")\n\n if arms_trace_ids:\n with ThreadPoolExecutor(max_workers=min(3, len(arms_trace_ids))) as ex:\n fut_map = {\n ex.submit(query_arms, cfg, tid, from_ts_ms, to_ts_ms): tid\n for tid in arms_trace_ids\n }\n for fut in as_completed(fut_map):\n tid = fut_map[fut]\n try:\n spans = fut.result()\n all_arms_results[tid] = spans\n arms_spans.extend(spans)\n except Exception as e:\n errors_info.append(\"ARMS 查询失败 (trace_id={}): {}\".format(tid, e))\n\n if arms_spans:\n all_error_spans = [s for s in arms_spans if s[\"is_error\"]]\n result[\"arms\"] = {\n \"status\": \"ok\",\n \"queried_trace_ids\": arms_trace_ids,\n \"span_count\": len(arms_spans),\n \"spans\": arms_spans,\n \"error_spans\": all_error_spans,\n \"per_trace\": {\n tid: {\n \"span_count\": len(spans),\n \"error_spans\": [s for s in spans if s[\"is_error\"]],\n }\n for tid, spans in all_arms_results.items()\n },\n }\n else:\n result[\"arms\"] = {\n \"status\": \"no_data\",\n \"message\": \"ARMS 未采样到此 TraceID 的调用链\",\n \"queried_trace_ids\": arms_trace_ids,\n \"span_count\": 0,\n \"spans\": [],\n \"error_spans\": [],\n }\n\n # ---- 构建调用链树 ----\n if arms_spans:\n error_spans, tree_text = build_call_tree(arms_spans)\n result[\"call_chain\"] = {\n \"tree\": tree_text,\n \"error_spans\": error_spans,\n \"total_spans\": len(arms_spans),\n \"error_count\": len(error_spans),\n \"services\": list(dict.fromkeys(s[\"service\"] for s in arms_spans)),\n \"total_duration_ms\": max((s[\"duration_ms\"] for s in arms_spans), default=0),\n }\n else:\n # ARMS 无数据时也要给出明确状态,防止 AI 跳过 ARMS 段\n arms_status = \"ARMS 未采样到此 TraceID 的调用链\"\n if args.skip_arms:\n arms_status = \"用户跳过 ARMS 查询(--skip-arms)\"\n elif any(\"ARMS\" in e for e in errors_info):\n arms_status = \"ARMS 查询失败: \" + next(\n (e for e in errors_info if \"ARMS\" in e), \"未知错误\")\n result[\"call_chain\"] = {\n \"tree\": \"⚠️ \" + arms_status,\n \"error_spans\": [],\n \"total_spans\": 0,\n \"error_count\": 0,\n \"services\": [],\n \"total_duration_ms\": 0,\n \"status\": arms_status,\n }\n\n # ---- 用 GetStack API 获取 error span 的方法级堆栈 ----\n stack_details = {}\n if arms_spans and not args.skip_arms:\n error_spans_for_stack = [s for s in arms_spans if s[\"is_error\"]]\n # 最多查 5 个 error span 的堆栈,避免过多 API 调用\n for es in error_spans_for_stack[:5]:\n tid = es.get(\"trace_id\") or trace_id\n rid = es.get(\"rpc_id\")\n if not tid or not rid:\n continue\n try:\n stack_entries = query_arms_stack(\n cfg, tid, rid,\n pid=es[\"tags\"].get(\"appName\") or es[\"tags\"].get(\"pid\"),\n start_time=from_ts_ms,\n end_time=to_ts_ms,\n )\n if stack_entries:\n key = \"{}:{}\".format(tid, rid)\n stack_details[key] = {\n \"trace_id\": tid,\n \"rpc_id\": rid,\n \"service\": es[\"service\"],\n \"operation\": es[\"operation\"],\n \"exception_id\": es.get(\"exception_id\", \"\"),\n \"stack_entries\": stack_entries,\n \"formatted\": format_stack_detail(stack_entries),\n }\n except Exception as e:\n errors_info.append(\"GetStack 失败 (rpc_id={}): {}\".format(rid, e))\n\n result[\"stack_details\"] = stack_details if stack_details else None\n\n # ---- 检查是否完全无数据 ----\n sls_total = sls_result[\"total\"] if sls_result else 0\n arms_total = len(arms_spans)\n no_data = (sls_total == 0 and arms_total == 0)\n result[\"no_data\"] = no_data\n result[\"current_minutes\"] = minutes\n\n # ---- 根因分析 ----\n analysis = analyze_root_cause(sls_result, result.get(\"arms\"), result.get(\"call_chain\"))\n if no_data:\n # 根据当前已查范围,建议下一步扩大到多少\n if minutes \u003c 10080:\n next_hint = \"--duration \\\"1周\\\"\"\n elif minutes \u003c 43200:\n next_hint = \"--duration \\\"1个月\\\"\"\n else:\n next_hint = \"确认 TraceID 是否正确\"\n analysis[\"suggestions\"].insert(0,\n \"当前时间范围 ({}) 内 SLS 和 ARMS 均无数据,建议扩大时间范围重新查询({})\".format(\n result[\"time_range\"], next_hint))\n result[\"analysis\"] = analysis\n\n # ---- 生成综合摘要 ----\n summary_lines = []\n summary_lines.append(\"=\" * 60)\n if trace_id:\n summary_lines.append(\"TraceID: {}\".format(trace_id))\n if wusid:\n summary_lines.append(\"WSUID: {}\".format(wusid))\n if path:\n summary_lines.append(\"Path: {}\".format(path))\n if arms_trace_ids and not trace_id:\n summary_lines.append(\"发现 TraceID: {}\".format(\", \".join(arms_trace_ids)))\n summary_lines.append(\"时间范围: {}\".format(result[\"time_range\"]))\n summary_lines.append(\"=\" * 60)\n\n # 根因结论(置顶)\n summary_lines.append(\"\\n【根本原因】\")\n summary_lines.append(\" \" + analysis[\"root_cause\"])\n\n # 关键发现\n if analysis[\"findings\"]:\n summary_lines.append(\"\\n【关键发现】\")\n for f in analysis[\"findings\"]:\n summary_lines.append(\" • \" + f)\n\n # 排查建议\n if analysis[\"suggestions\"]:\n summary_lines.append(\"\\n【排查建议】\")\n for i, s in enumerate(analysis[\"suggestions\"], 1):\n summary_lines.append(\" {}. {}\".format(i, s))\n\n # ARMS 调用链详情(多 trace_id 时逐一展示)\n if result[\"call_chain\"]:\n cc = result[\"call_chain\"]\n summary_lines.append(\"\\n【ARMS 调用链】涉及 {} 个服务,共 {} 个 Span,总耗时 {}ms\".format(\n len(cc[\"services\"]), cc[\"total_spans\"], cc[\"total_duration_ms\"]))\n summary_lines.append(\"涉及服务:{}\".format(\"、\".join(cc[\"services\"])))\n if cc[\"error_count\"]:\n summary_lines.append(\"❌ 发现 {} 个异常 Span:\".format(cc[\"error_count\"]))\n for es in cc[\"error_spans\"]:\n err_msg = (es[\"tags\"].get(\"error.message\")\n or es[\"tags\"].get(\"exception.message\", \"无详细信息\"))\n summary_lines.append(\" [{}] {} → {} | {}\".format(\n es[\"service\"], es[\"rpc_type\"], es[\"operation\"], err_msg[:100]))\n # 多 trace 时分段展示\n if len(arms_trace_ids) > 1:\n for tid, spans in all_arms_results.items():\n if not spans:\n continue\n _, tree_text_i = build_call_tree(spans)\n summary_lines.append(\"\\n── TraceID: {} ──\".format(tid))\n summary_lines.append(tree_text_i)\n else:\n summary_lines.append(\"\\n调用链路图:\")\n summary_lines.append(cc[\"tree\"])\n elif not args.skip_arms:\n if arms_trace_ids:\n summary_lines.append(\"\\n【ARMS 调用链】查询了 {} 个 TraceID,均无数据\".format(\n len(arms_trace_ids)))\n else:\n summary_lines.append(\"\\n【ARMS 调用链】未查到数据(TraceID 可能未被 ARMS 采样)\")\n\n # GetStack 方法级堆栈详情\n if stack_details:\n summary_lines.append(\"\\n【方法级堆栈详情(GetStack)】\")\n for key, detail in stack_details.items():\n summary_lines.append(\"\\n── [{}] {} → {} ──\".format(\n detail[\"service\"], detail[\"operation\"],\n \"异常ID: {}\".format(detail[\"exception_id\"]) if detail[\"exception_id\"] else \"rpc_id: {}\".format(detail[\"rpc_id\"])))\n summary_lines.append(detail[\"formatted\"])\n\n # SLS 日志摘要\n if sls_result:\n summary_lines.append(\"\\n【SLS 日志】\")\n for stat in sls_result[\"store_stats\"]:\n flag = {\"ok\": \"✅\", \"empty\": \"○\", \"error\": \"❌\"}.get(stat[\"status\"], \"?\")\n summary_lines.append(\" {} [{}] {} 条\".format(\n flag, stat[\"logstore\"], stat[\"count\"]))\n if sls_result[\"error_logs\"]:\n summary_lines.append(\"\\n❌ ERROR 日志 ({} 条):\".format(sls_result[\"error_count\"]))\n for el in sls_result[\"error_logs\"][:5]:\n summary_lines.append(\" [{}] {} | {} | {}\".format(\n el[\"logstore\"], el[\"time\"], el[\"file\"] or \"-\", el[\"message\"][:120]))\n elif not args.skip_sls:\n summary_lines.append(\"\\n【SLS 日志】未查到数据\")\n\n if errors_info:\n summary_lines.append(\"\\n⚠️ 查询警告:\")\n for e in errors_info:\n summary_lines.append(\" \" + e)\n\n result[\"summary\"] = \"\\n\".join(summary_lines)\n\n # Windows UTF-8 输出\n if sys.platform == \"win32\":\n try:\n sys.stdout.reconfigure(encoding=\"utf-8\")\n except Exception:\n pass\n\n print(json.dumps(result, ensure_ascii=False, indent=2))\n\n\nif __name__ == \"__main__\":\n main()\n","content_type":"text/x-python; charset=utf-8","language":"python","size":64030,"content_sha256":"41653159e249fe06dff3ed8e65e836990fe4ff43763119a9c19e451028f07b1e"},{"filename":"scripts/requirements.txt","content":"alibabacloud-arms20190808==10.0.4\naliyun-log-python-sdk==0.9.42\n","content_type":"text/plain; charset=utf-8","language":null,"size":64,"content_sha256":"7c43041d89c6df0714a830a3c9a96d0dc38105dc6510c4d1f7947c915491570e"}],"content_json":{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"text":"SLS + ARMS + 代码 + 数据库 全链路问题排查","type":"text"}]},{"type":"paragraph","content":[{"text":"查询阿里云SLS日志和ARMS调用链 → 定位源码问题 → 排查数据库异常 → 给出完整修复方案。","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"⚠️ 关键规则(必须严格遵守)","type":"text"}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"必须且只能通过执行下方 python 命令查询,禁止使用本地搜索或内置日志命令。","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"用户给出的 trace_id 是外部业务系统的 ID,禁止自行推断其来源、归属或意义,直接执行查询脚本。","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"每个 logstore 的日志必须单独分组展示,严禁合并或去重。","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"即使多条日志来自同一服务、同一时间,也必须逐条完整输出。","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"输出报告中必须包含 ","type":"text","marks":[{"type":"strong"}]},{"text":"sls.logs_by_logstore","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":" 里每个 logstore 的所有日志。","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"所有交互提示必须严格按照下方模板输出,禁止自由发挥、禁止用自己的话改写、禁止添加语气词或额外解释。用户看到的提示必须和模板一字不差。","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Step 5 代码搜索和 Step 6 数据库排查必须自动执行,禁止只输出\"建议搜索xxx\"之类的文字。发现异常后必须立即用 Grep/Glob/Read 工具实际搜索代码仓库。","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"所有提供选项的提示必须带序号(","type":"text","marks":[{"type":"strong"}]},{"text":"1","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":" ","type":"text","marks":[{"type":"strong"}]},{"text":"2","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":" ","type":"text","marks":[{"type":"strong"}]},{"text":"3","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":" …),用户可以直接回复序号操作。禁止输出不带序号的选项列表。禁止自编\"继续操作\"/\"接下来\"等不在模板中的提示文字。每个需要用户选择的场景都有对应模板,必须使用模板。","type":"text","marks":[{"type":"strong"}]}]}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"执行步骤","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 1:收集查询参数(交互式)","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"进入此 skill 后,立即扫描用户消息提取参数。已有的直接用,缺的才问。","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":4},"content":[{"text":"1.1 扫描用户消息","type":"text"}]},{"type":"paragraph","content":[{"text":"检查用户消息中是否已包含查询参数(TraceID / wusid / path / 时间):","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"已有参数","type":"text","marks":[{"type":"strong"}]},{"text":"(如用户说\"帮我查 trace_id f1b37e05...\")→ 直接提取,跳到 Step 1.3","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"没有参数","type":"text","marks":[{"type":"strong"}]},{"text":"(如用户只说\"分析sls\")→ 进入 Step 1.2 询问","type":"text"}]}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":4},"content":[{"text":"1.2 询问查询条件","type":"text"}]},{"type":"paragraph","content":[{"text":"你的回复必须且只能是下面这段文字,从「🔍」开始到「逐项输入。」结束,不能多一个字也不能少一个字,不能加语气词、不能加问候、不能用自己的话改写,输出后立即停止等待用户回复:","type":"text","marks":[{"type":"strong"}]}]},{"type":"paragraph","content":[{"text":"🔍 请输入查询条件,格式:","type":"text"},{"text":"关键词 值","type":"text","marks":[{"type":"code_inline"}]},{"text":",多项用 ","type":"text"},{"text":";","type":"text","marks":[{"type":"code_inline"}]},{"text":" 分隔:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"trace_id xxx; wusid xxx; path xxx","type":"text"}]},{"type":"paragraph","content":[{"text":"① trace_id — 染色ID / 业务调用链ID(32位十六进制字符串) ② wusid — 用户空间ID(数字,也可以用 ","type":"text"},{"text":"uid","type":"text","marks":[{"type":"code_inline"}]},{"text":") ③ path — 请求路径(如 ","type":"text"},{"text":"/ny.apps_pb.xxx/Method","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]},{"type":"paragraph","content":[{"text":"至少输入一项,回复序号 ","type":"text"},{"text":"1","type":"text","marks":[{"type":"code_inline"}]},{"text":" ","type":"text"},{"text":"2","type":"text","marks":[{"type":"code_inline"}]},{"text":" ","type":"text"},{"text":"3","type":"text","marks":[{"type":"code_inline"}]},{"text":" 可逐项输入。","type":"text"}]},{"type":"paragraph","content":[{"text":"解析用户回复规则:","type":"text","marks":[{"type":"strong"}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"概念统一","type":"text","marks":[{"type":"strong"}]},{"text":":trace_id = 染色ID = 业务调用链ID = requestId,都是同一个东西。","type":"text"}]}]},{"type":"paragraph","content":[{"text":"情况 A:用户输入了参数值(含 ","type":"text","marks":[{"type":"strong"}]},{"text":";","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":" 或关键词)","type":"text","marks":[{"type":"strong"}]}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"按 ","type":"text"},{"text":";","type":"text","marks":[{"type":"code_inline"}]},{"text":" 或换行拆分每项","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"每项内按空格分隔:前面是参数名,后面是值","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"trace_id","type":"text","marks":[{"type":"code_inline"}]},{"text":" / ","type":"text"},{"text":"tid","type":"text","marks":[{"type":"code_inline"}]},{"text":" / ","type":"text"},{"text":"trace","type":"text","marks":[{"type":"code_inline"}]},{"text":" / ","type":"text"},{"text":"染色id","type":"text","marks":[{"type":"code_inline"}]},{"text":" / ","type":"text"},{"text":"requestid","type":"text","marks":[{"type":"code_inline"}]},{"text":" → trace_id","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"wusid","type":"text","marks":[{"type":"code_inline"}]},{"text":" / ","type":"text"},{"text":"uid","type":"text","marks":[{"type":"code_inline"}]},{"text":" / ","type":"text"},{"text":"用户id","type":"text","marks":[{"type":"code_inline"}]},{"text":" → wusid","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"path","type":"text","marks":[{"type":"code_inline"}]},{"text":" / ","type":"text"},{"text":"接口","type":"text","marks":[{"type":"code_inline"}]},{"text":" / ","type":"text"},{"text":"api","type":"text","marks":[{"type":"code_inline"}]},{"text":" → path","type":"text"}]}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"不带参数名时自动识别:32位十六进制→trace_id,纯数字→wusid,","type":"text"},{"text":"/","type":"text","marks":[{"type":"code_inline"}]},{"text":"开头→path","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"提取到任意参数 → 进入 Step 1.3","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"情况 B:用户回复了序号","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"1","type":"text","marks":[{"type":"code_inline"}]},{"text":" → 回复「请输入 trace_id:」→ 等用户输入值 → 记录 → 进入 Step 1.3","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"2","type":"text","marks":[{"type":"code_inline"}]},{"text":" → 回复「请输入 wusid:」→ 等用户输入值 → 记录 → 进入 Step 1.3","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"3","type":"text","marks":[{"type":"code_inline"}]},{"text":" → 回复「请输入 path:」→ 等用户输入值 → 记录 → 进入 Step 1.3","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"情况 C:无法识别","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"回复「未识别到参数,请按格式输入(如 ","type":"text"},{"text":"trace_id xxx","type":"text","marks":[{"type":"code_inline"}]},{"text":")或回复序号 ","type":"text"},{"text":"1","type":"text","marks":[{"type":"code_inline"}]},{"text":" ","type":"text"},{"text":"2","type":"text","marks":[{"type":"code_inline"}]},{"text":" ","type":"text"},{"text":"3","type":"text","marks":[{"type":"code_inline"}]},{"text":"」","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"用户说\"没有\"/\"不知道\" → 依次追问 wusid → path → 都没有则停止","type":"text"}]}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":4},"content":[{"text":"1.3 确认时间范围","type":"text"}]},{"type":"paragraph","content":[{"text":"检查用户是否已提供时间信息:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"已提及时间","type":"text","marks":[{"type":"strong"}]},{"text":"(如\"今天下午\"、\"昨天\"、\"最近2小时\")→ 自动转换,直接跳到 Step 1.4","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"未提及时间","type":"text","marks":[{"type":"strong"}]},{"text":" → 你的回复必须且只能是下面这段文字,不能改写:","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"⏰ 时间范围?默认 ","type":"text"},{"text":"最近 1 周","type":"text","marks":[{"type":"strong"}]},{"text":",也可以指定:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"默认 → 最近 1 周(直接回车)\n1小时 / 3天 / 2周 / 1个月 → 相对时间\n今天 / 昨天 → 当天范围\n2024-03-15 14:00 ~ 16:00 → 精确时间段","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"用户回车 / 说\"默认\"/\"可以\"/\"行\" → 使用默认 1 周","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"用户给出时间 → 传给 ","type":"text"},{"text":"--duration","type":"text","marks":[{"type":"code_inline"}]},{"text":" 或 ","type":"text"},{"text":"--start/--end","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"用户说\"今天\"/\"昨天\"等 → 自行计算 ","type":"text"},{"text":"--start/--end","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"paragraph","content":[{"text":"时间转换参考:","type":"text","marks":[{"type":"strong"}]}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"用户说的","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"转换","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"今天","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"--start \"今天00:00:00\" --end \"当前时间\"","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"昨天","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"--start \"昨天00:00:00\" --end \"昨天23:59:59\"","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"今天下午","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"--start \"今天12:00:00\" --end \"当前时间\"","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"最近N小时/天/周/月","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"--duration \"N小时/天/周/月\"","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"上周","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"--start \"上周一00:00:00\" --end \"上周日23:59:59\"","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"3月15号","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"--start \"3月15日00:00:00\" --end \"3月15日23:59:59\"","type":"text","marks":[{"type":"code_inline"}]}]}]}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":4},"content":[{"text":"1.4 输出查询摘要并执行","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"📋 ","type":"text"},{"text":"查询参数:","type":"text","marks":[{"type":"strong"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"条件:trace_id = xxx / wusid = xxx / path = xxx\n时间:最近 1 周(2026-03-12 ~ 2026-03-19)\n来源:SLS + ARMS","type":"text"}]},{"type":"paragraph","content":[{"text":"🚀 正在查询,请稍候…","type":"text"}]}]},{"type":"paragraph","content":[{"text":"高级选项(","type":"text"},{"text":"不主动询问","type":"text","marks":[{"type":"strong"}]},{"text":",仅用户提到时才加):","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"只查SLS\" / \"不查ARMS\" → ","type":"text"},{"text":"--skip-arms","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"只查ARMS\" / \"不查SLS\" → ","type":"text"},{"text":"--skip-sls","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"查 xxx logstore\" → ","type":"text"},{"text":"--logstores \"xxx\"","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 2:执行查询脚本(必须执行)","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"默认查最近 1 周,无需指定时间参数。","type":"text","marks":[{"type":"strong"}]},{"text":" 支持 ","type":"text"},{"text":"--duration","type":"text","marks":[{"type":"code_inline"}]},{"text":" 自然语言时间:1小时、2天、1周、1星期、1个月、半天、30m、6h、3d、1w 等。 也支持 ","type":"text"},{"text":"--minutes N","type":"text","marks":[{"type":"code_inline"}]},{"text":" 直接传分钟数,或 ","type":"text"},{"text":"--start/--end","type":"text","marks":[{"type":"code_inline"}]},{"text":" 精确时间段。","type":"text"}]}]},{"type":"paragraph","content":[{"text":"模式 A:已知 TraceID(直接分析)","type":"text","marks":[{"type":"strong"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python \"%USERPROFILE%\\.openclaw\\workspace\\skills\\sls-trace-analysis\\scripts\\query_trace.py\" --trace-id \"TraceID\"","type":"text"}]},{"type":"paragraph","content":[{"text":"自定义时间范围(自然语言):","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python \"%USERPROFILE%\\.openclaw\\workspace\\skills\\sls-trace-analysis\\scripts\\query_trace.py\" --trace-id \"TraceID\" --duration \"3天\"","type":"text"}]},{"type":"paragraph","content":[{"text":"精确时间范围:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python \"%USERPROFILE%\\.openclaw\\workspace\\skills\\sls-trace-analysis\\scripts\\query_trace.py\" --trace-id \"TraceID\" --start \"2024-01-15 14:00:00\" --end \"2024-01-15 15:00:00\"","type":"text"}]},{"type":"paragraph","content":[{"text":"只查 ARMS(跳过 SLS):","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python \"%USERPROFILE%\\.openclaw\\workspace\\skills\\sls-trace-analysis\\scripts\\query_trace.py\" --trace-id \"TraceID\" --skip-sls","type":"text"}]},{"type":"paragraph","content":[{"text":"只查 SLS(跳过 ARMS):","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python \"%USERPROFILE%\\.openclaw\\workspace\\skills\\sls-trace-analysis\\scripts\\query_trace.py\" --trace-id \"TraceID\" --skip-arms","type":"text"}]},{"type":"paragraph","content":[{"text":"模式 B:未知 TraceID,通过 wusid / path 先检索","type":"text","marks":[{"type":"strong"}]}]},{"type":"paragraph","content":[{"text":"按用户 ID 检索:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python \"%USERPROFILE%\\.openclaw\\workspace\\skills\\sls-trace-analysis\\scripts\\query_trace.py\" --wusid \"76149226\" --no-interactive","type":"text"}]},{"type":"paragraph","content":[{"text":"按请求路径检索:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python \"%USERPROFILE%\\.openclaw\\workspace\\skills\\sls-trace-analysis\\scripts\\query_trace.py\" --path \"/ny.apps_pb.promote_pb.PromotePB/UpdateRelation\" --no-interactive","type":"text"}]},{"type":"paragraph","content":[{"text":"两者组合(精确缩小范围):","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python \"%USERPROFILE%\\.openclaw\\workspace\\skills\\sls-trace-analysis\\scripts\\query_trace.py\" --wusid \"76149226\" --path \"/ny.apps_pb.promote_pb.PromotePB/UpdateRelation\" --no-interactive","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"模式 B 说明","type":"text","marks":[{"type":"strong"}]},{"text":":","type":"text"},{"text":"--no-interactive","type":"text","marks":[{"type":"code_inline"}]},{"text":" 让脚本自动选择第一条 TraceID 进行分析。如果 JSON 输出的 ","type":"text"},{"text":"discovered_traces","type":"text","marks":[{"type":"code_inline"}]},{"text":" 有多条,可展示列表让用户选择,然后用选中的 trace_id 以模式 A 重新查询。","type":"text"}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 3:解析脚本输出","type":"text"}]},{"type":"paragraph","content":[{"text":"脚本返回 JSON,必须读取以下字段:","type":"text"}]},{"type":"paragraph","content":[{"text":"查询信息(","type":"text","marks":[{"type":"strong"}]},{"text":"query","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":"):","type":"text","marks":[{"type":"strong"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"query.trace_id → 本次使用的 TraceID(模式 A)\nquery.wusid → 本次使用的 wusid(模式 B)\nquery.path → 本次使用的路径(模式 B)","type":"text"}]},{"type":"paragraph","content":[{"text":"模式 B 专属(","type":"text","marks":[{"type":"strong"}]},{"text":"discovered_traces","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":"):","type":"text","marks":[{"type":"strong"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"discovered_traces[].trace_id → 找到的 TraceID\ndiscovered_traces[].first_time → 首条日志时间\ndiscovered_traces[].service → 服务名\ndiscovered_traces[].path → 请求路径\ndiscovered_traces[].response_code → 响应码\ndiscovered_traces[].response_msg → 响应消息\ndiscovered_traces[].has_error → 是否有 ERROR 日志\ndiscovered_traces[].log_count → 匹配日志条数","type":"text"}]},{"type":"paragraph","content":[{"text":"ARMS 调用链(","type":"text","marks":[{"type":"strong"}]},{"text":"call_chain","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":"):","type":"text","marks":[{"type":"strong"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"call_chain.tree → 带缩进的调用链路图(文本),含异常 ID 和完整堆栈\ncall_chain.error_spans → 异常 Span 列表(含 exception_id、full_stack 字段)\ncall_chain.services → 涉及的服务列表\ncall_chain.total_duration_ms → 总耗时","type":"text"}]},{"type":"paragraph","content":[{"text":"方法级堆栈(","type":"text","marks":[{"type":"strong"}]},{"text":"stack_details","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":"):","type":"text","marks":[{"type":"strong"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"stack_details.{key}.trace_id → TraceID\nstack_details.{key}.rpc_id → RpcID\nstack_details.{key}.service → 服务名\nstack_details.{key}.operation → 操作名\nstack_details.{key}.exception_id → 异常 ID\nstack_details.{key}.stack_entries → 方法级堆栈列表(api、duration、exception、line)\nstack_details.{key}.formatted → 格式化后的堆栈文本","type":"text"}]},{"type":"paragraph","content":[{"text":"SLS 日志(","type":"text","marks":[{"type":"strong"}]},{"text":"sls","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":"):","type":"text","marks":[{"type":"strong"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"sls.store_stats → 每个 logstore 的查询统计(必须全部展示)\nsls.logs_by_logstore → 按 logstore 分组的日志(必须按组展示,不能合并)\nsls.error_logs → ERROR 级别日志","type":"text"}]},{"type":"paragraph","content":[{"text":"根因分析(","type":"text","marks":[{"type":"strong"}]},{"text":"analysis","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":"):","type":"text","marks":[{"type":"strong"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"analysis.root_cause → 根本原因结论\nanalysis.findings → 关键发现列表\nanalysis.suggestions → 排查建议列表","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 3.5:无数据时循环询问时间范围(必须严格遵守)","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"核心规则:查不到数据就问用户,用户给了新时间就重查,如此循环直到查到数据或用户放弃。绝对不能自动重试,绝对不能输出空报告。","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"paragraph","content":[{"text":"如果 JSON 输出中 ","type":"text"},{"text":"no_data","type":"text","marks":[{"type":"code_inline"}]},{"text":" 为 ","type":"text"},{"text":"true","type":"text","marks":[{"type":"code_inline"}]},{"text":"(SLS 和 ARMS 均无数据):","type":"text"}]},{"type":"paragraph","content":[{"text":"第一次无数据 → 输出以下提示,等待用户回复:","type":"text","marks":[{"type":"strong"}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"⚠️ 在最近 {当前查询范围,如\"1周\"} 内({time_range})未查到任何数据。","type":"text"}]},{"type":"paragraph","content":[{"text":"回复序号或直接输入时间范围:","type":"text"}]},{"type":"paragraph","content":[{"text":"1","type":"text","marks":[{"type":"code_inline"}]},{"text":" 换时间重查 — 输入自然语言(如 ","type":"text"},{"text":"1个月","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"2周","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"3天","type":"text","marks":[{"type":"code_inline"}]},{"text":") ","type":"text"},{"text":"2","type":"text","marks":[{"type":"code_inline"}]},{"text":" 精确时间段 — 输入起止时间(如 ","type":"text"},{"text":"2024-03-10 00:00 ~ 2024-03-15 23:59","type":"text","marks":[{"type":"code_inline"}]},{"text":") ","type":"text"},{"text":"3","type":"text","marks":[{"type":"code_inline"}]},{"text":" 换条件重查 — 输入新的 trace_id / wusid / path ","type":"text"},{"text":"4","type":"text","marks":[{"type":"code_inline"}]},{"text":" 不用了 — 停止查询","type":"text"}]}]},{"type":"paragraph","content":[{"text":"收到用户回复后:","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"1","type":"text","marks":[{"type":"code_inline"}]},{"text":" 或直接输入时间(如\"1个月\"、\"2周\"、\"3天\")→ 用 ","type":"text"},{"text":"--duration","type":"text","marks":[{"type":"code_inline"}]},{"text":" 重新执行 Step 2,然后回到 Step 3","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"2","type":"text","marks":[{"type":"code_inline"}]},{"text":" 或输入精确时间段(如\"3月10号到3月15号\")→ 计算为 ","type":"text"},{"text":"--start/--end","type":"text","marks":[{"type":"code_inline"}]},{"text":" 重新执行","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"3","type":"text","marks":[{"type":"code_inline"}]},{"text":" → 回到 Step 1.2 重新收集参数","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"4","type":"text","marks":[{"type":"code_inline"}]},{"text":" 或\"不用了\"、\"算了\"、\"停\" → 停止,输出简短结论:「在所有尝试的时间范围内均未查到该 TraceID 的数据,可能原因:1) TraceID 不正确 2) 日志已过期被清理 3) 该请求未经过当前 SLS 项目」","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"再次无数据(第二次、第三次…) → 继续循环询问:","type":"text","marks":[{"type":"strong"}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"⚠️ 在 {本次时间范围} 内仍未查到数据。","type":"text"}]},{"type":"paragraph","content":[{"text":"1","type":"text","marks":[{"type":"code_inline"}]},{"text":" 换时间继续 — 输入新的时间范围 ","type":"text"},{"text":"2","type":"text","marks":[{"type":"code_inline"}]},{"text":" 换条件重查 — 输入新的 trace_id / wusid / path ","type":"text"},{"text":"3","type":"text","marks":[{"type":"code_inline"}]},{"text":" 不用了 — 停止查询","type":"text"}]}]},{"type":"paragraph","content":[{"text":"循环规则:","type":"text","marks":[{"type":"strong"}]}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"每次查不到数据 → 必须停下来问用户 → 等用户回复 → 按用户指示执行","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"绝不跳过询问直接输出报告","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"绝不自行决定用什么时间重试","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"用户在此上下文中说的任何时间表述,一律视为新的查询时间范围","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"只有 ","type":"text"},{"text":"no_data","type":"text","marks":[{"type":"code_inline"}]},{"text":" 为 ","type":"text"},{"text":"false","type":"text","marks":[{"type":"code_inline"}]},{"text":"(查到数据了)才进入 Step 4 输出完整报告","type":"text"}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 4:输出分析报告(格式严格按下方执行)","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"paragraph","content":[{"text":"📋 问题定位报告","type":"text","marks":[{"type":"strong"}]}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"项目","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"内容","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"TraceID","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{query.trace_id 或 discovered_traces 中用户选择的 trace_id}","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"WSUID","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{query.wusid,无则省略此行}","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"请求路径","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{query.path,无则省略此行}","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"时间范围","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{time_range}","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"涉及服务","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{call_chain.services}","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"总耗时","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{call_chain.total_duration_ms}ms","type":"text","marks":[{"type":"code_inline"}]}]}]}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"paragraph","content":[{"text":"🗺️ ARMS 调用链路图","type":"text","marks":[{"type":"strong"}]},{"text":"(此段必须输出,不可跳过)","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"判断条件:","type":"text"},{"text":"call_chain.total_spans > 0","type":"text","marks":[{"type":"code_inline"}]},{"text":" 表示有数据,","type":"text"},{"text":"== 0","type":"text","marks":[{"type":"code_inline"}]},{"text":" 表示无数据。 ","type":"text"},{"text":"call_chain.tree","type":"text","marks":[{"type":"code_inline"}]},{"text":" 始终有值(无数据时也有提示文本),","type":"text"},{"text":"必须原样输出","type":"text","marks":[{"type":"strong"}]},{"text":"。","type":"text"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"{call_chain.tree 的完整内容,一字不改直接输出}","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"示例(有数据时):","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"● [rpc-ny] gRPC → /PromotePB/UpdateRelation 156ms ❌\n └─ [promote-service] MySQL → SELECT 12ms ✅\n ⚡ 错误: record not found\n 🔗 异常ID: 811073848360427400","type":"text"}]},{"type":"paragraph","content":[{"text":"示例(无数据时,脚本输出的 tree 已包含提示):","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"⚠️ ARMS 未采样到此 TraceID 的调用链","type":"text"}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"paragraph","content":[{"text":"❌ 异常 Span","type":"text","marks":[{"type":"strong"}]},{"text":"(此段必须输出,不可跳过)","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"判断条件:","type":"text"},{"text":"call_chain.error_spans","type":"text","marks":[{"type":"code_inline"}]},{"text":" 列表是否非空。","type":"text"}]}]},{"type":"paragraph","content":[{"text":"有异常 Span(","type":"text","marks":[{"type":"strong"}]},{"text":"call_chain.error_count > 0","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":")时,逐个输出:","type":"text","marks":[{"type":"strong"}]}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"服务","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"操作","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"异常 ID","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"耗时","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"错误信息","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{service}","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{operation}","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{exception_id}","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{duration_ms}ms","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{tags.error.message 或 tags.exception.message}","type":"text","marks":[{"type":"code_inline"}]}]}]}]}]},{"type":"paragraph","content":[{"text":"每个异常 Span 下方,如果有 ","type":"text"},{"text":"full_stack","type":"text","marks":[{"type":"code_inline"}]},{"text":",必须输出完整堆栈:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"🔗 异常ID: {exception_id}\n⚡ 堆栈:\n{full_stack 完整内容,不截断,逐行输出}","type":"text"}]},{"type":"paragraph","content":[{"text":"无异常 Span(","type":"text","marks":[{"type":"strong"}]},{"text":"call_chain.error_count == 0","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":")时,输出:","type":"text","marks":[{"type":"strong"}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"无异常 Span(ARMS 未采样或调用链无错误)","type":"text"}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"paragraph","content":[{"text":"🔬 方法级堆栈详情(GetStack)","type":"text","marks":[{"type":"strong"}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"判断条件:","type":"text"},{"text":"stack_details","type":"text","marks":[{"type":"code_inline"}]},{"text":" 不为 null 且非空对象。","type":"text"}]}]},{"type":"paragraph","content":[{"text":"有 ","type":"text","marks":[{"type":"strong"}]},{"text":"stack_details","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":" 数据时,逐个输出:","type":"text","marks":[{"type":"strong"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"── [{service}] {operation} → 异常ID: {exception_id} ──\n{formatted 的完整内容,一字不改直接输出}","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"示例:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"── [rpc-ny] UpdateRelation → 异常ID: 811073848360427400 ──\n [ 1] com.ny.service.PromoteService.updateRelation (服务: rpc-ny) 156ms L212\n ⚡ 异常: record not found\n [ 2] com.ny.dao.PromoterDAO.getByWusId (服务: rpc-ny) 12ms L89","type":"text"}]}]},{"type":"paragraph","content":[{"text":"无 ","type":"text","marks":[{"type":"strong"}]},{"text":"stack_details","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":" 数据时,输出:","type":"text","marks":[{"type":"strong"}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"无方法级堆栈(ARMS 未采样或无异常 Span)","type":"text"}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"paragraph","content":[{"text":"📄 SLS 日志 — 按 LogStore 分组","type":"text","marks":[{"type":"strong"}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"⚠️ 以下每个 LogStore 单独展示,不合并,不去重","type":"text"}]}]},{"type":"paragraph","content":[{"text":"查询统计:","type":"text","marks":[{"type":"strong"}]}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"LogStore","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"状态","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"日志条数","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{logstore1}","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{status}","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{count}","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{logstore2}","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{status}","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{count}","type":"text","marks":[{"type":"code_inline"}]}]}]}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"paragraph","content":[{"text":"【LogStore: {logstore名称1}】","type":"text","marks":[{"type":"strong"}]},{"text":"(共 {count} 条)","type":"text"}]},{"type":"paragraph","content":[{"text":"逐条输出该 logstore 的每条日志:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"[1] 时间:{time}\n 级别:{level}\n 服务:{service}\n 文件:{file}\n 消息:{message}\n 附加:{raw 中的 attach / request / response 等关键字段}","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"paragraph","content":[{"text":"【LogStore: {logstore名称2}】","type":"text","marks":[{"type":"strong"}]},{"text":"(共 {count} 条)","type":"text"}]},{"type":"paragraph","content":[{"text":"逐条输出该 logstore 的每条日志(同上格式):","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"[1] 时间:{time}\n 级别:{level}\n 服务:{service}\n 文件:{file}\n 消息:{message}\n 附加:{raw 中的关键字段}","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"paragraph","content":[{"text":"🔍 根因分析","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"直接原因","type":"text","marks":[{"type":"strong"}]},{"text":":{结合 ARMS error_spans 和 SLS error_logs 的错误信息}","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"触发位置","type":"text","marks":[{"type":"strong"}]},{"text":":{service} → {operation}(来自哪个 logstore 第几条)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"关联日志","type":"text","marks":[{"type":"strong"}]},{"text":":{指明是哪个 logstore 的第几条}","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"根本原因","type":"text","marks":[{"type":"strong"}]},{"text":":{综合分析}","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"🛠️ 建议修复方向","type":"text","marks":[{"type":"strong"}]}]},{"type":"paragraph","content":[{"text":"{修复建议}","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 4.5:报告输出后的后续操作提示(必须严格按模板)","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"⚠️ 核心规则:输出完 Step 4 报告后,必须且只能输出下面的统一模板,禁止自由发挥任何后续操作文字。","type":"text","marks":[{"type":"strong"}]},{"text":" ","type":"text"},{"text":"禁止行为:","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"输出不带序号的选项,如\"继续操作:新 trace_id / 用 wusid 查 / 不用了\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"省略\"查看代码\"选项","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"自编任何不在模板中的提示文字","type":"text"}]}]}]}]},{"type":"paragraph","content":[{"text":"无论查询结果如何(成功/部分失败/有异常/无异常),Step 4 报告末尾统一输出以下模板:","type":"text","marks":[{"type":"strong"}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"回复序号选择下一步:","type":"text"}]},{"type":"paragraph","content":[{"text":"1","type":"text","marks":[{"type":"code_inline"}]},{"text":" 排查代码 — 搜索 ","type":"text"},{"text":"{operation}","type":"text","marks":[{"type":"code_inline"}]},{"text":" 方法源码,定位问题 ","type":"text"},{"text":"2","type":"text","marks":[{"type":"code_inline"}]},{"text":" 换条件重查 — 输入新的 trace_id / wusid / path ","type":"text"},{"text":"3","type":"text","marks":[{"type":"code_inline"}]},{"text":" 换时间重查 — 输入新的时间范围(如 ","type":"text"},{"text":"1个月","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"3天","type":"text","marks":[{"type":"code_inline"}]},{"text":") ","type":"text"},{"text":"4","type":"text","marks":[{"type":"code_inline"}]},{"text":" 用 wusid 查用户请求 — 输入 wusid 查该用户的所有请求 ","type":"text"},{"text":"5","type":"text","marks":[{"type":"code_inline"}]},{"text":" 不用了 — 结束排查","type":"text"}]}]},{"type":"paragraph","content":[{"text":"其中 ","type":"text"},{"text":"{operation}","type":"text","marks":[{"type":"code_inline"}]},{"text":" 替换为 ARMS error_spans 中的操作名(如 ","type":"text"},{"text":"UpdateRelation","type":"text","marks":[{"type":"code_inline"}]},{"text":"),无 ARMS 数据时替换为请求路径中的方法名。","type":"text"}]},{"type":"paragraph","content":[{"text":"用户回复处理:","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"1","type":"text","marks":[{"type":"code_inline"}]},{"text":" → 直接进入 Step 5 代码排查","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"2","type":"text","marks":[{"type":"code_inline"}]},{"text":" → 回到 Step 1.2 重新收集参数","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"3","type":"text","marks":[{"type":"code_inline"}]},{"text":" → 用新时间范围重新执行 Step 2","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"4","type":"text","marks":[{"type":"code_inline"}]},{"text":" → 用户提供 wusid 后,以模式 B 重新执行 Step 2","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"5","type":"text","marks":[{"type":"code_inline"}]},{"text":" → 输出简短结论,结束","type":"text"}]}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 5:代码级排查(必须自动执行,不能只建议)","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"⚠️ 核心规则:输出完 Step 4 报告后,如果存在 ERROR 日志或异常 Span,必须立即自动执行代码搜索,不能只输出\"建议搜索 xxx 方法\"之类的文字。","type":"text","marks":[{"type":"strong"}]},{"text":" 如果日志和调用链均无异常,跳过此步。","type":"text"}]},{"type":"paragraph","content":[{"text":"禁止行为","type":"text","marks":[{"type":"strong"}]},{"text":":输出类似\"建议:在代码仓库搜索 UpdateRelation 方法\"的文字而不实际执行搜索。必须直接使用 Grep/Glob/Read 工具去搜索代码。","type":"text"}]}]},{"type":"heading","attrs":{"level":4},"content":[{"text":"5.1 提取代码线索","type":"text"}]},{"type":"paragraph","content":[{"text":"从 Step 3/4 的结果中提取以下信息,作为代码搜索的关键词:","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"来源","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"提取内容","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"用途","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"SLS 日志 ","type":"text"},{"text":"file","type":"text","marks":[{"type":"code_inline"}]},{"text":" 字段","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"文件名和行号(如 ","type":"text"},{"text":"handler.go:156","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"直接定位源码位置","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"SLS 日志 ","type":"text"},{"text":"message","type":"text","marks":[{"type":"code_inline"}]},{"text":" 字段","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"错误消息关键词(如 ","type":"text"},{"text":"record not found","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"nil pointer","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"搜索错误产生位置","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"ARMS ","type":"text"},{"text":"error_spans","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"服务名 + 操作名(如 ","type":"text"},{"text":"promote-service","type":"text","marks":[{"type":"code_inline"}]},{"text":" → ","type":"text"},{"text":"UpdateRelation","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"定位入口函数","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"ARMS ","type":"text"},{"text":"tags","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"exception.type","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"error.message","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"db.statement","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"定位异常类型和 SQL","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"ARMS ","type":"text"},{"text":"stack_details","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"方法级堆栈中的类名、方法名、行号","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"精确定位异常代码位置","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"SLS 日志 ","type":"text"},{"text":"raw","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"data.request","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"data.response","type":"text","marks":[{"type":"code_inline"}]},{"text":" 中的业务字段","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"理解请求上下文","type":"text"}]}]}]}]},{"type":"heading","attrs":{"level":4},"content":[{"text":"5.2 搜索源码","type":"text"}]},{"type":"paragraph","content":[{"text":"按优先级依次搜索(找到即停):","type":"text","marks":[{"type":"strong"}]}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"有明确文件名+行号","type":"text","marks":[{"type":"strong"}]},{"text":"(如 ","type":"text"},{"text":"caller: service/handler.go:156","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"直接用 Grep 搜索该文件名,用 Read 读取对应代码段(前后各 30 行)","type":"text"}]}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"有函数/方法名","type":"text","marks":[{"type":"strong"}]},{"text":"(如 ARMS 的 ","type":"text"},{"text":"operation: UpdateRelation","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"用 Grep 搜索函数定义:","type":"text"},{"text":"func.*UpdateRelation","type":"text","marks":[{"type":"code_inline"}]},{"text":" 或 ","type":"text"},{"text":"def UpdateRelation","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"读取函数完整实现","type":"text"}]}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"有错误消息","type":"text","marks":[{"type":"strong"}]},{"text":"(如 ","type":"text"},{"text":"record not found","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"duplicate key","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"用 Grep 在项目中搜索该错误消息字符串","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"找到错误产生的代码位置","type":"text"}]}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"有请求路径","type":"text","marks":[{"type":"strong"}]},{"text":"(如 ","type":"text"},{"text":"/ny.apps_pb.promote_pb.PromotePB/UpdateRelation","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"路径中提取服务名和方法名(","type":"text"},{"text":"PromotePB","type":"text","marks":[{"type":"code_inline"}]},{"text":" / ","type":"text"},{"text":"UpdateRelation","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"搜索 proto 定义和对应的 handler 实现","type":"text"}]}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"有 GetStack 方法级堆栈","type":"text","marks":[{"type":"strong"}]},{"text":"(","type":"text"},{"text":"stack_details","type":"text","marks":[{"type":"code_inline"}]},{"text":" 不为空)","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"从堆栈条目的 ","type":"text"},{"text":"api","type":"text","marks":[{"type":"code_inline"}]},{"text":" 字段提取类名.方法名(如 ","type":"text"},{"text":"com.xxx.service.UpdateRelation","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"用 Grep 搜索对应的类定义和方法实现","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"堆栈中有 ","type":"text"},{"text":"exception","type":"text","marks":[{"type":"code_inline"}]},{"text":" 字段的条目优先搜索","type":"text"}]}]}]}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"搜索范围与代码仓库定位规则:","type":"text","marks":[{"type":"strong"}]}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"先在当前工作目录用 Grep 搜索关键方法/类名","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"如果当前目录搜不到(0 个结果),","type":"text"},{"text":"输出以下提示(严格按模板)","type":"text","marks":[{"type":"strong"}]},{"text":":","type":"text"}]}]}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"💻 需要搜索代码仓库来定位问题源码。\n\n当前目录未找到相关代码,请提供业务代码仓库路径:\n- 示例:`C:\\projects\\promote-service` 或 `/home/user/go/src/promote`\n- 如果有多个服务,可提供多个路径,用 `;` 分隔","type":"text"}]},{"type":"ordered_list","attrs":{"order":3,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"用户提供路径后 → 在该路径下用 Grep 搜索,然后继续 5.3 分析","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"必须实际执行搜索","type":"text","marks":[{"type":"strong"}]},{"text":":使用 Grep 工具搜索代码,不能只输出文字建议","type":"text"}]}]}]}]},{"type":"heading","attrs":{"level":4},"content":[{"text":"5.3 分析代码问题","type":"text"}]},{"type":"paragraph","content":[{"text":"找到相关代码后,分析以下内容:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"错误触发路径","type":"text","marks":[{"type":"strong"}]},{"text":":从入口函数到报错位置的调用链路","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"错误原因","type":"text","marks":[{"type":"strong"}]},{"text":":参数校验缺失?空指针?异常未捕获?逻辑错误?","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"上下文数据","type":"text","marks":[{"type":"strong"}]},{"text":":结合 SLS 日志中的 request/response 数据,还原触发条件","type":"text"}]}]}]},{"type":"heading","attrs":{"level":4},"content":[{"text":"5.4 输出代码分析","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"**💻 代码排查**\n\n**定位文件:** `{file_path}:{line_number}`\n\n**关键代码段:**\n​```{language}\n// 标注问题所在行\n{code snippet with comments}\n​```\n\n**问题分析:**\n- 错误路径:{入口} → {中间调用} → {报错位置}\n- 直接原因:{具体代码问题,如\"第 156 行未检查 err 返回值\"}\n- 触发条件:{结合日志中的 request 数据说明什么情况下会触发}\n\n> ⚠️ 仅指出代码问题,不直接修改代码。由用户自行决定如何修复。","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 6:数据库排查(当错误涉及数据库时)","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"触发条件","type":"text","marks":[{"type":"strong"}]},{"text":":仅当以下任一条件满足时才执行此步骤:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"ARMS tags 中有 ","type":"text"},{"text":"db.statement","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"db.type","type":"text","marks":[{"type":"code_inline"}]},{"text":" 字段","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"错误消息包含 SQL/数据库相关关键词(","type":"text"},{"text":"duplicate key","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"deadlock","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"record not found","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"foreign key","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"table doesn't exist","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"column not found","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"timeout","type":"text","marks":[{"type":"code_inline"}]},{"text":" + ","type":"text"},{"text":"sql","type":"text","marks":[{"type":"code_inline"}]},{"text":"/","type":"text"},{"text":"db","type":"text","marks":[{"type":"code_inline"}]},{"text":"/","type":"text"},{"text":"mysql","type":"text","marks":[{"type":"code_inline"}]},{"text":"/","type":"text"},{"text":"redis","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"SLS 日志中出现 SQL 语句或数据库错误","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"代码排查中发现 ORM 操作或 SQL 拼接","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"不满足以上条件则跳过此步骤。","type":"text"}]}]},{"type":"heading","attrs":{"level":4},"content":[{"text":"6.1 提取数据库线索","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"来源","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"提取内容","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"ARMS ","type":"text"},{"text":"tags.db.statement","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"完整 SQL 语句","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"ARMS ","type":"text"},{"text":"tags.db.type","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"数据库类型(MySQL/Redis/ES)","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"SLS 日志","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"SQL 相关错误消息","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Step 5 代码","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"ORM 模型定义、SQL 拼接逻辑、表名/字段名","type":"text"}]}]}]}]},{"type":"heading","attrs":{"level":4},"content":[{"text":"6.2 分析数据库问题","type":"text"}]},{"type":"paragraph","content":[{"text":"根据错误类型进行针对性分析:","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"错误类型","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"排查方向","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"record not found","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"查询条件是否正确?数据是否存在?是否有软删除过滤?","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"duplicate key","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"唯一索引冲突,检查插入逻辑是否有并发问题或重试机制","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"deadlock","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"事务中的锁顺序,是否有交叉更新","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"timeout","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"慢 SQL,检查是否缺少索引、全表扫描、大事务","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"foreign key","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"外键约束失败,检查关联数据是否存在","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"connection refused","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"数据库连接池耗尽或实例宕机","type":"text"}]}]}]}]},{"type":"heading","attrs":{"level":4},"content":[{"text":"6.3 搜索相关代码中的数据库操作","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"在 Step 5 定位到的代码文件中,搜索 ORM 操作(如 ","type":"text"},{"text":"db.Where","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"db.Create","type":"text","marks":[{"type":"code_inline"}]},{"text":"、","type":"text"},{"text":"Model.objects","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"查找表结构定义(model/schema)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"查找 SQL 拼接或 Raw SQL","type":"text"}]}]}]},{"type":"heading","attrs":{"level":4},"content":[{"text":"6.4 输出数据库分析","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"**🗄️ 数据库排查**\n\n**涉及表/操作:** `{table_name}` — `{SELECT/INSERT/UPDATE/DELETE}`\n\n**问题 SQL:**\n​```sql\n{SQL 语句,标注问题部分}\n​```\n\n**分析:**\n- 错误类型:{如 duplicate key on index `idx_xxx`}\n- 原因:{如并发插入同一唯一键}\n- 对应代码:`{file}:{line}` — {代码描述}\n\n**🔎 建议检查的数据库配置项:**\n- 表:`{table_name}`\n- 字段/索引:`{需要检查的字段或索引名}`\n- 检查内容:{如\"确认该用户的 xxx 字段值是否为 null\"、\"检查 idx_xxx 索引是否存在\"、\"核实 xxx 配置表中 key=yyy 的记录是否正确\"}\n- 参考 SQL:`SELECT ... FROM {table} WHERE {condition}`","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"⚠️ 仅指出应该检查哪些数据库配置项和数据,不直接执行 SQL。由用户或 DBA 自行查询确认。","type":"text"}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 7:综合结论与修复建议","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"在完成所有排查后(Step 4 报告 + Step 5 代码 + Step 6 数据库),输出最终综合结论。","type":"text"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"**📝 综合结论**\n\n**问题链路:**\n{用户请求} → {入口服务} → {中间调用} → {出错位置}\n\n**根本原因:**\n{一句话总结,结合日志 + 代码 + 数据库的分析}\n\n**代码问题:**\n1. {文件:行号} — {问题描述}\n2. {文件:行号} — {问题描述}\n\n**需要检查的数据库配置:**\n1. 表 `{table}` — {检查什么,附参考 SQL}\n2. 配置项 `{key}` — {检查什么}\n\n**修复方向(按优先级):**\n1. 【紧急】{问题描述 + 修复思路}\n2. 【建议】{预防性改进}\n3. 【优化】{长期优化方向}\n\n**影响范围:**\n- 受影响接口:{path}\n- 受影响用户:{wusid 相关信息}\n- 影响程度:{根据 error_logs 数量和 error_spans 判断}","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"⚠️ 本报告仅指出问题和排查方向,不直接修改代码或执行数据库操作。","type":"text"}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 8:询问用户是否需要进一步操作","type":"text"}]},{"type":"paragraph","content":[{"text":"输出综合结论后,","type":"text"},{"text":"严格按以下模板输出","type":"text","marks":[{"type":"strong"}]},{"text":":","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"🔧 需要进一步操作吗?回复序号:","type":"text"}]},{"type":"paragraph","content":[{"text":"1","type":"text","marks":[{"type":"code_inline"}]},{"text":" 查看更多代码 — 深入分析相关文件或上下游调用 ","type":"text"},{"text":"2","type":"text","marks":[{"type":"code_inline"}]},{"text":" 查看更多日志 — 换条件 / 换时间范围重新查询 ","type":"text"},{"text":"3","type":"text","marks":[{"type":"code_inline"}]},{"text":" 分析其他 TraceID — 输入新的查询条件 ","type":"text"},{"text":"4","type":"text","marks":[{"type":"code_inline"}]},{"text":" 不用了 — 结束排查","type":"text"}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"注意事项","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"每个 logstore 的日志必须独立展示","type":"text","marks":[{"type":"strong"}]},{"text":",哪怕内容高度相似也不能合并","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"ARMS 未采样到时(call_chain 为 null),只展示 SLS 日志,注明\"未采样到调用链\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"TraceID 长度为 30 位时 ARMS 不需要时间范围;其他长度需要 ","type":"text"},{"text":"--start/--end","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"SLS 和 ARMS 可以用不同的 AK/SK","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"模式 B 使用 ","type":"text"},{"text":"--no-interactive","type":"text","marks":[{"type":"code_inline"}]},{"text":",脚本自动选第一条 TraceID;如需让用户选择,展示 ","type":"text"},{"text":"discovered_traces","type":"text","marks":[{"type":"code_inline"}]},{"text":" 列表后用模式 A 重跑","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"--wusid","type":"text","marks":[{"type":"code_inline"}]},{"text":" 同时匹配 ","type":"text"},{"text":"wechat_user_space_id","type":"text","marks":[{"type":"code_inline"}]},{"text":" 和 ","type":"text"},{"text":"promoter_wechat_user_space_id","type":"text","marks":[{"type":"code_inline"}]},{"text":" 两个字段","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"--path","type":"text","marks":[{"type":"code_inline"}]},{"text":" 匹配 ","type":"text"},{"text":"data.request.path","type":"text","marks":[{"type":"code_inline"}]},{"text":" 字段,支持完整路径或路径片段","type":"text"}]}]}]},{"type":"hr","attrs":{"markup":"---"}}]},"metadata":{"date":"2026-06-05","name":"sls-trace-analysis","author":"@skillopedia","source":{"stars":2012,"repo_name":"openclaw-master-skills","origin_url":"https://github.com/leoyeai/openclaw-master-skills/blob/HEAD/skills/sls-trace-analysis/SKILL.md","repo_owner":"leoyeai","body_sha256":"c47a603ceaf9816737afe087b52800533e322edd0d0e0f016cf53232770a4886","cluster_key":"f472137d06c47844e9763e6aedb1d567f60e27052293d549ecda29c6a8e7b682","clean_bundle":{"format":"clean-skill-bundle-v1","source":"leoyeai/openclaw-master-skills/skills/sls-trace-analysis/SKILL.md","attachments":[{"id":"94a68479-5535-5965-bcf4-fdbac2d7f6f3","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/94a68479-5535-5965-bcf4-fdbac2d7f6f3/attachment.md","path":"README.md","size":2073,"sha256":"e8ddb204e676e0564e60781fb21b518fa072e963dd2dff004f37c9a1b68efc68","contentType":"text/markdown; charset=utf-8"},{"id":"4baa924e-ae07-576b-9b52-4a61152b1dc4","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/4baa924e-ae07-576b-9b52-4a61152b1dc4/attachment.json","path":"_meta.json","size":306,"sha256":"2a0dbbff5e34247a113bf02131ccb807a42388cb46a9a036c1e9acd205ca84a4","contentType":"application/json; charset=utf-8"},{"id":"6df4e2f2-6477-56e2-adb5-0bc6a9070251","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/6df4e2f2-6477-56e2-adb5-0bc6a9070251/attachment.py","path":"scripts/query_trace.py","size":64030,"sha256":"41653159e249fe06dff3ed8e65e836990fe4ff43763119a9c19e451028f07b1e","contentType":"text/x-python; charset=utf-8"},{"id":"29dec2c3-e45d-5b9d-8d45-08493fc7ae1b","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/29dec2c3-e45d-5b9d-8d45-08493fc7ae1b/attachment.txt","path":"scripts/requirements.txt","size":64,"sha256":"7c43041d89c6df0714a830a3c9a96d0dc38105dc6510c4d1f7947c915491570e","contentType":"text/plain; charset=utf-8"}],"bundle_sha256":"d322b8b2399b0bc779c7477b6d465951f72860bd58b0bda29d263435cd06458e","attachment_count":4,"text_attachments":4,"attachment_storage":"skillopedia-attachments-v1","binary_attachments":0,"excluded_attachments":[]},"cluster_size":1,"skill_md_path":"skills/sls-trace-analysis/SKILL.md","import_metadata":{"date":"2026-06-05","author":"@skillopedia","version":"v1","category":"web-development","category_label":"Web"},"exact_dupes_collapsed_into_this":0},"license":"MIT-0","version":"v1","category":"web-development","metadata":{"openclaw":{"tags":["sls","arms","trace","debug","log-analysis","alibaba-cloud"],"emoji":"🔍","author":"Crazyfish","version":"1.0.0","requires":{"env":["ALIBABA_CLOUD_ACCESS_KEY_ID","ALIBABA_CLOUD_ACCESS_KEY_SECRET"],"bins":["python"]}}},"import_tag":"clean-skills-v1","description":"查询阿里云SLS日志和ARMS调用链,结合源码和数据库进行全链路问题排查。 完整流程:查日志 → 画调用链 → 定位源码 → 排查数据库 → 给出修复方案。 Use when: 用户说「分析sls」「分析问题」或想排查业务服务/线上接口/用户请求的报错或异常。 触发示例:「分析sls」「帮我查一下这个trace_id」「分析一下这个trace_id」 「查一下这个用户的请求」「wusid 是 xxx」「uid xxx」 「查一下 /path/to/api 这个接口的报错」「帮我排查一下这个业务报错」「线上有个接口挂了」 「帮我分析一下这个报错的代码」「数据库报错了」「SQL超时」「查一下这个接口为什么慢」。 IMPORTANT: trace_id = 染色ID = 业务调用链ID = requestId,这些都是同一个东西, 统一用 trace_id 表述。用户提供的 trace_id 是业务系统的外部 trace,不是 OpenClaw 内部 session ID, 不要自行分析 trace_id 的来源或归属,必须调用此 skill 去 SLS/ARMS 查询。 NOT for: 查询OpenClaw自身状态、分析OpenClaw系统问题、搜索本地文件、openclaw内置命令。\n","compatibility":"Python 3.8+, aliyun-log-python-sdk 0.9.42+, alibabacloud-arms20190808 10.0.4+. 需要阿里云 SLS 和 ARMS 的 AccessKey (AK/SK). Windows / macOS / Linux 均可运行.\n","user-invocable":true}},"renderedAt":1782980355286}

SLS + ARMS + 代码 + 数据库 全链路问题排查 查询阿里云SLS日志和ARMS调用链 → 定位源码问题 → 排查数据库异常 → 给出完整修复方案。 ⚠️ 关键规则(必须严格遵守) 1. 必须且只能通过执行下方 python 命令查询,禁止使用本地搜索或内置日志命令。 2. 用户给出的 trace id 是外部业务系统的 ID,禁止自行推断其来源、归属或意义,直接执行查询脚本。 3. 每个 logstore 的日志必须单独分组展示,严禁合并或去重。 4. 即使多条日志来自同一服务、同一时间,也必须逐条完整输出。 5. 输出报告中必须包含 里每个 logstore 的所有日志。 6. 所有交互提示必须严格按照下方模板输出,禁止自由发挥、禁止用自己的话改写、禁止添加语气词或额外解释。用户看到的提示必须和模板一字不差。 7. Step 5 代码搜索和 Step 6 数据库排查必须自动执行,禁止只输出"建议搜索xxx"之类的文字。发现异常后必须立即用 Grep/Glob/Read 工具实际搜索代码仓库。 8. 所有提供选项的提示必须带序号( …),用户可以直接回复序号操作。禁止输出不带序号的选项列表。禁止自编"继续操作"/"接下来"等不在模板中的提示文字。每个需要用户选择的场景都有对应模板,必须使用模板。 --- 执行步骤 Step 1:收集查询参数(交互式) 进入此 skil…