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

# 查询 Prometheus 标签值列表

> 通过监控代理从 Prometheus 兼容数据源读取标签值列表。

## 限制说明

| 项目        | 说明                                    |
| --------- | ------------------------------------- |
| 速率限制      | 每个账户 **1,000 次/分钟**；**50 次/秒**        |
| 权限要求      | 任意有效的 `app_key`（只读，不受特定权限分类限制）        |
| Edge 版本要求 | 受支持的部署要求 **monit-edge v0.35.0 或更高版本** |

## 使用说明

* 通过 `X-DSID` 请求头指定目标数据源，必须是当前账户下 Prometheus 兼容类型的数据源；可用 `/monit/datasource/list` 获取 ID。
* 200 响应体是数据源原生的 Prometheus HTTP API 结构，**不是**统一的 `{ request_id, data }` envelope。未到达数据源前发生的失败以 `text/plain` 返回，并携带对应的 4xx/5xx 状态码。
* 省略 `X-DSID` 时会回退到平台自有的 Prometheus 代理；需要查询指定数据源时必须携带该请求头。


## OpenAPI

````yaml /api-reference/monitors.openapi.zh.json get /monit/prometheus/api/v1/label/{label_name}/values
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: Flashduty AI SRE 使用的诊断与查询接口——数据源即席查询、日志/指标诊断,以及监控对象侧的工具调用。
  - name: Monitors/通用工具
    description: 监控服务开通及数据预览工具。
paths:
  /monit/prometheus/api/v1/label/{label_name}/values:
    get:
      tags:
        - Monitors/告警数据源
      summary: 查询 Prometheus 标签值列表
      description: 通过监控代理从 Prometheus 兼容数据源读取标签值列表。
      operationId: monit-prometheus-read-label-values
      parameters:
        - name: label_name
          in: path
          required: true
          schema:
            type: string
          description: 要枚举取值的标签名，例如 `job`。
        - name: X-DSID
          in: header
          required: true
          schema:
            type: string
          description: 要查询的数据源 ID，必须是当前账户下 Prometheus 兼容类型的数据源。
      responses:
        '200':
          description: 数据源返回的原生 Prometheus 标签值响应。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrometheusLabelValuesResponse'
              example:
                status: success
                data:
                  - api
                  - db
                  - worker
        '400':
          description: '`X-DSID` 请求头缺失或非法、数据源不存在，或该数据源不是 Prometheus 类型。以 `text/plain` 返回。'
          content:
            text/plain:
              schema:
                type: string
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          description: 数据源查询或代理请求失败。以 `text/plain` 返回。
          content:
            text/plain:
              schema:
                type: string
        '503':
          description: 数据源所在集群中没有支持数据源资源代理的 monit-edge。以 `text/plain` 返回，请升级 monit-edge。
          content:
            text/plain:
              schema:
                type: string
components:
  schemas:
    PrometheusLabelValuesResponse:
      type: object
      description: 所查询数据源返回的原生 Prometheus HTTP API 响应。本接口不会把结果包装进 Flashduty 统一响应 envelope。
      required:
        - status
      properties:
        status:
          type: string
          enum:
            - success
            - error
          description: >-
            Prometheus 结果状态。`success` 携带 `data`，`error` 携带 `errorType` 与
            `error`。
        data:
          type: array
          items:
            type: string
            description: 一个标签值。
          description: 标签值列表，`status` 为 `success` 时出现。
        errorType:
          type: string
          description: Prometheus 错误类别，`status` 为 `error` 时出现。
        error:
          type: string
          description: Prometheus 错误信息，`status` 为 `error` 时出现。
    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.
        reason:
          description: 可选的机器可读拒绝原因，包含数据源工具错误；结合 HTTP 状态及 code 判断。
          type: string
          x-flashduty-preserve-absence: true
      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:
    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.
  securitySchemes:
    AppKeyAuth:
      type: apiKey
      in: query
      name: app_key
      description: >-
        在 Flashduty 控制台 账户 → APP Key 中签发的 app_key。调用任何公开 API
        时都必须携带。它等同于所属账户的身份凭证，请妥善保管。

````