> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8c05c8a2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 查询图表序列数据

> 根据已配置的序列参数获取时间序列数据



## OpenAPI

````yaml /zh/_specs/hyperdx-openapi.json post /api/v2/charts/series
openapi: 3.0.0
info:
  description: 用于管理 HyperDX 告警和仪表盘的 API
  title: HyperDX External API
  version: 2.0.0
servers:
  - description: 生产环境 API 服务器
    url: https://api.hyperdx.io
  - description: 当前服务器
    url: /
security:
  - BearerAuth: []
tags:
  - description: 用于管理仪表盘及其可视化内容的端点
    name: Dashboards
  - description: 用于管理监控告警的端点
    name: Alerts
paths:
  /api/v2/charts/series:
    post:
      tags:
        - Charts
      summary: 查询图表序列数据
      description: 根据已配置的序列参数获取时间序列数据
      operationId: queryChartSeries
      requestBody:
        content:
          application/json:
            examples:
              basicTimeSeries:
                summary: 基本时间序列查询
                value:
                  endTime: 1647100800000
                  granularity: 1h
                  series:
                    - aggFn: count
                      groupBy: []
                      sourceId: 65f5e4a3b9e77c001a123456
                      where: SeverityText:error
                  startTime: 1647014400000
              metricSeries:
                summary: 指标数据序列
                value:
                  endTime: 1647100800000
                  granularity: 5m
                  series:
                    - aggFn: avg
                      groupBy: []
                      metricDataType: gauge
                      metricName: http_requests_total
                      sourceId: 65f5e4a3b9e77c001a789012
                      where: service:api
                  startTime: 1647014400000
              multiSeriesWithGroupBy:
                summary: 使用 group by 的多个序列
                value:
                  endTime: 1647100800000
                  granularity: 15m
                  series:
                    - aggFn: count
                      groupBy:
                        - service
                      sourceId: 65f5e4a3b9e77c001a123456
                      where: SeverityText:error
                    - aggFn: avg
                      field: duration
                      groupBy:
                        - service
                      sourceId: 65f5e4a3b9e77c001a123456
                      where: SeverityText:error
                  startTime: 1647014400000
              multiSourceSeries:
                summary: 来自多个数据源的序列
                value:
                  endTime: 1647100800000
                  granularity: 5m
                  series:
                    - aggFn: count
                      groupBy: []
                      sourceId: 65f5e4a3b9e77c001a123456
                      where: SeverityText:error
                    - aggFn: avg
                      groupBy: []
                      metricDataType: gauge
                      metricName: http_requests_total
                      sourceId: 65f5e4a3b9e77c001a789012
                      where: service:api
                  startTime: 1647014400000
            schema:
              $ref: '#/components/schemas/SeriesQueryRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                groupedTimeSeriesData:
                  summary: 分组后的时间序列数据
                  value:
                    data:
                      - group:
                          - api
                        series_0.data: 15
                        ts_bucket: 1647014400000
                      - group:
                          - frontend
                        series_0.data: 8
                        ts_bucket: 1647014400000
                      - group:
                          - api
                        series_0.data: 22
                        ts_bucket: 1647018000000
                timeSeriesData:
                  summary: 时间序列数据点
                  value:
                    data:
                      - series_0.data: 42
                        ts_bucket: 1647014400000
                      - series_0.data: 37
                        ts_bucket: 1647018000000
                      - series_0.data: 53
                        ts_bucket: 1647021600000
              schema:
                $ref: '#/components/schemas/SeriesResponse'
          description: 已成功获取时间序列数据
        '400':
          content:
            application/json:
              examples:
                invalidParams:
                  value:
                    error: All series must have the same groupBy fields
                invalidTimestamp:
                  value:
                    error: Timestamp must be in milliseconds
              schema:
                properties:
                  error:
                    type: string
                type: object
          description: 请求参数无效
        '403':
          content:
            application/json:
              example:
                error: Team context missing
              schema:
                properties:
                  error:
                    type: string
                type: object
          description: 未授权
        '404':
          content:
            application/json:
              example:
                error: Source not found
              schema:
                properties:
                  error:
                    type: string
                type: object
          description: 未找到数据源
        '500':
          content:
            application/json:
              example:
                error: Internal server error
              schema:
                properties:
                  error:
                    type: string
                type: object
          description: 服务器错误
components:
  schemas:
    SeriesQueryRequest:
      properties:
        endTime:
          description: 结束时间戳（毫秒）
          example: 1647100800000
          type: number
        granularity:
          description: 聚合的时间桶大小
          enum:
            - 30s
            - 1m
            - 5m
            - 10m
            - 15m
            - 30m
            - 1h
            - 2h
            - 6h
            - 12h
            - 1d
            - 2d
            - 7d
            - 30d
            - auto
          example: 1h
          type: string
        series:
          description: 序列配置数组
          items:
            $ref: '#/components/schemas/ChartSeries'
          maxItems: 5
          minItems: 1
          type: array
        seriesReturnType:
          description: 返回数据的格式
          enum:
            - ratio
            - column
          example: column
          type: string
        startTime:
          description: 起始时间戳（毫秒）
          example: 1647014400000
          type: number
      required:
        - series
        - startTime
        - endTime
      type: object
    SeriesResponse:
      properties:
        data:
          items:
            $ref: '#/components/schemas/SeriesDataPoint'
          type: array
      type: object
    ChartSeries:
      properties:
        aggFn:
          description: 对数据使用的聚合函数
          enum:
            - avg
            - count
            - count_distinct
            - last_value
            - max
            - min
            - quantile
            - sum
          example: count
          type: string
        dataSource:
          enum:
            - events
            - metrics
          example: events
          type: string
        field:
          description: 要聚合的字段
          example: duration
          type: string
        groupBy:
          description: 用于对结果分组的字段
          example:
            - service
            - host
          items:
            type: string
          type: array
        metricDataType:
          description: 指标数据类型
          enum:
            - sum
            - gauge
            - histogram
          example: gauge
          type: string
        metricName:
          description: 指标名称（用于指标数据源）
          example: http_requests_total
          type: string
        sourceId:
          description: 此序列的数据源 ID
          example: 65f5e4a3b9e77c001a123456
          type: string
        type:
          enum:
            - time
            - table
            - number
            - histogram
            - search
            - markdown
          example: time
          type: string
        where:
          description: 采用 Lucene 查询语法的过滤条件
          example: level:error
          type: string
        whereLanguage:
          description: WHERE 子句中使用的查询语言
          enum:
            - lucene
            - sql
          example: lucene
          type: string
      required:
        - sourceId
        - aggFn
        - where
        - groupBy
      type: object
    SeriesDataPoint:
      properties:
        group:
          description: 如果指定了 groupBy，则为分组后的值
          example:
            - api
            - prod-host-1
          items:
            type: string
          type: array
        series_0.data:
          description: 第一个序列的值
          example: 42
          type: number
        series_1.data:
          description: 第二个序列的值
          example: 18
          type: number
        ts_bucket:
          description: 数据点的时间戳（桶起始时间）
          example: 1647014400000
          type: number
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: API Key
      scheme: bearer
      type: http

````