---
title: "Traces"
description: "The traces endpoints of the HTTP API."
---

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

# Traces

## GET /datasources/{uid}/traces/{trace_id}

Read one trace whole from a Tempo, Jaeger or ClickHouse datasource.

Answers every span of the trace as one frame with ref `A` and the columns `TraceId`, `SpanId`, `ParentSpanId`, `SpanName`, `ServiceName`, `StartTime`, `Duration`, `StatusCode`, `StatusMessage`, `SpanAttributes`, `ResourceAttributes`, `SpanKind`, `SpanEvents` and `SpanLinks`, sorted by `StartTime` then `SpanId`. `SpanKind` is one of `Server`, `Client`, `Producer`, `Consumer`, `Internal` or `Unspecified`, `SpanEvents` is a JSON array string of `{"time_ms", "name", "attributes"}` objects, and `SpanLinks` a JSON array string of `{"trace_id", "span_id", "attributes"}` objects with lowercase hex ids; both are `[]` when the span has none. A trace over 20,000 spans is cut to its earliest 20,000: `meta.rows` is the number of spans returned, `meta.rows_total` the number in the trace and `meta.truncated` says the two differ. `meta.bytes` is the size of Tempo's payload in bytes and `meta.elapsed_ms` the time the upstream read took; ClickHouse reports no `bytes`. `meta.kind` is `instant` and `meta.cached` is always false. `from` and `to` bound the search and default to the last 24 hours; they take relative expressions such as `now-1h`, epoch milliseconds or RFC 3339 times. The call runs with the agent tools' 15 second timeout, is never cached, and counts against the caller's 8 in-flight query requests. Viewers and above may call it, service-account keys included.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `uid` (required) | path | `string` |   |
| `trace_id` (required) | path | `string` | The trace id as 16 or 32 hex characters, in either case. |
| `from` | query | `string` |   |
| `to` | query | `string` |   |
| `timezone` | query | `string` | The browser's IANA time zone, used to resolve relative times such as `now/d`. |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | The spans of the trace. | [`PanelData`](/docs/reference/api/schemas/#paneldata) |
| `400` | The trace id is not 16 or 32 hex characters, `from` or `to` is not a valid time, or the datasource is not Tempo, Jaeger or ClickHouse (`invalid_request`). | [`PanelDataError`](/docs/reference/api/schemas/#paneldataerror) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The datasource does not exist, or no span of the trace lies in the range (`not_found`); widen `from` and `to`. | [`PanelDataError`](/docs/reference/api/schemas/#paneldataerror) |
| `422` | The response is over 32 MiB (`limit_exceeded`); the body carries no `ref`. | [`PanelDataError`](/docs/reference/api/schemas/#paneldataerror) |
| `429` | The caller already has the maximum number of query requests in flight, or the server's shared upstream call slots stayed busy for 5 seconds. | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request, including a datasource call that failed without a classified cause. | [`PanelDataError`](/docs/reference/api/schemas/#paneldataerror) |
| `502` | The datasource is unavailable. | [`PanelDataError`](/docs/reference/api/schemas/#paneldataerror) |
| `504` | The datasource did not answer within the 15 second query timeout, or the request did not finish within 20 seconds. | [`PanelDataError`](/docs/reference/api/schemas/#paneldataerror) |

## POST /datasources/{uid}/trace-stats

Count spans and errors per bucket and give the duration distribution of the spans a filter matches.

On Tempo `query` is a TraceQL spanset filter such as `{ resource.service.name = "checkout" }`, and `{}` matches every span; on ClickHouse it is a SQL boolean expression over `otel_traces` such as `ServiceName = 'checkout'`, and an empty string matches every span. The server picks a whole-second step of at least one second so the range fits in at most `buckets` buckets, aligns the range to it, and returns every bucket, oldest first, zero-filled. Each bucket carries its span and error counts and the p50, p95 and p99 span durations in milliseconds, null when the bucket has no spans. `histogram` is the duration distribution of every matched span over the whole range in powers-of-two buckets, ascending by `le_ms`, empty when nothing matched. `partial` is true when Tempo did not search every block, so the counts are a lower bound. The query runs with the agent tools' limits, nothing is cached, and the call counts against the caller's 8 in-flight query requests. Viewers and above may call it, service-account keys included. `from` and `to` take relative expressions such as `now-1h`, epoch milliseconds or RFC 3339 times.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `uid` (required) | path | `string` |   |

### Request body

`application/json`, required.

| Field | Type | Description |
| --- | --- | --- |
| `query` (required) | `string` | A TraceQL spanset filter on Tempo, or a SQL boolean expression over `otel_traces` on ClickHouse. |
| `from` (required) | `string` |   |
| `to` (required) | `string` |   |
| `buckets` | `integer` | The most buckets wanted. Between 1 and 200. Default `60`. |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | The span counts, error counts, quantiles and duration histogram. | [`TraceStats`](/docs/reference/api/schemas/#tracestats) |
| `400` | The request is malformed or fails validation, `buckets` is out of range, or the datasource is not Tempo or ClickHouse (`invalid_request`), or the query is longer than 64 KiB (`query_too_long`). | [`PanelDataError`](/docs/reference/api/schemas/#paneldataerror) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The datasource does not exist (`not_found`). | [`PanelDataError`](/docs/reference/api/schemas/#paneldataerror) |
| `413` | The request body exceeds the size limit. | [`Error`](/docs/reference/api/schemas/#error) |
| `422` | The filter cannot run: `query_invalid` for a Tempo query that is not a `{ ... }` spanset filter or that Tempo rejects, or a ClickHouse expression the server rejects; `query_forbidden` or `limit_exceeded` as for the explore query; the body carries no `ref`. | [`PanelDataError`](/docs/reference/api/schemas/#paneldataerror) |
| `429` | The caller already has the maximum number of query requests in flight, or the server's shared upstream call slots stayed busy for 5 seconds. | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request, including a datasource call that failed without a classified cause. | [`PanelDataError`](/docs/reference/api/schemas/#paneldataerror) |
| `502` | The datasource is unavailable. | [`PanelDataError`](/docs/reference/api/schemas/#paneldataerror) |
| `504` | The datasource did not answer within the 15 second query timeout, or the request did not finish within 20 seconds. | [`PanelDataError`](/docs/reference/api/schemas/#paneldataerror) |

Generated from [`api/openapi.yaml`](https://github.com/slashobserve/slashobserve/blob/c770e5e0/api/openapi.yaml) at `c770e5e0`. [Report a problem](https://github.com/slashobserve/slashobserve/issues/new).
