Run a PromQL instant query
- POST GET /_prometheus/{index}/api/v1/query
- POST GET /_prometheus/api/v1/query
Evaluate a PromQL expression at a single instant and return vector data.
The endpoint mirrors the Prometheus /api/v1/query endpoint.
GET requests send parameters in the query string.
On Serverless and on Elasticsearch 9.5.0 and later, POST requests send the same parameters as an application/x-www-form-urlencoded body.
Form-encoded POST requests are accepted only on authenticated TLS connections.
If you send the same parameter in both the query string and the form body, the API returns 400 with the standard Elasticsearch error body.
Required privileges
read
Path parameters
-
indexstringoptional -
An index expression that restricts which indices are considered, for example
metrics-generic.prometheus-*. If you omit it, the default expressionmetrics-*is used. Only indices withindex.mode: time_seriesare considered. An alias is accepted and index privileges are checked against that alias name.Leave it out to use
/_prometheus/api/v1/query.
Query parameters
-
timestring -
The evaluation instant, as an RFC 3339 timestamp or Unix time in seconds. Defaults to the current time.
-
limitnumber · default: 0 -
The maximum number of series to return.
0means no limit from the request. The cluster can still truncate the response atesql.query.timeseries_result_truncation_max_size. -
timeoutstring · default: 2m -
The evaluation timeout, as a number of seconds or a duration such as
30s. It must be positive:0is rejected with status code400. The default and the maximum are thexpack.prometheus.query.timeoutcluster setting. A request can only lower that cap. Set the cluster setting to-1to remove the default and the maximum; a positivetimeoutis then uncapped. When the timeout elapses, the response is503witherrorTypetimeout.
Responses
The request or expression is not valid, including a non-positive timeout.
A form parameter that is also in the query string is the standard Elasticsearch error body instead.
-
errorTypeenumrequired -
The Prometheus error type, from the HTTP status:
400isbad_data;503,408, and504aretimeout; every other status isexecution.Supported values include:
bad_data: HTTP400. The request or expression is not valid.timeout: HTTP503,408, or504. The query timed out or a gateway timed out.execution: Every other status, including HTTP403and500.
-
Values:
bad_datatimeoutexecution
The caller is not allowed to run the query.
-
errorTypeenumrequired -
The Prometheus error type, from the HTTP status:
400isbad_data;503,408, and504aretimeout; every other status isexecution.Supported values include:
bad_data: HTTP400. The request or expression is not valid.timeout: HTTP503,408, or504. The query timed out or a gateway timed out.execution: Every other status, including HTTP403and500.
-
Values:
bad_datatimeoutexecution
On Serverless and on Elasticsearch 9.5.0 and later, form-encoded POST requests are accepted only on authenticated TLS connections.
Otherwise the response is 406 with the standard Elasticsearch error body.
The query ran, but the response could not be written.
-
errorTypeenumrequired -
The Prometheus error type, from the HTTP status:
400isbad_data;503,408, and504aretimeout; every other status isexecution.Supported values include:
bad_data: HTTP400. The request or expression is not valid.timeout: HTTP503,408, or504. The query timed out or a gateway timed out.execution: Every other status, including HTTP403and500.
-
Values:
bad_datatimeoutexecution
The query timed out.
-
errorTypeenumrequired -
The Prometheus error type, from the HTTP status:
400isbad_data;503,408, and504aretimeout; every other status isexecution.Supported values include:
bad_data: HTTP400. The request or expression is not valid.timeout: HTTP503,408, or504. The query timed out or a gateway timed out.execution: Every other status, including HTTP403and500.
-
Values:
bad_datatimeoutexecution