Query Logs
Search and aggregate log data over HTTP using gcQL queries - filter by any field, run full-text searches, and compute aggregations in a single request.
Endpoint
POST /api/logs/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
Examples
Recent Error Logs
Fetch the latest error logs with a selected set of fields:
Example Response:
Filtering by Multiple Fields
Different fields combine with AND; repeating the same field creates an OR. This query matches error logs from the prod or dev environments:
Exclusions use a - prefix (-level:debug), and explicit boolean logic is also supported: level:error AND (env:prod OR env:dev). See gcQL filters for the full syntax.
Full-Text Search
A bare keyword (no field prefix) runs an indexed full-text search over log content. This counts how many log lines from a workload contain "500":
Example Response:
Aggregation: Errors per Workload
Count error logs grouped by workload, sorted by count:
Example Response:
Pagination
Use the offset and limit pipes with a stable sort order, keeping the same time range across pages:
Best Practices
Narrow the time range: keep
start/endas tight as your use case allows, and widen only if needed.Lead with a selective filter: a specific
workload,namespace, orlevelbounds the scan; on high-volume environments add a keyword predicate too.Aggregate on the server: one
| statsquery withcount() if (condition)beats fetching raw rows and counting client-side.Always bound results with
| limit N.
Last updated
