Skip to content

Observability API

Endpoints for observability features.

POST /api/v1/observe/traces

Request:

{
"trace_id": "tr_xxx",
"span_id": "sp_xxx",
"parent_span_id": "sp_parent",
"name": "process_document",
"start_time": "2026-01-01T12:00:00Z",
"end_time": "2026-01-01T12:00:01Z",
"status": "ok",
"attributes": {
"document_id": "doc-123",
"pages": 10
}
}
GET /api/v1/observe/traces

Query parameters:

  • start_time - Start of time range (ISO 8601)
  • end_time - End of time range
  • agent_id - Filter by agent
  • status - Filter by status (ok, error)
  • min_duration_ms - Minimum duration
  • limit - Max results
GET /api/v1/observe/traces/{trace_id}

Response:

{
"data": {
"trace_id": "tr_xxx",
"spans": [
{
"span_id": "sp_xxx",
"name": "process_document",
"start_time": "...",
"end_time": "...",
"duration_ms": 1000,
"status": "ok",
"attributes": {...}
}
],
"duration_ms": 1500
}
}
POST /api/v1/observe/logs

Request:

{
"level": "info",
"message": "Document processed",
"timestamp": "2026-01-01T12:00:00Z",
"trace_id": "tr_xxx",
"span_id": "sp_xxx",
"attributes": {
"document_id": "doc-123"
}
}
GET /api/v1/observe/logs

Query parameters:

  • start_time - Start of time range
  • end_time - End of time range
  • level - Filter by level (debug, info, warn, error)
  • search - Full-text search
  • trace_id - Filter by trace
  • limit - Max results
POST /api/v1/observe/costs

Request:

{
"span_id": "sp_xxx",
"model": "gpt-4",
"input_tokens": 1500,
"output_tokens": 500,
"cost_usd": 0.045
}
GET /api/v1/observe/costs

Query parameters:

  • start_time - Start of time range
  • end_time - End of time range
  • group_by - Group by fields (agent_id, model, date)

Response:

{
"data": {
"items": [
{
"agent_id": "doc-processor",
"model": "gpt-4",
"total_cost": 45.50,
"total_input_tokens": 150000,
"total_output_tokens": 50000
}
],
"total_cost": 45.50
}
}
POST /api/v1/observe/alerts

Threshold alert:

{
"name": "High Error Rate",
"condition": {
"type": "threshold",
"metric": "error_count",
"operator": ">",
"threshold": 10,
"window": "5m"
},
"channels": [
{"type": "email", "to": "ops@example.com"}
]
}

Anomaly alert:

{
"name": "Latency Anomaly",
"condition": {
"type": "anomaly",
"metric": "request_latency_ms",
"sensitivity": 2.0,
"baseline_window": "24h"
},
"channels": [...]
}

Absence alert:

{
"name": "Missing Data",
"condition": {
"type": "absence",
"metric": "heartbeat_count",
"missing_for": "5m"
},
"channels": [...]
}
GET /api/v1/observe/alerts
GET /api/v1/observe/alerts/{alert_id}
PUT /api/v1/observe/alerts/{alert_id}
DELETE /api/v1/observe/alerts/{alert_id}
GET /api/v1/observe/alerts/{alert_id}/history
GET /api/v1/observe/dashboard?time_range={range}

Time range: 1h, 6h, 24h, 7d, 30d

Response:

{
"data": {
"total_requests": 10000,
"error_count": 50,
"error_rate": 0.005,
"p50_latency_ms": 25,
"p95_latency_ms": 100,
"p99_latency_ms": 250,
"total_cost": 123.45
}
}
GET /api/v1/observe/metrics

Query parameters:

  • metric - Metric name
  • start_time - Start of time range
  • end_time - End of time range
  • aggregation - avg, sum, min, max, p50, p95, p99
  • interval - Bucket interval (1m, 5m, 1h, 1d)
  • group_by - Group by fields
POST /api/v1/observe/otlp/config

Request:

{
"endpoint": "https://otel-collector.example.com:4318",
"headers": {"Authorization": "Bearer xxx"},
"export_traces": true,
"export_logs": true,
"sample_rate": 0.1
}
POST /api/v1/observe/otlp/v1/traces

Standard OTLP format.

POST /api/v1/observe/otlp/v1/logs

Standard OTLP format.