Skip to content

Reference

Draft query

The draft query endpoints of the HTTP API.

POST /datasources/{uid}/draft-query

Turn a question into a checked log query, PromQL query, TraceQL query or trace filters for one datasource.

The server reads the datasource’s metric names, labels, attributes or columns first, then asks the model once with the question and those facts, capped at 12 KiB. The answer is checked with the lint and one sample run over the last 15 minutes of the range under the agent tools’ limits; the full query is never run. Only when that check fails does the server make a second model call in the same session to correct it, so a draft spends at most two model calls, and a second failure answers cannot_translate. The whole draft has a 60 second deadline. Each caller may have 3 drafts in flight and each server process 10, and each caller may start 60 drafts per clock hour across all servers; the count is kept in the database. Loki answers LogQL, Prometheus answers PromQL, ClickHouse logs answer ClickHouse SQL, ClickHouse traces answer trace filters, and Tempo answers trace filters or, when the question needs more, TraceQL. signal defaults to logs on Loki, metrics on Prometheus and traces on Tempo, and ClickHouse requires it. from and to default to now-1h and now and take relative expressions such as now-1h, epoch milliseconds or RFC 3339 times. Viewers and above may call it, service-account keys included. Without a configured model it answers 503 agent_unavailable.

Parameters

Name In Type Description
uid (required) path string

Request body

application/json, required.

A DraftQueryRequest object.

Responses

Status Description Body
200 The checked draft; trace_filters is null unless language is filters, and query is empty when it is. DraftQuery
400 The body is malformed or fails validation, the signal does not fit the datasource type, or the datasource type has no drafts (invalid_request). Error
401 Authentication is missing or invalid. Error
403 The caller is not allowed to perform the request; a role that is too low is code forbidden_role. Error
404 The datasource does not exist (not_found). Error
413 The request body exceeds the size limit. Error
422 The question could not be turned into a query (cannot_translate); reason says why in one sentence. CannotTranslate
429 The caller has 3 drafts in flight or has used the 60 drafts of this clock hour (too_many_requests, and the message says which and how long to wait), or the server process has 10 in flight (agent_busy). Error
500 The server failed to handle the request. Error
502 The model provider failed (provider_error), or every read of the datasource failed, with the datasource’s own code such as datasource_unavailable. Error
503 No model is configured on this server (agent_unavailable). Error
504 The draft did not finish within its 60 second deadline (draft_timeout). Error

Generated from api/openapi.yaml at c770e5e0. Report a problem.

Reading this as an agent? Every page is in /llms.txt and /llms-full.txt as plain text.

/observeOpen source under Apache-2.0.Grafana is a trademark of Grafana Labs. Elasticsearch and Kibana are trademarks of Elasticsearch B.V. OpenSearch is a trademark of LF Projects, LLC. SlashObserve is not affiliated with or endorsed by any of them.

Search pages and headings.