> ## Documentation Index
> Fetch the complete documentation index at: https://test-8ad8522e-feat-ai-sre.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 查询分值分布

> 按出现次数降序返回指定时间范围内某个分面字段的 Top N 值及其计数。

## 限制说明

| 项目   | 说明                            |
| ---- | ----------------------------- |
| 速率限制 | 每个账户 **300 次/分钟**；**100 次/秒** |
| 权限要求 | 无 —— 持有有效的 `app_key` 即可调用     |

## 使用说明

* 使用 `POST /rum/field/list`（传 `is_facet: true`）发现每个 scope 下可用的 `facet_key` 值。
* `scope` 必须是以下之一：`session`、`view`、`action`、`error`、`resource`、`long_task`、`vital`、`issue`、`sourcemap`。
* 传入 `dql` 可在统计前进一步过滤事件，DQL 语法遵循 RUM 查询语言。
* 传入 `sql` 可使用仅含 WHERE 子句（无 SELECT）的 SQL 风格过滤。
* 默认 limit 为 100，最大 100。
* 时间范围必填（`start_time` / `end_time` 为 Unix 毫秒时间戳），最大跨度 31 天。


## OpenAPI

````yaml /api-reference/rum.openapi.zh.json post /rum/facet/count
openapi: 3.1.0
info:
  description: >-
    Flashduty 事件管理平台的公开 HTTP API —— 覆盖故障、通知模板、协作空间、值班排班、监控、RUM、以及平台管理。每次调用都需在
    query 中携带 `app_key`，该 key 在 Flashduty 控制台 账户 → APP Key 中签发。所有响应使用统一结构：成功时为
    `{ request_id, data }`，失败时为 `{ request_id, error }`。
  title: Flashduty 开放 API
  version: 1.0.0
servers:
  - description: Flashduty Open API
    url: https://api.flashcat.cloud
security:
  - AppKeyAuth: []
tags:
  - description: 管理前端性能监控（RUM）应用。
    name: RUM/应用管理
  - description: 对 RUM 事件数据执行分析查询。
    name: RUM/RUM 数据查询
  - description: 查询和管理 RUM 异常追踪 Issue 及预设严重性规则。
    name: RUM/RUM 问题跟踪
  - description: 查询 RUM 自定义字段及其值分布，用于构建分析过滤条件。
    name: RUM/RUM 自定义字段
  - description: 管理和查询用于 Browser、Android、iOS 错误符号化的 RUM Sourcemap 文件。
    name: RUM/RUM Sourcemap
  - description: 查询 RUM 会话的回放元数据与录制分段。
    name: RUM/RUM 会话回放
  - description: 配置和查看决定 RUM 应用采集哪些错误的规则，并可查看其编辑历史。
    name: RUM/错误采集规则
  - description: 管理按应用配置的预设严重性规则，用于为匹配的前端错误指定严重级别，并管理其评估顺序与变更历史。
    name: RUM/Issue 预设严重性规则
  - description: 查询账户的 RUM 资源记录及当前用量。
    name: RUM/资源
paths:
  /rum/facet/count:
    post:
      tags:
        - RUM/RUM 自定义字段
      summary: 查询分值分布
      description: 按出现次数降序返回指定时间范围内某个分面字段的 Top N 值及其计数。
      operationId: rum-read-facet-count
      requestBody:
        content:
          application/json:
            example:
              end_time: 1712707200000
              facet_key: error.type
              limit: 10
              scope: error
              start_time: 1712620800000
            schema:
              $ref: '#/components/schemas/RumFacetCountRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              example:
                data:
                  items:
                    - count: 1523
                      facet_value: TypeError
                    - count: 342
                      facet_value: ReferenceError
                    - count: 89
                      facet_value: SyntaxError
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - properties:
                      data:
                        $ref: '#/components/schemas/RumFacetCountResponse'
                    type: object
          description: 成功
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    RumFacetCountRequest:
      description: 分面值分布统计的请求参数。
      properties:
        dql:
          description: 统计前应用的 RUM DQL 过滤表达式。
          type: string
        end_time:
          description: 时间范围结束，Unix 毫秒时间戳。最大跨度 31 天。
          example: 1712707200000
          format: int64
          type: integer
        facet_key:
          description: 要统计值分布的字段键；必须是该 `scope` 下已注册的字段，可用字段可通过 `POST /rum/field/list` 查询。
          type: string
        facet_value:
          description: 设置后，统计前会先过滤 `facet_key` 等于该值的事件。接受字符串、数字或布尔值。
        kind:
          description: >-
            符号类型，仅在 `scope` 为 `sourcemap` 时使用，且只对 `android`/`harmony`
            有意义：`mapping`（默认）选择 ProGuard/R8 mapping 或 ArkTS Sourcemap，`native`
            选择 native .so 符号。
          enum:
            - mapping
            - native
          type: string
        limit:
          default: 100
          description: 返回的最大 Top N 值数量。默认 100，最大 100。
          maximum: 100
          type: integer
        scope:
          description: |-
            要查询的 RUM 数据 scope。取值：

            | 值 | 含义 |
            |---|---|
            | `session` | 用户会话 |
            | `view` | 页面/视图 |
            | `action` | 用户操作 |
            | `error` | 错误事件 |
            | `resource` | 资源加载 |
            | `long_task` | 长任务 |
            | `vital` | 性能指标（Web Vitals 等） |
            | `issue` | 异常聚合 Issue |
            | `sourcemap` | Sourcemap 符号文件 |
          enum:
            - session
            - view
            - action
            - error
            - resource
            - long_task
            - vital
            - issue
            - sourcemap
          type: string
        sql:
          description: 仅含 WHERE 子句（无 SELECT）的 SQL 附加过滤条件。
          type: string
        start_time:
          description: 时间范围起始，Unix 毫秒时间戳。
          example: 1712620800000
          format: int64
          type: integer
        type:
          description: >-
            符号文件存储的平台，仅在 `scope` 为 `sourcemap` 时使用。省略时默认为
            `browser`；`web`、`javascript` 是 `browser` 的别名。


            | 值 | 查询的存储 |

            |---|---|

            | `browser` / `web` / `javascript` | JS Sourcemap（不含鸿蒙 ArkTS 与 React
            Native 行） |

            | `android` | Android ProGuard/R8 mapping；`kind=native` 时为 Android
            NDK .so 符号 |

            | `ios` | iOS dSYM 符号 |

            | `miniprogram` | 微信小程序 Sourcemap |

            | `harmony` | 鸿蒙 ArkTS Sourcemap；`kind=native` 时为鸿蒙 .so 符号 |

            | `flutter` | Flutter Dart AOT 符号 |

            | `electron` | Electron Breakpad 符号 |

            | `react-native` | React Native JS Sourcemap |
          enum:
            - browser
            - web
            - javascript
            - android
            - ios
            - miniprogram
            - harmony
            - flutter
            - electron
            - react-native
          type: string
      required:
        - scope
        - facet_key
        - start_time
        - end_time
      type: object
    SuccessEnvelope:
      description: >-
        成功响应结构。2xx 响应中 `request_id` 标识本次调用（同时出现在 `Flashcat-Request-Id`
        响应头中），`data` 为接口业务 payload。失败响应使用不同结构，参见 `ErrorResponse`。
      properties:
        data:
          description: 每个接口自己的业务 payload，详见各接口的 200 响应 schema。
        request_id:
          description: 本次请求的唯一 ID，也会在 Flashcat-Request-Id 响应头中返回。反馈问题时请一并附上。
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          type: string
      required:
        - request_id
        - data
      type: object
    RumFacetCountResponse:
      description: 按计数降序排列的 Top N 分面值。
      properties:
        items:
          description: 分面值及其出现次数的列表，按计数降序排列，最多返回 `limit`（默认上限 100）条。
          items:
            $ref: '#/components/schemas/FacetCountItem'
          type: array
      required:
        - items
      type: object
    FacetCountItem:
      description: 一个分面值及其出现次数。
      properties:
        count:
          description: 该时间范围内具有此分面值的事件数量。
          example: 1523
          format: int64
          type: integer
        facet_value:
          description: 分面值，类型与字段的 `value_type` 一致。
      required:
        - facet_value
        - count
      type: object
    ErrorResponse:
      description: 错误响应结构。`error` 必填，`data` 不存在。
      properties:
        error:
          $ref: '#/components/schemas/DutyError'
        request_id:
          description: 本次请求的唯一追踪 ID（trace ID），反馈问题时请提供该值以便检索日志。
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          type: string
      required:
        - request_id
        - error
      type: object
    DutyError:
      description: 响应结构中的错误 payload，仅在非 2xx 响应时出现。
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          description: 用户可读的错误描述，语言会跟随调用方的 Accept-Language。可能包含字段名、ID 等请求上下文。
          example: The specified parameter template_id is not valid.
          type: string
      required:
        - code
        - message
      type: object
    ErrorCode:
      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
      example: InvalidParameter
      type: string
      x-enumDescriptions:
        AccessDenied: 身份认证通过，但 RBAC 权限不足以执行该操作。
        BadRequest: 通用的 400 错误，通常是请求本身不合法。
        BalanceNotEnough: 账户余额不足，无法执行需要计费的操作。
        DangerousOperation: 危险操作，需要进行 MFA 验证。
        EntityTooLarge: 请求体超过允许的最大长度。
        InternalError: 服务端未预期错误。反馈问题请附上 `request_id`。
        InvalidContentType: 请求头 `Content-Type` 不是 `application/json`。
        InvalidParameter: 必填参数缺失或未通过校验。
        MethodNotAllowed: 当前路径不接受所使用的 HTTP 方法。
        NoLicense: 功能需要有效授权，但未找到可用的 license。
        OK: 保留值，正常错误响应不会返回。
        ReferenceExist: 该资源仍被其他实体引用，无法删除。
        RequestLocked: 因连续失败被临时锁定。
        RequestTooFrequently: 命中限流（全局、账户级或集成级）。
        RequestVerifyRequired: 操作需要二次验证码，但未提供。
        ResourceNotFound: 目标资源不存在。注意 HTTP 状态码是 400 而非 404（历史设计）。
        RouteNotFound: 请求的 URL 路径不是已知路由。
        ServiceUnavailable: 后端依赖不可用，请稍后重试。
        Unauthorized: '`app_key` 缺失、无效或已过期。'
        UndonedOrderExist: 账户存在未完成的订单，请稍后重试。
  responses:
    BadRequest:
      content:
        application/json:
          examples:
            missingParameter:
              value:
                error:
                  code: InvalidParameter
                  message: The specified parameter is not valid.
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: 请求非法 — 通常是参数缺失或格式不正确。
    Unauthorized:
      content:
        application/json:
          examples:
            missingAppKey:
              value:
                error:
                  code: Unauthorized
                  message: You are unauthorized.
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: app_key 缺失或无效。
    TooManyRequests:
      content:
        application/json:
          examples:
            rateLimited:
              value:
                error:
                  code: RequestTooFrequently
                  message: Request too frequently.
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: 命中限流。可能是全局 API 限流、账户级限流或集成级限流。限流按账户聚合。
    ServerError:
      content:
        application/json:
          examples:
            internal:
              value:
                error:
                  code: InternalError
                  message: >-
                    We encountered an internal error, and it has been reported.
                    Please try again later.
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: 服务端未预期错误。反馈问题时请携带 request_id。
  securitySchemes:
    AppKeyAuth:
      description: >-
        在 Flashduty 控制台 账户 → APP Key 中签发的 app_key。调用任何公开 API
        时都必须携带。它等同于所属账户的身份凭证，请妥善保管。
      in: query
      name: app_key
      type: apiKey

````