---
type: api
title: "Run a PromQL range query"
description: "Evaluate a PromQL expression over a time range and return matrix data."
url: https://www.elastic.co/elastic/docs-builder/docs/5066/api/elasticsearch-serverless/operation/operation-prometheus-query-range
resource: https://www.elastic.co/elastic/docs-builder/docs/5066/api/elasticsearch-serverless/operation/operation-prometheus-query-range
products:
  - Elasticsearch Serverless
---

# Run a PromQL range query

Authentication: required

Availability: Preview

## Paths

- `POST` (also `GET`) `/_prometheus/{index}/api/v1/query_range`
- `POST` (also `GET`) `/_prometheus/api/v1/query_range`

#### Path parameters

- `index` (string) — optional, leave it out to use `/_prometheus/api/v1/query_range`
  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.

## Description

Evaluate a PromQL expression over a time range and return matrix data.
The endpoint mirrors the Prometheus `/api/v1/query_range` endpoint.

## Required privileges

- Index privileges: `read`

## Query string parameters

- `query` (string) — required
  The PromQL expression to evaluate.
- `start` (string) — required
  The start of the range, as an RFC 3339 timestamp or Unix time in seconds.
- `end` (string) — required
  The end of the range, as an RFC 3339 timestamp or Unix time in seconds.
- `step` (string) — required
  The resolution between samples, as a number of seconds or a duration such as `30s` or `1h30m`.
- `limit` (number) — optional
  The maximum number of series to return. `0` means no limit from the request.
- `timeout` (string) — optional
  The evaluation timeout, as a number of seconds or a duration such as `30s`.
It must be positive and is capped by the `xpack.prometheus.query.timeout` cluster setting.

## Responses

`application/json`

- `status` (string)
  The status of the request: `success`.
- `data` (object)
  - `resultType` (string)
    The type of the result: `vector` for an instant query, `matrix` for a range query.
  - `result` (object[])
    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`.
## Code examples

#### Console

```console
POST /_prometheus/api/v1/query_range?query=rate(http_requests_total[5m])&start=2026-07-09T22:00:00Z&end=2026-07-09T22:01:00Z&step=15s
```

#### JavaScript

```javascript
const response = await client.prometheus.queryRange({
  query: "rate(http_requests_total[5m])",
  start: "2026-07-09T22:00:00Z",
  end: "2026-07-09T22:01:00Z",
  step: "15s",
});
```

#### Python

```python
resp = client.prometheus.query_range(
    query="rate(http_requests_total[5m])",
    start="2026-07-09T22:00:00Z",
    end="2026-07-09T22:01:00Z",
    step="15s",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_prometheus/api/v1/query_range?query=rate(http_requests_total[5m])&start=2026-07-09T22:00:00Z&end=2026-07-09T22:01:00Z&step=15s" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### PHP

```php
$resp = $client->prometheus()->queryRange([
    "query" => "rate(http_requests_total[5m])",
    "start" => "2026-07-09T22:00:00Z",
    "end" => "2026-07-09T22:01:00Z",
    "step" => "15s",
]);
```

#### Ruby

```ruby
response = client.prometheus.query_range(
  query: "rate(http_requests_total[5m])",
  start: "2026-07-09T22:00:00Z",
  end: "2026-07-09T22:01:00Z",
  step: "15s"
)
```

## Response examples

#### A successful response

`application/json`

A successful response from `GET /_prometheus/api/v1/query_range`.

```json
{
  "status": "success",
  "data": {
    "resultType": "matrix",
    "result": [
      {
        "metric": {
          "job": "api",
          "instance": "api-1:8080"
        },
        "values": [
          [
            1783634400,
            "0.5"
          ],
          [
            1783634415,
            "0.52"
          ],
          [
            1783634430,
            "0.51"
          ]
        ]
      }
    ]
  }
}
```

