Skip to main content

Range Query

A range query evaluates a PromQL expression over a time range at regular intervals, returning a matrix of results suitable for graphing.

Endpoint: GET https://euw1-01.m.xscalerlabs.com/prometheus/api/v1/query_range


Parameters

ParameterRequiredDescription
queryYesPromQL expression
startYesRange start — RFC3339 or Unix timestamp
endYesRange end — RFC3339 or Unix timestamp
stepYesResolution step — duration string (e.g. 60s, 5m) or seconds as a float
timeoutNoQuery timeout override. Maximum: 2m.

Example

Request rate over a 1-hour window with 60-second resolution:

curl "https://euw1-01.m.xscalerlabs.com/prometheus/api/v1/query_range" \
-H "Authorization: Bearer <token>" \
-H "X-Scope-OrgID: <tenant-id>" \
--data-urlencode 'query=rate(http_requests_total[5m])' \
--data-urlencode 'start=2024-01-01T00:00:00Z' \
--data-urlencode 'end=2024-01-01T01:00:00Z' \
--data-urlencode 'step=60'

Response

{
"status": "success",
"data": {
"resultType": "matrix",
"result": [
{
"metric": {
"job": "api-server",
"method": "GET"
},
"values": [
[1704067200, "12.5"],
[1704067260, "13.1"],
[1704067320, "11.8"]
]
}
]
}
}

values is an array of [timestamp, value_string] pairs at each step interval.


Choosing the right step

The step determines how many data points are returned and how much compute the query uses.

Rule of thumbRationale
step ≥ scrape intervalStepping finer than your scrape interval produces duplicate data points.
Aim for ≈ 200–400 data points per graphstep = (end - start) / 300 is a good default for dashboards.
For rate functions, match the range to at least 4× the steprate(metric[5m]) works well with a step of 60s90s.

Example: 24-hour graph

# 24 hours / 300 points = 288s ≈ 5m step
--data-urlencode 'start=2024-01-01T00:00:00Z' \
--data-urlencode 'end=2024-01-02T00:00:00Z' \
--data-urlencode 'step=5m'

Example: 7-day graph

# 7 days / 300 points ≈ 2016s ≈ 30m step
--data-urlencode 'start=2024-01-01T00:00:00Z' \
--data-urlencode 'end=2024-01-08T00:00:00Z' \
--data-urlencode 'step=30m'