> ## 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.

# 浏览拓扑主机

> 浏览账户内启用了服务拓扑能力的主机及其当前采集状态。

## 限制说明

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

## 使用说明

* 与其余四个服务拓扑只读接口不同，本接口在服务拓扑存储不可用时会优雅降级：匹配逻辑仍基于清单数据运行，受影响的项通过 `servicemap.error_code=status_unavailable` 及 `partial=true` 披露，而不会导致整个请求失败。
* `cursor` 是不透明值，请原样传入 `next_cursor` 返回的值，不要自行构造或解析。
* 在找到 `limit` 个匹配前先达到 `scan_limit` 时，会设置 `truncated=true` 且仍会返回 `next_cursor`——这与扫描到账户主机末尾不是一回事。
* `coverage.scanned`/`matched`/`returned` 仅描述本页的扫描情况，不代表账户内主机总量。


## OpenAPI

````yaml /api-reference/monitors.openapi.zh.json post /monit/servicemap/fleet
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/fleet:
    post:
      tags:
        - Monitors/服务拓扑
      summary: 浏览拓扑主机
      description: 浏览账户内启用了服务拓扑能力的主机及其当前采集状态。
      operationId: monit-servicemap-read-fleet
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceMapFleetBrowseRequest'
            example:
              limit: 50
              scan_limit: 1000
              statuses:
                - degraded
                - stale
              agent_versions:
                - v1.2.3
              edge_clusters:
                - edge-a
              capture_modes:
                - ebpf
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/ServiceMapFleetBrowseResponse'
              example:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                data:
                  items:
                    - host_id: host_0123456789abcdef0123456789abcdef
                      agent_version: v1.2.3
                      edge_cluster: edge-a
                      servicemap:
                        enabled: true
                        status: degraded
                        capability_status: degraded
                        capture_mode: ebpf
                        snapshot_ready: true
                        authoritative: true
                        graph_available: false
                        freshness_status: fresh
                        observed_at_ms: 1784635557272
                        received_at_ms: 1784635557272
                        node_count: 46
                        edge_count: 200
                        reason_codes:
                          - snapshot_incomplete
                    - host_id: host_fedcba9876543210fedcba9876543210
                      agent_version: v1.2.3
                      edge_cluster: edge-a
                      servicemap:
                        enabled: true
                        status: stale
                        capability_status: running
                        capture_mode: ebpf
                        snapshot_ready: true
                        authoritative: true
                        graph_available: true
                        freshness_status: stale
                        observed_at_ms: 1784631957272
                        received_at_ms: 1784631957272
                        node_count: 38
                        edge_count: 152
                  coverage:
                    scanned: 80
                    matched: 2
                    returned: 2
                    failed: 0
                    states:
                      active: 0
                      degraded: 1
                      stale: 1
                      initializing: 0
                      disabled: 0
                      unsupported: 0
                      no_data: 0
                  partial: false
                  truncated: false
                  generated_at_ms: 1784635557272
        '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:
    ServiceMapFleetBrowseRequest:
      type: object
      description: 浏览已启用服务拓扑能力主机的过滤与分页参数。
      properties:
        cursor:
          type: string
          description: 不透明的分页游标。请原样传入上一次响应中的 `next_cursor`；首页请省略此字段。
        limit:
          type: integer
          description: 本页最多返回的匹配主机数。默认 50，范围 1～100。
          default: 50
          minimum: 1
          maximum: 100
        scan_limit:
          type: integer
          description: 填充本页时最多检查的候选主机数。默认 1000，范围 `limit`～2000。
          default: 1000
          maximum: 2000
        statuses:
          type: array
          description: 筛选处于以下任一状态的主机，最多 20 个值。
          items:
            type: string
            enum:
              - active
              - degraded
              - stale
              - initializing
              - disabled
              - unsupported
              - no_data
          maxItems: 20
        agent_versions:
          type: array
          description: 筛选运行以下任一确切 Agent 版本的主机，最多 20 个值。
          items:
            type: string
          maxItems: 20
        edge_clusters:
          type: array
          description: 筛选属于以下任一确切边缘集群名称的主机，最多 20 个值。
          items:
            type: string
          maxItems: 20
        capture_modes:
          type: array
          description: 筛选使用以下任一采集模式的主机。`unknown` 匹配尚未上报采集模式的主机。
          items:
            type: string
            enum:
              - ebpf
              - polling
              - unknown
          maxItems: 3
    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
    ServiceMapFleetBrowseResponse:
      type: object
      description: 匹配主机群浏览过滤条件的一页主机结果。
      required:
        - items
        - coverage
        - partial
        - truncated
        - generated_at_ms
      properties:
        items:
          type: array
          description: 本页匹配到的主机。
          items:
            $ref: '#/components/schemas/ServiceMapFleetHost'
        coverage:
          $ref: '#/components/schemas/ServiceMapFleetCoverage'
          description: 产生本页结果的候选扫描覆盖情况。
        partial:
          type: boolean
          description: 若本页存在读取失败的主机，或扫描被截断，则为 true。
        truncated:
          type: boolean
          description: >-
            若在找到 `limit` 个匹配前达到了 `scan_limit`，则为 true；此时 `next_cursor`
            仍可能找到更多结果。
        truncation_reasons:
          type: array
          description: 当 `truncated=true` 时，扫描被截断的机器可读原因。
          items:
            type: string
        next_cursor:
          type: string
          description: 用于获取下一页的不透明游标。若已无更多候选可扫描则不返回该字段。
        generated_at_ms:
          type: integer
          format: int64
          description: 生成本次响应的 Unix 时间戳（毫秒）。
    ServiceMapFleetHost:
      type: object
      description: 主机群浏览过滤条件匹配到的一台主机。
      required:
        - host_id
        - agent_version
        - edge_cluster
        - servicemap
      properties:
        host_id:
          type: string
          description: 稳定的服务拓扑主机标识符。
        agent_version:
          type: string
          description: 该主机上报的 Agent 版本。
        edge_cluster:
          type: string
          description: 该主机所属的边缘集群名称。
        servicemap:
          $ref: '#/components/schemas/ServiceMapFleetHostCapability'
          description: 该主机的服务拓扑能力及当前采集状态。
    ServiceMapFleetCoverage:
      type: object
      description: 产生本页结果的候选扫描覆盖情况。
      required:
        - scanned
        - matched
        - returned
        - failed
        - states
      properties:
        scanned:
          type: integer
          description: 本次请求实际检查的去重候选主机数。
        matched:
          type: integer
          description: 扫描主机中通过全部筛选条件的数量。
        returned:
          type: integer
          description: 本页实际返回的匹配主机数（`<= limit`）。
        failed:
          type: integer
          description: 状态读取失败的候选主机数量。
        states:
          type: object
          description: 按状态值统计的返回项数量；固定包含全部七个状态 key，未出现的值填 0。仅反映本页结果，不代表账户全量分布。
          additionalProperties:
            type: integer
    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
    ServiceMapFleetHostCapability:
      type: object
      description: 主机群列表中某台主机的服务拓扑能力及当前采集状态，由清单数据与实时状态联合而成。
      required:
        - enabled
        - status
        - snapshot_ready
        - authoritative
        - graph_available
        - node_count
        - edge_count
      properties:
        enabled:
          type: boolean
          description: 该主机是否已启用服务拓扑采集。
        status:
          type: string
          enum:
            - active
            - degraded
            - stale
            - initializing
            - disabled
            - unsupported
            - no_data
          description: |-
            总体的服务拓扑采集状态。

            | 值 | 含义 |
            |---|---|
            | `active` | 采集正常：有新鲜快照且无降级。 |
            | `degraded` | 采集在进行但质量受损：健康上报晚于快照、快照被截断/降级，或采集报错。 |
            | `stale` | 有快照但已过期（超过 2× 上报间隔未更新）。 |
            | `initializing` | Agent 已上报采集能力，但首个快照尚未就绪。 |
            | `disabled` | 该主机的拓扑采集被禁用。 |
            | `unsupported` | Agent 或内核不支持该采集。 |
            | `no_data` | 未收到任何快照或健康数据。 |
        capability_status:
          type: string
          description: >-
            Agent 自报的能力状态，例如
            `running`、`disabled`、`starting`、`failed`、`unsupported`。
        capture_mode:
          type: string
          description: 采集模式，例如 `ebpf` 或 `polling`。
        report_interval_ms:
          type: integer
          format: int64
          description: 配置的上报间隔（毫秒）。
        snapshot_ready:
          type: boolean
          description: Agent 是否已产出过至少一次完整快照。
        authoritative:
          type: boolean
          description: 该主机是否存在权威的当前拓扑。
        graph_available:
          type: boolean
          description: 当前是否可以获取该主机的拓扑数据。
        freshness_status:
          type: string
          enum:
            - fresh
            - stale
            - unknown
          description: >-
            该主机拓扑数据的新鲜度分类。`fresh` = 最近一次快照在 2× 上报间隔内收到；`stale` = 超过 2×
            上报间隔未收到新快照；`unknown` = 从未收到拓扑快照，无法判定新鲜度。
        max_age_ms:
          type: integer
          format: int64
          description: 该主机拓扑数据相对本次响应生成时间的年龄（毫秒）。
        observed_at_ms:
          type: integer
          format: int64
          description: 该主机拓扑被 Agent 观测到的 Unix 时间戳（毫秒）。
        received_at_ms:
          type: integer
          format: int64
          description: 服务端收到该主机当前拓扑生成数据的 Unix 时间戳（毫秒）。
        node_count:
          type: integer
          description: 该主机当前拓扑中的节点数量。
        edge_count:
          type: integer
          description: 该主机当前拓扑中的边数量。
        reason_codes:
          type: array
          description: 解释当前状态的机器可读原因码。
          items:
            type: string
        error_code:
          type: string
          description: 当无法读取该主机实时状态时设为 `status_unavailable`；此时其余字段回退为基于清单数据推导的默认值。
    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
        时都必须携带。它等同于所属账户的身份凭证，请妥善保管。

````