> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flashduty.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 获取拓扑摘要

> 返回某台主机出向服务依赖的有界摘要，专为 AI 场景准备。

## 限制说明

| 项目   | 说明                         |
| ---- | -------------------------- |
| 速率限制 | 每个账户 **30 次/分钟**；**2 次/秒** |
| 权限要求 | **服务拓扑查看**（`monit`）        |

## 使用说明

* 服务拓扑是可选子系统：未配置 `redis.servicemap` 的部署会返回 `ServiceUnavailable`。
* `anchor.host_id` 必须已被服务拓扑感知，否则返回 `ResourceNotFound`。
* 本接口是固定大小的摘要，而非 `POST /monit/servicemap/topology` 的缩小版：深度固定为 1，相邻关系上限固定为 12 条，调用方均不可调整。
* `context_ref_detail` 是为大模型提示词预先渲染好的自然语言证据摘要文本；结构化字段才是权威来源，该字段只是对其的便捷呈现。
* `graph_role=last_known_good` 表示最新一次采集不健康，摘要改为基于上一份权威拓扑而非实时数据。


## OpenAPI

````yaml /api-reference/monitors.openapi.zh.json post /monit/servicemap/summary
openapi: 3.1.0
info:
  title: Flashduty 开放 API
  description: >-
    Flashduty 事件管理平台的公开 HTTP API —— 覆盖故障、通知模板、协作空间、值班排班、监控、RUM、以及平台管理。每次调用都需在
    query 中携带 `app_key`，该 key 在 Flashduty 控制台 账户 → APP Key 中签发。所有响应使用统一结构：成功时为
    `{ request_id, data }`，失败时为 `{ request_id, error }`。
  version: 1.0.0
servers:
  - url: https://api.flashcat.cloud
    description: Flashduty Open API
security:
  - AppKeyAuth: []
tags:
  - name: Monitors/告警规则
    description: 创建、管理和导出监控告警规则，查询规则统计和审计历史。
  - name: Monitors/告警数据源
    description: 管理监控告警规则用于查询指标的数据源。
  - name: Monitors/规则集
    description: 管理 Monitors 规则仓库中的共享规则集，规则集可在账户内或公开共享。
  - name: Monitors/诊断分析
    description: Flashduty AI SRE 使用的诊断与查询接口——数据源即席查询、日志/指标诊断,以及监控对象侧的工具调用。
  - name: Monitors/通用工具
    description: 监控服务开通及数据预览工具。
  - name: Monitors/服务拓扑
    description: 查询基于网络观测生成的服务拓扑、依赖摘要，以及主机的服务拓扑采集状态。
paths:
  /monit/servicemap/summary:
    post:
      tags:
        - Monitors/服务拓扑
      summary: 获取拓扑摘要
      description: 返回某台主机出向服务依赖的有界摘要，专为 AI 场景准备。
      operationId: monit-servicemap-read-summary
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceMapSummaryRequest'
            example:
              anchor:
                host_id: host_0123456789abcdef0123456789abcdef
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/ServiceMapSummaryResponse'
              example:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                data:
                  network_scope_id: ns_0123456789abcdef0123456789abcdef
                  anchor_host_id: host_0123456789abcdef0123456789abcdef
                  status: active
                  authoritative: true
                  graph_role: current
                  latest_collection_authoritative: true
                  observed_at_ms: 1784635556072
                  received_at_ms: 1784635557272
                  freshness:
                    status: fresh
                    newest_received_at_ms: 1784635557272
                    oldest_received_at_ms: 1784635557272
                    max_age_ms: 1200
                  coverage:
                    direction: outbound
                    hosts_loaded: 2
                    degraded_hosts: 0
                    truncated_hosts: 0
                    capture_modes:
                      - ebpf
                    network_inventory_status: complete
                    kubernetes_enrichment_status: unavailable
                  truncated: false
                  resolution_counts:
                    resolved: 1
                    ambiguous: 0
                    unresolved: 0
                  neighbors:
                    - edge_id: edge_v1_example
                      source_entity_id: procw_v1_source
                      source_display_name: orders.service
                      resolution_status: resolved
                      target_host_id: host_fedcba9876543210fedcba9876543210
                      target_entity_id: procw_v1_mysql
                      target_display_name: mysqld.service
                      destination_protocol: tcp
                      destination_ip: 203.0.113.105
                      destination_port: 3306
                      last_seen: '2026-07-21T18:45:56.072+08:00'
                      active_connections: 1
                  context_ref_detail: >-
                    ServiceMap current bounded evidence:
                    anchor_host_id=host_0123456789abcdef0123456789abcdef;
                    observed_at_ms=1784635556072; received_at_ms=1784635557272;
                    latest_health_at_ms=0; status=active; freshness=fresh;
                    graph_authoritative=true;
                    latest_collection_authoritative=true; coverage_hosts=2;
                    resolution_counts=resolved:1,ambiguous:0,unresolved:0;
                    truncated=false. Observed outbound relations
                    (relations_shown=1/1): [orders.service -> mysqld.service,
                    resolution=resolved,
                    last_seen=2026-07-21T18:45:56.072+08:00] Evidence rules:
                    only resolution=resolved relations are certain; treat
                    ambiguous/unresolved relations as leads to verify, not fact.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/ServerError'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
components:
  schemas:
    ServiceMapSummaryRequest:
      type: object
      description: 有界的、面向 AI 场景的依赖摘要查询参数。
      required:
        - anchor
      properties:
        anchor:
          $ref: '#/components/schemas/ServiceMapAnchor'
          description: 要生成摘要的主机（及可选的实体）。
        network_scope_id:
          type: string
          description: >-
            可选的一致性校验：如果设置，必须与 `anchor.host_id` 已关联的网络域一致，否则返回
            `InvalidParameter`。
    SuccessEnvelope:
      type: object
      description: >-
        成功响应结构。2xx 响应中 `request_id` 标识本次调用（同时出现在 `Flashcat-Request-Id`
        响应头中），`data` 为接口业务 payload。失败响应使用不同结构，参见 `ErrorResponse`。
      properties:
        request_id:
          type: string
          description: 本次请求的唯一 ID，也会在 Flashcat-Request-Id 响应头中返回。反馈问题时请一并附上。
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
        data:
          description: 每个接口自己的业务 payload，详见各接口的 200 响应 schema。
      required:
        - request_id
        - data
    ServiceMapSummaryResponse:
      type: object
      description: 某台主机出向服务依赖的有界、面向 AI 场景的摘要。
      required:
        - network_scope_id
        - anchor_host_id
        - status
        - authoritative
        - graph_role
        - latest_collection_authoritative
        - observed_at_ms
        - received_at_ms
        - freshness
        - coverage
        - truncated
        - resolution_counts
        - neighbors
        - context_ref_detail
      properties:
        network_scope_id:
          type: string
          description: 本次摘要解析所属的网络域。
        anchor_host_id:
          type: string
          description: 回显请求中的锚点主机 ID。
        anchor_entity_id:
          type: string
          description: 回显请求中的锚点实体 ID（如提供）。
        status:
          type: string
          enum:
            - active
            - degraded
            - stale
            - initializing
            - disabled
            - unsupported
            - no_data
          description: |-
            锚点主机的服务拓扑采集状态。

            | 值 | 含义 |
            |---|---|
            | `active` | 采集正常：有新鲜快照且无降级。 |
            | `degraded` | 采集在进行但质量受损：健康上报晚于快照、快照被截断/降级，或采集报错。 |
            | `stale` | 有快照但已过期（超过 2× 上报间隔未更新）。 |
            | `initializing` | Agent 已上报采集能力，但首个快照尚未就绪。 |
            | `disabled` | 该主机的拓扑采集被禁用。 |
            | `unsupported` | Agent 或内核不支持该采集。 |
            | `no_data` | 未收到任何快照或健康数据。 |
        authoritative:
          type: boolean
          description: 始终为 `true`；摘要仅基于权威拓扑数据构建。
        graph_role:
          type: string
          enum:
            - current
            - last_known_good
          description: '`current` 表示摘要基于实时拓扑；`last_known_good` 表示最新采集不健康，摘要改为基于上一份权威拓扑。'
        latest_collection_authoritative:
          type: boolean
          description: 当 `graph_role=last_known_good` 时为 false，即最近一次采集并非权威数据。
        latest_health_at_ms:
          type: integer
          format: int64
          description: 最近一次非权威健康信号的 Unix 时间戳（毫秒），仅当其晚于当前拓扑时出现。
        observed_at_ms:
          type: integer
          format: int64
          description: 底层数据被 Agent 观测到的 Unix 时间戳（毫秒）。
        received_at_ms:
          type: integer
          format: int64
          description: 服务端收到当前拓扑生成数据的 Unix 时间戳（毫秒）。
        freshness:
          $ref: '#/components/schemas/ServiceMapFreshness'
          description: 拓扑数据的新鲜程度。
        coverage:
          $ref: '#/components/schemas/ServiceMapTopologyCoverage'
          description: 锚点主机拓扑数据的整体覆盖与增强状态。
        truncated:
          type: boolean
          description: 若为保持固定大小的摘要而省略了任何相邻关系或覆盖细节，则为 true。
        truncation_reasons:
          type: array
          description: 当 `truncated=true` 时，摘要被截断的机器可读原因。
          items:
            type: string
        resolution_counts:
          $ref: '#/components/schemas/ServiceMapResolutionCounts'
          description: 锚点主机出向关系按解析结果分类的数量统计。
        neighbors:
          type: array
          description: 最多 12 条出向关系，信息量最高的排在前面。
          items:
            $ref: '#/components/schemas/ServiceMapSummaryNeighbor'
        context_ref_detail:
          type: string
          description: 为大模型提示词预先渲染好的自然语言证据摘要文本，是对上述结构化字段的便捷呈现，结构化字段本身才是权威来源。
    ServiceMapAnchor:
      type: object
      description: 标识本次查询锚定的主机（以及可选的具体进程/实体）。
      required:
        - host_id
      properties:
        host_id:
          type: string
          description: 稳定的服务拓扑主机标识符，例如 `host_0123...`。该主机必须已被服务拓扑感知。
          pattern: ^host_[a-z0-9_-]+$
          maxLength: 128
        entity_id:
          type: string
          description: 可选，主机内具体进程/实体的 ID，用于锚定到该实体。省略则锚定到整台主机。
    ServiceMapFreshness:
      type: object
      description: 描述底层拓扑数据的新鲜程度。
      required:
        - status
        - newest_received_at_ms
        - oldest_received_at_ms
        - max_age_ms
      properties:
        status:
          type: string
          enum:
            - fresh
            - stale
            - unknown
          description: >-
            新鲜度分类。`fresh` = 最近一次快照在 2× 上报间隔内收到；`stale` = 超过 2×
            上报间隔未收到新快照；`unknown` = 无快照数据，无法判定。
        newest_received_at_ms:
          type: integer
          format: int64
          description: 覆盖主机中最近一次收到拓扑数据的 Unix 时间戳（毫秒）。
        oldest_received_at_ms:
          type: integer
          format: int64
          description: 覆盖主机中最早一次收到拓扑数据的 Unix 时间戳（毫秒）。
        max_age_ms:
          type: integer
          format: int64
          description: 覆盖范围内最旧拓扑数据相对当前时间的年龄（毫秒）。
    ServiceMapTopologyCoverage:
      type: object
      description: 本次查询所加载的全部主机拓扑数据的整体覆盖与增强状态。
      required:
        - direction
        - hosts_loaded
        - degraded_hosts
        - truncated_hosts
        - network_inventory_status
        - kubernetes_enrichment_status
        - listener_address_family_status
      properties:
        direction:
          type: string
          enum:
            - outbound
          description: 始终为 `outbound`；服务拓扑当前仅建模出向关系。
        hosts_loaded:
          type: integer
          format: int64
          description: 为回答本次查询所加载的不同主机拓扑数量。
        degraded_hosts:
          type: integer
          format: int64
          description: 已加载的主机拓扑中，在采集时处于降级状态的数量。
        truncated_hosts:
          type: integer
          format: int64
          description: 已加载的主机拓扑中，在采集时被截断的数量。
        capture_modes:
          type: array
          description: 已加载主机中出现的不同采集模式（如 `ebpf`）。
          items:
            type: string
        network_inventory_status:
          type: string
          enum:
            - unknown
            - complete
            - partial
            - unavailable
          description: |-
            已加载主机的网络清单增强覆盖聚合状态（取所有主机中最差的一档）。

            | 值 | 含义 |
            |---|---|
            | `complete` | 所有主机请求的网络命名空间全部扫描成功且无错误。 |
            | `partial` | 至少一台主机部分命名空间未扫描成功，或扫描存在错误。 |
            | `unavailable` | 至少一台主机的命名空间全部未扫描成功。 |
            | `unknown` | 未加载任何主机，或某主机上报了无法识别的状态。 |
        kubernetes_enrichment_status:
          type: string
          enum:
            - unknown
            - complete
            - partial
            - unavailable
          description: |-
            已加载主机的 Kubernetes 增强覆盖聚合状态（取所有主机中最差的一档）。

            | 值 | 含义 |
            |---|---|
            | `complete` | 所有主机的实体均有完整的 Pod 绑定元数据。 |
            | `partial` | 至少一台主机存在绑定但部分 Pod 元数据缺失，或有绑定被丢弃。 |
            | `unavailable` | 至少一台主机没有任何 Pod 绑定。 |
            | `unknown` | 未加载任何主机，或某主机上报了无法识别的状态。 |
        listener_address_family_status:
          type: string
          enum:
            - unknown
            - complete
            - partial
            - unavailable
          description: |-
            已加载主机的监听地址族（IPv4/IPv6）解析覆盖聚合状态（取所有主机中最差的一档）。

            | 值 | 含义 |
            |---|---|
            | `complete` | 所有主机的 IPv6 通配监听器，其 IPv6-only 属性均已确认。 |
            | `partial` | 至少一台主机只有部分 IPv6 通配监听器的 IPv6-only 属性已确认。 |
            | `unavailable` | 至少一台主机的 IPv6 通配监听器 IPv6-only 属性全部未知。 |
            | `unknown` | 未加载任何主机，或某主机上报了无法识别的状态。 |
        ipv6_wildcard_listener_count:
          type: integer
          format: int64
          description: 观测到的 IPv6 通配（未指定地址）监听数量。
        ipv6_only_known_listener_count:
          type: integer
          format: int64
          description: IPV6_V6ONLY 设置已知的 IPv6 通配监听数量。
        ipv6_only_unknown_listener_count:
          type: integer
          format: int64
          description: IPV6_V6ONLY 设置无法确定的 IPv6 通配监听数量。
        reasons:
          type: array
          description: 解释已加载主机中降级或截断状态的机器可读原因码。
          items:
            type: string
    ServiceMapResolutionCounts:
      type: object
      description: 按解析结果分类的边数量统计。
      required:
        - resolved
        - ambiguous
        - unresolved
      properties:
        resolved:
          type: integer
          description: 解析到唯一置信候选的边数量。
        ambiguous:
          type: integer
          description: 解析到多个或低置信候选的边数量。
        unresolved:
          type: integer
          description: 未能解析出候选的边数量。
    ServiceMapSummaryNeighbor:
      type: object
      description: 折叠进摘要中的一条出向关系，结构为便于用于提示词的紧凑形式。
      required:
        - edge_id
        - source_entity_id
        - resolution_status
      properties:
        edge_id:
          type: string
          description: 边 ID。
        source_entity_id:
          type: string
          description: 源节点的实体 ID。
        source_display_name:
          type: string
          description: 源节点的展示名称（如已知）。
        resolution_status:
          type: string
          enum:
            - resolved
            - ambiguous
            - unresolved
          description: >-
            该关系目的端的解析结果。`resolved` = 唯一解析到某台主机的某个监听实体，关系可信；`ambiguous` =
            存在多个候选（或监听地址族未知），关系仅是待核实的线索；`unresolved` = 未找到任何候选，目的端身份未知。
        target_host_id:
          type: string
          description: 当 `resolution_status=resolved` 且唯一时，目标所在主机 ID。
        target_entity_id:
          type: string
          description: 当 `resolution_status=resolved` 且唯一时，目标的实体 ID。
        target_display_name:
          type: string
          description: 已解析目标的展示名称（如已知）。
        destination_protocol:
          type: string
          enum:
            - tcp
            - udp
          description: 目的端的传输协议。`tcp` = TCP 连接；`udp` = UDP 会话。当前采集端仅上报 `tcp`，`udp` 为预留值。
        destination_ip:
          type: string
          description: 目的 IP 地址。
        destination_port:
          type: integer
          description: 目的端口。
        last_seen:
          type: string
          format: date-time
          description: 最近一次观测到该关系的时间。
        active_connections:
          type:
            - integer
            - 'null'
          format: int64
          description: 该关系的活跃连接数（若底层 Agent 上报了该数据）。
    ErrorResponse:
      type: object
      description: 错误响应结构。`error` 必填，`data` 不存在。
      properties:
        request_id:
          type: string
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          description: 本次请求的唯一追踪 ID（trace ID），反馈问题时请提供该值以便检索日志。
        error:
          $ref: '#/components/schemas/DutyError'
      required:
        - request_id
        - error
    DutyError:
      type: object
      description: 响应结构中的错误 payload，仅在非 2xx 响应时出现。
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          description: 用户可读的错误描述，语言会跟随调用方的 Accept-Language。可能包含字段名、ID 等请求上下文。
          example: The specified parameter template_id is not valid.
      required:
        - code
        - message
    ErrorCode:
      type: string
      description: >-
        Flashduty 错误码枚举。每个失败响应的 `error.code` 都是下列稳定值之一，HTTP 状态码仅作参考。


        | 错误码 | HTTP | 含义 |

        |---|---|---|

        | `OK` | 200 | 保留值，正常错误响应不会返回。 |

        | `InvalidParameter` | 400 | 必填参数缺失或未通过校验。 |

        | `BadRequest` | 400 | 通用的 400 错误，通常是请求本身不合法。 |

        | `InvalidContentType` | 400 | 请求头 `Content-Type` 不是 `application/json`。
        |

        | `ResourceNotFound` | 400 | 目标资源不存在。注意 HTTP 状态码是 400 而非 404（历史设计）。 |

        | `NoLicense` | 400 | 功能需要有效授权，但未找到可用的 license。 |

        | `ReferenceExist` | 400 | 该资源仍被其他实体引用，无法删除。 |

        | `Unauthorized` | 401 | `app_key` 缺失、无效或已过期。 |

        | `BalanceNotEnough` | 402 | 账户余额不足，无法执行需要计费的操作。 |

        | `AccessDenied` | 403 | 身份认证通过，但 RBAC 权限不足以执行该操作。 |

        | `RouteNotFound` | 404 | 请求的 URL 路径不是已知路由。 |

        | `MethodNotAllowed` | 405 | 当前路径不接受所使用的 HTTP 方法。 |

        | `UndonedOrderExist` | 409 | 账户存在未完成的订单，请稍后重试。 |

        | `RequestLocked` | 423 | 因连续失败被临时锁定。 |

        | `EntityTooLarge` | 413 | 请求体超过允许的最大长度。 |

        | `RequestTooFrequently` | 429 | 命中限流（全局、账户级或集成级）。 |

        | `RequestVerifyRequired` | 428 | 操作需要二次验证码，但未提供。 |

        | `DangerousOperation` | 428 | 危险操作，需要进行 MFA 验证。 |

        | `InternalError` | 500 | 服务端未预期错误。反馈问题请附上 `request_id`。 |

        | `ServiceUnavailable` | 503 | 后端依赖不可用，请稍后重试。 |
      enum:
        - OK
        - InvalidParameter
        - BadRequest
        - InvalidContentType
        - ResourceNotFound
        - NoLicense
        - ReferenceExist
        - Unauthorized
        - BalanceNotEnough
        - AccessDenied
        - RouteNotFound
        - MethodNotAllowed
        - UndonedOrderExist
        - RequestLocked
        - EntityTooLarge
        - RequestTooFrequently
        - RequestVerifyRequired
        - DangerousOperation
        - InternalError
        - ServiceUnavailable
      x-enumDescriptions:
        OK: 保留值，正常错误响应不会返回。
        InvalidParameter: 必填参数缺失或未通过校验。
        BadRequest: 通用的 400 错误，通常是请求本身不合法。
        InvalidContentType: 请求头 `Content-Type` 不是 `application/json`。
        ResourceNotFound: 目标资源不存在。注意 HTTP 状态码是 400 而非 404（历史设计）。
        NoLicense: 功能需要有效授权，但未找到可用的 license。
        ReferenceExist: 该资源仍被其他实体引用，无法删除。
        Unauthorized: '`app_key` 缺失、无效或已过期。'
        BalanceNotEnough: 账户余额不足，无法执行需要计费的操作。
        AccessDenied: 身份认证通过，但 RBAC 权限不足以执行该操作。
        RouteNotFound: 请求的 URL 路径不是已知路由。
        MethodNotAllowed: 当前路径不接受所使用的 HTTP 方法。
        UndonedOrderExist: 账户存在未完成的订单，请稍后重试。
        RequestLocked: 因连续失败被临时锁定。
        EntityTooLarge: 请求体超过允许的最大长度。
        RequestTooFrequently: 命中限流（全局、账户级或集成级）。
        RequestVerifyRequired: 操作需要二次验证码，但未提供。
        DangerousOperation: 危险操作，需要进行 MFA 验证。
        InternalError: 服务端未预期错误。反馈问题请附上 `request_id`。
        ServiceUnavailable: 后端依赖不可用，请稍后重试。
      example: InvalidParameter
  responses:
    BadRequest:
      description: 请求非法 — 通常是参数缺失或格式不正确。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingParameter:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InvalidParameter
                  message: The specified parameter is not valid.
    Unauthorized:
      description: app_key 缺失或无效。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingAppKey:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: Unauthorized
                  message: You are unauthorized.
    TooManyRequests:
      description: 命中限流。可能是全局 API 限流、账户级限流或集成级限流。限流按账户聚合。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rateLimited:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: RequestTooFrequently
                  message: Request too frequently.
    ServerError:
      description: 服务端未预期错误。反馈问题时请携带 request_id。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            internal:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InternalError
                  message: >-
                    We encountered an internal error, and it has been reported.
                    Please try again later.
    ServiceUnavailable:
      description: 当前部署未开启或无法访问 ServiceMap 子系统。反馈问题时请附带 request_id。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            serviceMapDisabled:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: ServiceUnavailable
                  message: servicemap store is not initialized
  securitySchemes:
    AppKeyAuth:
      type: apiKey
      in: query
      name: app_key
      description: >-
        在 Flashduty 控制台 账户 → APP Key 中签发的 app_key。调用任何公开 API
        时都必须携带。它等同于所属账户的身份凭证，请妥善保管。

````