Run a PromQL instant query

  • POST GET /_prometheus/{index}/api/v1/query
  • POST GET /_prometheus/api/v1/query
Auth

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

Index
read

Path parameters

index string optional

An index expression that restricts which indices are considered, for example metrics-generic.prometheus-*. If you omit it, the default expression metrics-* is used. Only indices with index.mode: time_series are 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

query string required

The PromQL expression to evaluate.

time string

The evaluation instant, as an RFC 3339 timestamp or Unix time in seconds. Defaults to the current time.

limit number · default: 0

The maximum number of series to return. 0 means no limit from the request. The cluster can still truncate the response at esql.query.timeseries_result_truncation_max_size.

timeout string · default: 2m

The evaluation timeout, as a number of seconds or a duration such as 30s. It must be positive: 0 is rejected with status code 400. The default and the maximum are the xpack.prometheus.query.timeout cluster setting. A request can only lower that cap. Set the cluster setting to -1 to remove the default and the maximum; a positive timeout is then uncapped. When the timeout elapses, the response is 503 with errorType timeout.

Responses

application/json
status string required

The status of the request: success.

data object required
resultType string required

The type of the result: vector for an instant query, matrix for a range query.

result object[] required

The result series. Sample values are JSON strings, including NaN, +Inf and -Inf.

warnings string[]

Warnings, such as a notice that the results were truncated because of limit.