Observability

Query Observability Store

Changed on

Runs a single read-only SQL query against the local trace store and returns { columns, rows }.

Only one SELECT/WITH statement is allowed; writes, DDL, PRAGMA, ATTACH, and multiple statements are rejected, and at most 10000 rows are returned. Bind values with params rather than string-interpolating them. attributes is stored as JSONB — wrap it with json(attributes) to read it back as JSON.

Schema (the query contract):

CREATE TABLE spans ( trace_id TEXT NOT NULL, span_id TEXT NOT NULL, parent_id TEXT, -- parent_id IS NULL on a root (invocation) span service TEXT, -- owning worker name (multi-worker attribution) name TEXT, kind TEXT, start_ms INTEGER, -- absolute epoch ms duration_ms INTEGER, -- whole ms; NULL while the span is still running outcome TEXT, error TEXT, attributes BLOB, -- JSONB; read via json(attributes) created_at TEXT, PRIMARY KEY (trace_id, span_id) ); -- index spans_roots ON spans (start_ms) WHERE parent_id IS NULL

CREATE TABLE logs ( trace_id TEXT NOT NULL, span_id TEXT, seq INTEGER NOT NULL, -- order within the trace ts_ms INTEGER, level TEXT, message TEXT, -- message is a JSON-encoded console arg array operation TEXT, created_at TEXT, PRIMARY KEY (trace_id, seq) );

post/local/observability/query

Request

  • Base URL: /cdn-cgi/local/explorer/api (relative, and the document was published on a file host, not at the API’s origin)
  • URL: /cdn-cgi/local/explorer/api/local/observability/query
  • Auth: none declared

Request body

sqlstring required

A single read-only SELECT/WITH query against the spans/logs schema above.

Response

Query response.

successtrue required

Whether the API call was successful.

Example response

{
  "errors": [],
  "messages": [],
  "success": true
}

Changes