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

# 获取采集状态

> 返回一台或多台主机的服务拓扑采集状态，或一份有界的主机群抽样状态。

## 限制说明

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

## 使用说明

* 服务拓扑是可选子系统：未配置 `redis.servicemap` 的部署会返回 `ServiceUnavailable`。
* 每次调用只能使用一种选择方式：显式的 `host_id`/`host_ids`，或 `fleet=true`；两者同时传入会被拒绝。
* 与 `POST /monit/servicemap/topology`、`POST /monit/servicemap/summary` 不同，单个主机解析失败不会导致整个请求失败，而是通过 `items[].error_code` 逐项披露。
* `limit`（默认 100，最大 200）限定了显式主机的接受数量，在 `fleet` 模式下则限定了抽样的候选主机数量。


## OpenAPI

````yaml /api-reference/monitors.openapi.zh.json post /monit/servicemap/status
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/status:
    post:
      tags:
        - Monitors/服务拓扑
      summary: 获取采集状态
      description: 返回一台或多台主机的服务拓扑采集状态，或一份有界的主机群抽样状态。
      operationId: monit-servicemap-read-status
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceMapStatusRequest'
            example:
              host_id: host_0123456789abcdef0123456789abcdef
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/ServiceMapStatusResponse'
              example:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                data:
                  fleet: false
                  items:
                    - host_id: host_0123456789abcdef0123456789abcdef
                      network_scope_id: ns_0123456789abcdef0123456789abcdef
                      status: active
                      authoritative: true
                      graph_available: true
                      capability:
                        present: true
                        enabled: true
                        status: running
                        host_id: host_0123456789abcdef0123456789abcdef
                        capture_mode: ebpf
                        report_interval_ms: 60000
                        snapshot_ready: true
                      freshness:
                        status: fresh
                        newest_received_at_ms: 1784635557272
                        oldest_received_at_ms: 1784635557272
                        max_age_ms: 1200
                      coverage:
                        degraded: false
                        truncated: false
                        network_inventory_status: complete
                        kubernetes_enrichment_status: unavailable
                      observed_at_ms: 1784635556072
                      received_at_ms: 1784635557272
                      report_interval_ms: 60000
                      node_count: 12
                      edge_count: 8
                  coverage:
                    requested: 1
                    succeeded: 1
                    failed: 0
                    truncated: false
                    states:
                      active: 1
                      degraded: 0
                      stale: 0
                      initializing: 0
                      disabled: 0
                      unsupported: 0
                      no_data: 0
                  partial: false
                  generated_at_ms: 1784635558472
        '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:
    ServiceMapStatusRequest:
      type: object
      description: 选择要查询采集状态的主机：可指定明确的主机 ID，或使用有界的主机群抽样。
      properties:
        host_id:
          type: string
          description: 要查询的单个主机 ID。可与 `host_ids` 组合以查询多台；与 `fleet=true` 互斥。
          pattern: ^host_[a-z0-9_-]+$
          maxLength: 128
        host_ids:
          type: array
          description: 本次调用要查询的多个主机 ID，与 `host_id` 合计最多 200 个。与 `fleet=true` 互斥。
          items:
            type: string
        fleet:
          type: boolean
          description: >-
            为 `true` 时忽略 `host_id`/`host_ids`，改为对账户内主机抽样，最多返回 `limit` 台候选主机。默认
            `false`。
          default: false
        limit:
          type: integer
          description: '`fleet` 模式下抽样的候选主机数量，其他模式下忽略该字段。默认 100，范围 1～200。'
          default: 100
          minimum: 1
          maximum: 200
    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
    ServiceMapStatusResponse:
      type: object
      description: 所请求主机的服务拓扑采集状态。
      required:
        - fleet
        - items
        - coverage
        - partial
        - generated_at_ms
      properties:
        fleet:
          type: boolean
          description: 回显本次响应是否来自主机群抽样而非显式主机 ID。
        items:
          type: array
          description: 各主机的状态，顺序与主机解析顺序一致。
          items:
            $ref: '#/components/schemas/ServiceMapStatusItem'
        coverage:
          $ref: '#/components/schemas/ServiceMapStatusBatchCoverage'
          description: 主机覆盖情况的汇总统计。
        partial:
          type: boolean
          description: 若存在主机读取失败，或主机群抽样被截断，则为 true。
        generated_at_ms:
          type: integer
          format: int64
          description: 生成本次响应的 Unix 时间戳（毫秒）。
    ServiceMapStatusItem:
      type: object
      description: 单台主机的服务拓扑采集状态。
      required:
        - host_id
        - status
        - authoritative
        - graph_available
        - capability
        - freshness
        - coverage
        - node_count
        - edge_count
      properties:
        host_id:
          type: string
          description: 该状态所属的主机 ID。
        network_scope_id:
          type: string
          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` | 未收到任何快照或健康数据。 |
        authoritative:
          type: boolean
          description: 该主机是否存在权威的当前拓扑。
        graph_available:
          type: boolean
          description: 当前是否可以获取该主机的拓扑数据。
        capability:
          $ref: '#/components/schemas/ServiceMapCapability'
          description: 该主机自报的服务拓扑能力信息。
        freshness:
          $ref: '#/components/schemas/ServiceMapFreshness'
          description: 该主机拓扑数据的新鲜程度。
        coverage:
          $ref: '#/components/schemas/ServiceMapHostCoverage'
          description: 该主机拓扑数据的覆盖与增强状态。
        observed_at_ms:
          type: integer
          format: int64
          description: 该主机拓扑被 Agent 观测到的 Unix 时间戳（毫秒）。
        received_at_ms:
          type: integer
          format: int64
          description: 服务端收到该主机当前拓扑生成数据的 Unix 时间戳（毫秒）。
        latest_health_at_ms:
          type: integer
          format: int64
          description: 最近一次非权威健康信号的 Unix 时间戳（毫秒），仅当其晚于当前拓扑时出现。
        report_interval_ms:
          type: integer
          format: int64
          description: 配置的上报间隔（毫秒）。
        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`；此时其余字段回退为基于清单数据推导的默认值。
    ServiceMapStatusBatchCoverage:
      type: object
      description: 本次请求中主机覆盖情况的汇总统计。
      required:
        - requested
        - succeeded
        - failed
        - truncated
        - states
      properties:
        requested:
          type: integer
          description: 请求涉及的主机数量（显式的 `host_id`/`host_ids`，或 fleet 模式下实际扫描的抽样数量）。
        succeeded:
          type: integer
          description: 状态读取成功的主机数量。
        failed:
          type: integer
          description: 状态读取失败的主机数量。
        truncated:
          type: boolean
          description: '`fleet` 模式下若候选主机数超过 `limit` 上限则为 true。'
        states:
          type: object
          description: >-
            按状态值统计的数量；固定包含全部七个
            key（`active`、`degraded`、`stale`、`initializing`、`disabled`、`unsupported`、`no_data`），未出现的值填
            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
    ServiceMapCapability:
      type: object
      description: 该主机在监控对象清单中自报的服务拓扑能力信息。
      required:
        - present
        - enabled
        - snapshot_ready
      properties:
        present:
          type: boolean
          description: 该主机是否存在带有服务拓扑能力元数据的清单记录。
        enabled:
          type: boolean
          description: 该主机是否已启用服务拓扑采集。
        status:
          type: string
          description: >-
            Agent 自报的能力状态，例如
            `running`、`disabled`、`starting`、`failed`、`unsupported`。
        host_id:
          type: string
          description: 该能力信息所属的主机 ID。
        capture_mode:
          type: string
          description: 采集模式，例如 `ebpf` 或 `polling`。
        report_interval_ms:
          type: integer
          format: int64
          description: 配置的上报间隔（毫秒）。
        snapshot_ready:
          type: boolean
          description: Agent 是否已产出过至少一次完整快照。
        reason_codes:
          type: array
          description: 解释当前能力状态的机器可读原因码。
          items:
            type: string
    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: 覆盖范围内最旧拓扑数据相对当前时间的年龄（毫秒）。
    ServiceMapHostCoverage:
      type: object
      description: 单台主机拓扑数据的覆盖与增强状态。
      required:
        - degraded
        - truncated
      properties:
        degraded:
          type: boolean
          description: 该主机拓扑在采集时是否处于降级状态。
        truncated:
          type: boolean
          description: 该主机拓扑在采集时是否被截断。
        network_inventory_status:
          type: string
          description: 该主机的网络清单增强状态，如 `complete`、`partial`、`unavailable`，由 Agent 自报。
        kubernetes_enrichment_status:
          type: string
          description: 该主机的 Kubernetes 增强状态，由 Agent 自报。
        reason_codes:
          type: array
          description: 解释当前覆盖状态的机器可读原因码。
          items:
            type: string
    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
        时都必须携带。它等同于所属账户的身份凭证，请妥善保管。

````