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

# Query a metrics timeseries

For selectors, fields, and series limits, see [Querying metrics](https://docs.appsignal.com/api/v2/metrics.md#query-a-timeseries).

```yaml POST /api/v2/metrics/timeseries theme={null}
openapi: 3.1.0
info:
  title: AppSignal V2 API
  description: >-
    REST API for metrics, traces, logs, Kubernetes monitoring, and deployment
    tracking.
  license:
    name: ''
  version: 0.1.0
paths:
  /api/v2/metrics/timeseries:
    post:
      tags:
        - Metrics
      summary: Query a metrics timeseries
      operationId: timeseries
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TimeseriesQuery'
            example:
              site_id: abc123
              from: '2024-01-01T00:00:00Z'
              to: '2024-01-01T01:00:00Z'
              resolution: MINUTELY
              select:
                - name: cpu
                  field: GAUGE
                  tags:
                    hostname: server-1
                    state: user
        required: true
      responses:
        '200':
          description: The matching series.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Timeseries'
        '400':
          description: Malformed request, or input the server cannot process.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestResponse'
        '401':
          description: Missing or invalid authentication token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Route or resource not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: External query concurrency limit exceeded; retry shortly.
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TooManyRequestsResponse'
        '500':
          description: Unhandled server-side failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearer_auth: []
        - token_query: []
components:
  schemas:
    Aggregation:
      type: string
      description: >-
        The aggregation function applied when combining multiple values within a
        time bucket.


        Serialized as uppercase strings (e.g. `"SUM"`, `"AVERAGE"`). When no
        aggregation is

        explicitly set on a selector, a default is chosen based on the [`Field`]
        type.
      enum:
        - SUM
        - AVERAGE
        - MIN
        - MAX
        - FIRST
        - LAST
    BadRequestResponse:
      type: object
      description: >-
        Standard body for HTTP 400 Bad Request responses. Branch on the stable
        `error` slug, display `message` as-is, and read per-error structured
        data from `details`.
      required:
        - error
        - message
      properties:
        error:
          type: string
          description: Stable, machine-readable slug identifying the specific error case.
        message:
          type: string
          description: Human-readable message. Safe to log or display to end users.
        details:
          description: >-
            Per-error structured payload. Shape varies by
            [`error`](Self::error).
    ErrorResponse:
      type: object
      description: Error body returned for 401, 404 and 500 responses.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message.
    Field:
      type: string
      description: >-
        The specific measurement within a metric to retrieve.


        A gauge metric only has a [`Gauge`](Self::Gauge) field; a counter metric
        only has a

        [`Counter`](Self::Counter) field; a measurement metric has statistical
        fields such as

        [`Mean`](Self::Mean), [`Count`](Self::Count), [`Min`](Self::Min),
        [`Max`](Self::Max)

        and percentiles.


        Serialized as uppercase strings (e.g. `"GAUGE"`, `"P95"`).
      enum:
        - GAUGE
        - COUNTER
        - MEAN
        - COUNT
        - MIN
        - MAX
        - P99
        - P95
        - P90
        - P80
        - P75
        - P70
        - P60
        - P50
        - P40
        - P30
        - P20
        - P10
    FillMode:
      type: string
      description: >-
        How missing data points (empty time buckets) are filled when assembling
        a series.
      enum:
        - ZERO
        - PREVIOUS
        - NONE
    Point:
      type: object
      description: >-
        A single data point in a timeseries, representing a value at a specific
        moment in time.
      required:
        - timestamp
        - value
      properties:
        timestamp:
          type: string
          format: date-time
          description: >-
            The moment in time this data point represents, aligned to the
            query's timeframe resolution.
        value:
          type: number
          format: double
          description: The numeric metric value at this timestamp.
    Resolution:
      type: string
      description: Time resolution that metrics can be returned in
      enum:
        - HOURLY
        - MINUTELY
        - DAILY
    Serie:
      type: object
      description: >-
        A single timeseries: a named sequence of points that share the same tags
        and field.
      required:
        - id
        - name
        - tags
        - max
        - min
        - field
        - data
      properties:
        id:
          type: string
          description: >-
            Unique identifier for this series, composed of the metric name,
            sorted tags and field

            (e.g. `"cpu_usage{hostname=frontend1};GAUGE"`).
        name:
          type: string
          description: The metric name (e.g. `"cpu_usage"`, `"transaction_duration"`).
        tags:
          type: object
          description: >-
            Tag key-value pairs that distinguish this series from others with
            the same name

            (e.g. `{"hostname": "frontend1"}`).
          additionalProperties:
            type: string
          propertyNames:
            type: string
        max:
          type: number
          format: double
          description: The maximum value across all data points in this series.
        min:
          type: number
          format: double
          description: The minimum value across all data points in this series.
        field:
          $ref: '#/components/schemas/Field'
          description: >-
            The type of measurement this series represents (e.g. gauge, mean, a
            percentile).
        data:
          type: array
          items:
            $ref: '#/components/schemas/Point'
          description: >-
            The ordered sequence of data points, aligned to the query's
            timeframe resolution.
    Timeseries:
      type: object
      description: >-
        A collection of series over a time range, aligned to the given
        resolution.
      required:
        - resolution
        - from
        - to
        - series
      properties:
        resolution:
          $ref: '#/components/schemas/Resolution'
          description: >-
            The time interval between consecutive data points (e.g. one minute,
            one hour).
        from:
          type: string
          format: date-time
          description: Start of the queried time range (inclusive).
        to:
          type: string
          format: date-time
          description: End of the queried time range (inclusive).
        series:
          type: array
          items:
            $ref: '#/components/schemas/Serie'
          description: The individual timeseries that matched the query.
    TimeseriesQuery:
      type: object
      description: Query for fetching timeseries metric data, used to populate graphs.
      required:
        - from
        - to
        - site_id
        - select
      properties:
        from:
          type: string
          format: date-time
          description: Start of the time range to query (inclusive).
        to:
          type: string
          format: date-time
          description: End of the time range to query (inclusive).
        resolution:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Resolution'
              description: >-
                The desired interval between data points. When `None`, a
                resolution is

                automatically chosen based on the time range.
        site_id:
          type: string
          description: The site to fetch metrics for.
        select:
          type: array
          items:
            $ref: '#/components/schemas/TimeseriesSelector'
          description: Selectors that define which metrics and fields to fetch.
        limit:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Maximum number of unique series to return. When `None`, no limit is
            applied.
    TimeseriesSelector:
      type: object
      description: >-
        Selects a specific metric, field and tag combination to include in a
        timeseries response.
      required:
        - name
        - tags
        - field
      properties:
        name:
          type: string
          description: >-
            The metric name to query (e.g. `"cpu_usage"`,
            `"transaction_duration"`).
        tags:
          type: object
          description: 'Tag key-value pairs to filter on (e.g. `{"hostname": "frontend1"}`).'
          additionalProperties:
            type: string
          propertyNames:
            type: string
        field:
          $ref: '#/components/schemas/Field'
          description: >-
            The specific measurement field to retrieve (e.g. `GAUGE`, `MEAN`,
            `P95`).
        aggregation:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Aggregation'
              description: >-
                The aggregation function to apply when combining values within a
                time bucket.

                When omitted, a default is chosen based on the field (e.g. `SUM`
                for counters,

                `AVERAGE` for percentiles).
        draw_null_as_zero:
          type: boolean
          description: >-
            Legacy fill policy: `true` fills missing data points with `0.0`,
            `false` carries

            the previous value forward. Superseded by `fill`.
          default: true
        fill:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/FillMode'
              description: >-
                Preferred fill policy; takes precedence over `draw_null_as_zero`
                when set.
    TooManyRequestsResponse:
      type: object
      description: Error body returned for 429 responses.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message.
        suggestion:
          type:
            - string
            - 'null'
          description: >-
            A cheaper way to write the request's filter. Only the trace list

            endpoints set it, and only for a filter with a known indexed
            rewrite.
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      description: '`Authorization: Bearer <token>`'
    token_query:
      type: apiKey
      in: query
      name: token
      description: >-
        Alternative to the Authorization header: pass the token as a
        `?token=<token>` query parameter.
```


## API Specification

The full API specification for this endpoint is available in the [documentation index](https://docs.appsignal.com/llms.txt).


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