Query Traces
Search and aggregate trace spans over HTTP using gcQL queries - find failing requests, compute latency percentiles, and calculate error rates per endpoint.
Endpoint
POST /api/traces/v2/search
Authentication
This endpoint requires API Key authentication via the Authorization header.
Headers
Authorization
Yes
Bearer token with your API key
Content-Type
Yes
Must be application/json
X-Backend-Id
Only for multi-backend accounts
Your backend identifier, found under Settings → Access → API Keys (details)
Request Body
start
string
Yes
Start of the time range (RFC3339 / ISO 8601)
end
string
Yes
End of the time range (RFC3339 / ISO 8601)
query
string
Yes
The gcQL query to execute
Error Conventions in Traces
Traces carry two distinct error dimensions - pick the one that matches your question:
status_code>=500
HTTP-layer server errors (use status_code>=400 to include client errors)
status:error
Span-level error status, set by instrumentation
Examples
Recent Server Errors
Fetch HTTP spans that returned a 5xx status:
Example Response:
Latency per Endpoint
Compute request counts, average latency, and p99 latency per workload and resource in a single query:
Example Response:
Error Rate per Workload
Combine conditional counting with | math to compute an error percentage, and | filter to keep only meaningful traffic:
Example Response:
Best Practices
Filter by
span_type(http,grpc,sql, etc.) when your question targets a specific protocol.Traces do not support bare free-text keywords - use
field:*term*or*:*term*for substring matching, and prefer exact field filters where possible.Use the right error dimension:
status_codefor HTTP status errors,status:errorfor instrumentation-reported span errors.Always bound results with
| limit N.
Last updated
