> ## Documentation Index
> Fetch the complete documentation index at: https://docs.basaltic.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Run a range metric query

> Returns aggregate points per series between start and end. The window is limited to 31 days and 11000 buckets per series; step defaults to 60s. Requires telemetry:ReadMetrics.

<Info>
  Requires the IAM action **`telemetry:ReadMetrics`**. See [TELEMETRY permissions](/telemetry#permissions) for the full list, what each one covers, and an example policy.
</Info>


## OpenAPI

````yaml /api-reference/specs/telemetry.yaml get /v1/metrics/query-range
openapi: 3.0.3
info:
  title: Basaltic Telemetry API
  version: 1.0.0
  description: >
    Regional telemetry API — log groups and log ingest/search,

    metrics (remote_write ingestion and native structured JSON queries), span
    ingest, and trace search/detail + per-account

    trace settings.


    Log-group request references accept UUIDs, CRNs or exact account-scoped

    names, classified by syntax without lookup fallback. CRNs must match the

    authenticated account handle and serving region. HTTP and gRPC OTLP logs

    use basaltic.log_group, falling back to service.name, with the same

    reference contract. Trace/span identifiers, metric labels and region

    search dimensions are protocol values, independent of resource resolution.
  contact:
    name: Basaltic Support
    email: ping@basaltic.sh
  license:
    name: Proprietary
    url: https://basaltic.sh/terms
servers:
  - url: https://telemetry.{region}.basaltic.sh
    description: Regional API endpoint (one per region)
    variables:
      region:
        default: sa-saopaulo-1
        description: Region code
security:
  - BearerAuth: []
paths:
  /v1/metrics/query-range:
    get:
      tags:
        - Telemetry
      summary: Run a range metric query
      description: >-
        Returns aggregate points per series between start and end. The window is
        limited to 31 days and 11000 buckets per series; step defaults to 60s.
        Requires telemetry:ReadMetrics.
      operationId: queryMetricsRange
      parameters:
        - name: metric
          in: query
          required: true
          schema:
            type: string
            example: http_requests_total
        - name: agg
          in: query
          required: false
          schema:
            type: string
            enum:
              - avg
              - sum
              - min
              - max
              - count
              - last
              - rate
              - increase
            example: avg
            default: avg
        - name: match[]
          in: query
          schema:
            type: array
            items:
              type: string
          style: form
          explode: true
        - name: by[]
          in: query
          schema:
            type: array
            items:
              type: string
          style: form
          explode: true
        - name: start
          in: query
          required: true
          schema:
            type: string
            example: '2026-01-15T09:00:00Z'
        - name: end
          in: query
          required: true
          schema:
            type: string
            example: '2026-01-15T10:00:00Z'
        - name: step
          in: query
          description: Bucket width duration (e.g. "15s", "1m")
          schema:
            type: string
            example: 15s
      responses:
        '200':
          description: Query result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MetricQueryResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    MetricQueryResponse:
      type: object
      required:
        - query_result
      properties:
        query_result:
          $ref: '#/components/schemas/MetricQueryResult'
    MetricQueryResult:
      type: object
      required:
        - metric
        - series
      properties:
        metric:
          type: string
          example: http_requests_total
        series:
          type: array
          items:
            $ref: '#/components/schemas/MetricQuerySeries'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - request_id
          properties:
            code:
              type: string
              description: Error code identifying the type of error
              example: INVALID_INPUT
            message:
              type: string
              description: Human-readable error message
              example: Invalid request parameters
            params:
              type: object
              additionalProperties: true
              description: >-
                Optional non-sensitive values for interpolation of localized
                errors, keyed by error code. Never present for server errors.
              example:
                instances: 2
                pools: 0
            request_id:
              type: string
              format: uuid
              description: Request ID for debugging
              example: 550e8400-e29b-41d4-a716-446655440000
    MetricQuerySeries:
      type: object
      required:
        - labels
        - points
      properties:
        labels:
          type: object
          additionalProperties:
            type: string
        points:
          type: array
          items:
            $ref: '#/components/schemas/MetricPoint'
    MetricPoint:
      type: object
      required:
        - timestamp
        - value
      properties:
        timestamp:
          type: number
          format: double
          description: Unix timestamp in seconds, including fractional seconds.
          example: 1768469400.5
        value:
          type: string
          description: Float value as text, including NaN and infinities.
          example: '12.5'
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: INVALID_INPUT
              message: Invalid request parameters
              request_id: 550e8400-e29b-41d4-a716-446655440000
    Unauthorized:
      description: Authentication required or token invalid
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: UNAUTHORIZED
              message: Authentication required
              request_id: 550e8400-e29b-41d4-a716-446655440000
    Forbidden:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: ACCESS_DENIED
              message: You don't have permission to perform this action
              request_id: 550e8400-e29b-41d4-a716-446655440000
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: INTERNAL_ERROR
              message: An internal error occurred
              request_id: 550e8400-e29b-41d4-a716-446655440000
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        An OAuth 2.0 bearer token, sent as `Authorization: Bearer <token>`.
        This is the recommended way to authenticate.

        Get one by exchanging a service account's access key pair at
        `POST /v1/oauth/token` with `grant_type=client_credentials`. It is the
        standard client-credentials grant, so any OAuth-aware library will
        obtain and refresh it for you.

        ```
        curl -s -u "$KEY_ID:$SECRET" -d grant_type=client_credentials \
          https://iam.basaltic.sh/v1/oauth/token
        ```

        Tokens last an hour by default. The same access key pair is separately
        your AWS SigV4 credential for the S3-compatible object endpoint, which
        speaks nothing else.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.