---
title: "Query Analytics"
method: POST
path: "/spans/analytics/query"
tags: ["Traces"]
---

# Query Analytics

`POST /spans/analytics/query`

## 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.
  - `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`, ordered oldest to newest.
    - `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

---

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