---
title: "Fetch Analytics"
method: POST
path: "/tracing/analytics/query"
tags: ["Deprecated"]
deprecated: true
---

# Fetch Analytics

`POST /tracing/analytics/query`

> **Deprecated.**

Aggregate span metrics into time buckets.

Runs filtering and windowing identical to `POST /tracing/spans/query`,
then bucketizes the matched spans by time and computes one or more
metric summaries per bucket. Use this to build charts of latency,
cost, token usage, or custom numeric and categorical attributes.

## Request body

- `filtering` — same shape as the query endpoint, scoped to the spans
  that contribute to the analytics.
- `windowing` — `oldest`/`newest` for the time range and `interval`
  for bucket width (in seconds).
- `specs` — a list of `MetricSpec` entries describing which
  attributes to summarize and how. Each spec declares a `type`
  (`numeric/continuous`, `numeric/discrete`, `binary`,
  `categorical/single`, `categorical/multiple`, `string`, `json`,
  or `*` for auto) and a dotted `path` into the span (for example
  `attributes.ag.metrics.costs.cumulative.total`).

## Response

Buckets are returned in chronological order. Each bucket carries a
`metrics` dict keyed by spec path. See [Tracing — the ag.*
namespace](/reference/api-guide/tracing#the-ag-attribute-namespace)
for the cumulative/incremental metric layout on each span.

## Query parameters

- `focus` 'trace' | 'span'
- `format` 'agenta' | 'opentelemetry'
- `oldest` union
  - string
  - integer
- `newest` union
  - string
  - integer
- `interval` integer, nullable
- `rate` number, nullable
- `filter` unknown
- `specs` unknown

## Response `200`

Successful Response

- AnalyticsResponse — Analytics response with user-specified metric specs.
  - `support_id` string, nullable
  - `support_ts` string, date-time, nullable
  - `count` integer — Number of time buckets returned.
  - `buckets` MetricsBucket[] — Time-bucketed aggregates. Each bucket's `metrics` dict is keyed by the dotted `path` of the corresponding `MetricSpec`.
    - `timestamp` string, date-time, required
    - `interval` integer, required
    - `metrics` object, nullable
  - `query` TracingQuery
    - `formatting` Formatting
      - `focus` 'trace' | 'span'
      - `format` 'agenta' | 'opentelemetry'
    - `windowing` Windowing
      - `newest` string, date-time, nullable
      - `oldest` string, date-time, nullable
      - `next` string, uuid, nullable
      - `limit` integer, nullable
      - `order` 'ascending' | 'descending', nullable
      - `interval` integer, nullable
      - `rate` number, nullable
    - `filtering` FilteringOutput
      - `operator` 'and' | 'or' | 'not' | 'nand' | 'nor'
      - `conditions` union[]
        - union
          - Condition
            - `field` string, required
            - `key` string, nullable
            - `value` union
              - …
            - `operator` union
              - …
            - `options` union
              - …
          - FilteringOutput — recursive
  - `specs` MetricSpec[] — The resolved metric specs applied in each bucket.
    - `type` 'numeric/continuous' | 'numeric/discrete' | 'binary' | 'categorical/single' | 'categorical/multiple' | 'string' | 'json' | 'none' | '*'
    - `path` string
    - `bins` integer, nullable
    - `vmin` number, nullable
    - `vmax` number, nullable
    - `edge` boolean, nullable

## Other responses

- `422` — Validation Error

## Changes

- **2026-05-14** `d7e21f629c88` — 1 info
  - the `query` response's property default value `{}` was removed for the status `200`
- **2026-05-08** `bb630edffa27` — 3 info
  - api tag `Deprecated` added
  - api tag `Traces` removed
  - endpoint deprecated
- **2026-05-08** `5e6f53ce5d08` — 1 info
  - api operation id `fetch_analytics` removed and replaced with `query_analytics`
- **2026-05-02** `6e37373d45fe` — 2 info
  - api tag `Traces` added
  - api tag `Observability` removed
- **2026-04-23** `925e8b901a26` — 2 info
  - added the optional property `support_id` to the response with the `200` status
  - added the optional property `support_ts` to the response with the `200` status

[Full history](https://skmtc.dev/agenta-ai/apis/agenta-api/changes/tracing/analytics/query/post.md)

---

[API](https://skmtc.dev/agenta-ai/apis/agenta-api.md) · [All operations](https://skmtc.dev/agenta-ai/apis/agenta-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/agenta-ai/agenta-api/revisions/d7e21f629c88/schema)
