Summary from

  • Understanding Prometheus Range Vectors
  • The Anatomy of a PromQL Query

  • What’s a Vector?
    • Since Prometheus is a timeseries database, all data is in the context of some timestamp. The series that maps a timestamp to recorded data is called a timeseries
    • a set of related timeseries is called a vector
    • Ex.
      • http_requests_total is a vector representing the total number of http requests received by a service
      • http_requests_total{code="200"} http_requests_total refers to the entire set of timeseries that are named that. And by appending a {code="200"}, we’re selecting a subset.
  • Types of Vectors
    • Instant vector - a set of timeseries where every timestamp maps to a single data point at that “instant”
      • Imagine evaluating the expression http_requests_total at a given timestamp. http_requests_total is an instant vector selector that selects the latest sample for any time series with the metric name http_requests_total. More specifically, "latest" means "at most 5 minutes old and not stale", relative to the evaluation timestamp. So this selector will only yield a result for series that have a sample at most 5 minutes prior to the evaluation timestamp, and where the last sample before the evaluation timestamp is not a stale marker (an explicit way of marking a series as terminating at a certain time in the Prometheus TSDB).
    • Range vector - a set of timeseries where every timestamp maps to a “range” of data points, recorded some duration into the past.
      • Range vector is mostly used for graphs, where you want to show a PromQL expression over a given time range. A range query works exactly like many completely independent instant queries that are evaluated at subsequent time steps over a given range of time. Of course, this is highly optimized under the hood and Prometheus doesn't actually run many independent instant queries in this case.
  • Differences
    • Instant vectors can be charted; Range vectors cannot. This is because charting something involves displaying a data point on the y-axis for every timestamp on the x-axis. Instant vectors have a single value for every timestamp, while range vectors have many of them. For the purpose of charting a metric, it is undefined1 how to show multiple data points for a single timestamp in a timeseries.
    • Instant vectors can be compared and have arithmetic performed on them; Range vectors cannot. This is also due to the way comparison and arithmetic operators are defined. For every timestamp, if we have multiple values, we don’t know how to add1 or compare them to another timeseries of a similar nature.
    • Range Vectors for counters. We take the instant vector and append our duration [15m]. This part is called the range selector and it transforms the instant vector into a range vector. We then use a function like increase which effectively subtracts the data point at the start of the range from the one at the end. increase(http_requests_total{code="200",handler="/api/v1/query"}[15m]) represent it is the increase in the total number of requests over the past fifteen minutes
Answer from zangw on Stack Overflow
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › basics
Querying basics | Prometheus
Prometheus provides a functional query language called PromQL (Prometheus Query Language) that lets the user select and aggregate time series data in real time. When you send a query request to Prometheus, it can be an instant query, evaluated at one point in time, or a range query at equally-spaced steps between a start and an end time.
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › functions
Query functions | Prometheus
Elements in the range vector that contain only histogram samples are ignored entirely. For elements that contain a mix of float and histogram samples, only the float samples are used as input, which is flagged by an info-level annotation. This function has to be enabled via the feature flag --enable-feature=promql...
🌐
Grafana
grafana.com › blog › 2024 › 10 › 08 › inside-promql-a-closer-look-at-the-mechanics-of-a-prometheus-query
Inside PromQL: A closer look at the mechanics of a Prometheus query | Grafana Labs
October 9, 2024 - When PromQL takes a sample from each time series, all at the same timestamp, this is called an instant vector. A range vector, on the other hand, is a set of time series containing a range of data points over time for each series.
Top answer
1 of 10
42

Summary from

  • Understanding Prometheus Range Vectors
  • The Anatomy of a PromQL Query

  • What’s a Vector?
    • Since Prometheus is a timeseries database, all data is in the context of some timestamp. The series that maps a timestamp to recorded data is called a timeseries
    • a set of related timeseries is called a vector
    • Ex.
      • http_requests_total is a vector representing the total number of http requests received by a service
      • http_requests_total{code="200"} http_requests_total refers to the entire set of timeseries that are named that. And by appending a {code="200"}, we’re selecting a subset.
  • Types of Vectors
    • Instant vector - a set of timeseries where every timestamp maps to a single data point at that “instant”
      • Imagine evaluating the expression http_requests_total at a given timestamp. http_requests_total is an instant vector selector that selects the latest sample for any time series with the metric name http_requests_total. More specifically, "latest" means "at most 5 minutes old and not stale", relative to the evaluation timestamp. So this selector will only yield a result for series that have a sample at most 5 minutes prior to the evaluation timestamp, and where the last sample before the evaluation timestamp is not a stale marker (an explicit way of marking a series as terminating at a certain time in the Prometheus TSDB).
    • Range vector - a set of timeseries where every timestamp maps to a “range” of data points, recorded some duration into the past.
      • Range vector is mostly used for graphs, where you want to show a PromQL expression over a given time range. A range query works exactly like many completely independent instant queries that are evaluated at subsequent time steps over a given range of time. Of course, this is highly optimized under the hood and Prometheus doesn't actually run many independent instant queries in this case.
  • Differences
    • Instant vectors can be charted; Range vectors cannot. This is because charting something involves displaying a data point on the y-axis for every timestamp on the x-axis. Instant vectors have a single value for every timestamp, while range vectors have many of them. For the purpose of charting a metric, it is undefined1 how to show multiple data points for a single timestamp in a timeseries.
    • Instant vectors can be compared and have arithmetic performed on them; Range vectors cannot. This is also due to the way comparison and arithmetic operators are defined. For every timestamp, if we have multiple values, we don’t know how to add1 or compare them to another timeseries of a similar nature.
    • Range Vectors for counters. We take the instant vector and append our duration [15m]. This part is called the range selector and it transforms the instant vector into a range vector. We then use a function like increase which effectively subtracts the data point at the start of the range from the one at the end. increase(http_requests_total{code="200",handler="/api/v1/query"}[15m]) represent it is the increase in the total number of requests over the past fifteen minutes
2 of 10
24

VictoriaMetrics author here. This is Prometheus-like monitoring system, which supports PromQL-like query language - MetricsQL.

The instant vector and range vector are indeed confusing terms in Prometheus. That's why these terms are avoided in VictoriaMetrics docs. Prometheus query language - PromQL - provides various functions, which can be divided into two groups:

  • Functions, which accept only instant vector. Such functions can be split into the following subgroups:
    • transform functions, which apply various transformations individually per each input time series. For example, abs()
    • label manipulation functions, which modify labels and metric names for the input time series. For example, label_replace()
    • aggregate functions, which aggregate multiple input time series into specified groups of output time series. For example, sum(). Fun fact is that aggregate functions are named aggregation operators in Prometheus - see these docs.
  • Functions, which accept only range vector. VictoriaMetrics names such functions as rollup functions, since they calculate the result based on input time series samples over the given lookbehind window specified in square brackets (aka sliding window). For example, rate(http_requests_total[5m]) calculates the average per-second increase rate for http_requests_total time series over the last 5 minutes.

From user's perspective the only difference between instant vector and range vector is that range vector is constructed from the instant vector by adding a lookbehind window in square brackets. For example, http_requests_total is an instant vector, while http_requests_total[5m] is a range vector. I'd say that the range vector syntax is just a syntactic sugar for rollup functions in PromQL. E.g. rate(m[d]) could be written as rate(m, d), e.g. the lookbehind window d could be passed as a separate argument to rollup functions.

🌐
Promlabs
promlabs.com › blog › 2020 › 06 › 18 › the-anatomy-of-a-promql-query
PromLabs | Blog - The Anatomy of a PromQL Query
June 18, 2020 - Range queries are mostly used for graphs, where you want to show a PromQL expression over a given time range. A range query works exactly like many completely independent instant queries that are evaluated at subsequent time steps over a given ...
🌐
Logz.io
logz.io › home › blog › how to › an intro to promql: basic concepts & examples
An Intro to PromQL: Basic Concepts & Examples | Logz.io
September 2, 2023 - PromQL, short for Prometheus Querying Language, is the main way to query metrics within Prometheus. You can display an expression’s return either as a graph or export it using the HTTP API. PromQL uses three data types: scalars, range vectors, and instant vectors.
🌐
Google Cloud
googlecloudcommunity.com › google cloud › cloud foundations & onboarding
Using $__range in promql queries - Cloud Foundations & Onboarding - Google Developer forums
March 12, 2024 - When using PromQL in cloud monitoring dashboard, I can see that the variable $__interval is available (and often automatically used by google cloud). But is there a way to get the time duration for the entire range in question? Grafana has __range, but i can’t get that to work.
Find elsewhere
🌐
Medium
medium.com › @ahmed.s.farag96 › decoding-promql-unraveling-range-vectors-and-instant-vectors-in-prometheus-c1390f650e5c
Decoding PromQL: Unraveling Range Vectors and Instant Vectors in Prometheus | by Ahmed Saleh | Medium
November 25, 2023 - Usually, we get a range of values for a specific metric, for example, we could write http_requests_total{method = "POST", instance= "instance-1"} [15s] which would give us the scrapped values of this metric within the last 15 seconds as shown below.
🌐
Chronosphere
chronosphere.io › home › understanding the prometheus query language engine and its quirks
Understanding the Prometheus Query Language engine and its quirks | Chronosphere
June 26, 2024 - To give an extreme example, if we would like to have a step=30s for a 90-day range query, the PromQL engine would return 259,200 points. Even our computer monitor would not be able to visualize that many data points due to limitations in pixel count.
🌐
Better Stack
betterstack.com › community › guides › monitoring › promql
The Beginner’s Handbook to PromQL | Better Stack Community
February 26, 2025 - ... Scalar: A single numeric ... timestamp (e.g http_requests_total). Range vector: A set of time series, each with a range of data points over a specified time duration (e.g., http_requests_total[5m])....
🌐
DEV Community
dev.to › sre_panchanan › decoding-promql-a-deep-dive-into-prometheus-query-language-4h23
Decoding PromQL: A Deep Dive into Prometheus Query Language - DEV Community
November 12, 2024 - ... The query filters instant vectors to select time series where the memory usage exceeds 80 gigabytes. The Range Vector in Prometheus is a set of time series data, each associated with a range of values over a specified time interval.
🌐
Last9
last9.io › blog › guide-to-prometheus-query-language
PromQL: A Developer's Guide to Prometheus Query Language | Last9
February 26, 2026 - Range Vector: A set of time series with a range of samples over time. Scalar: A simple numeric floating-point value. String: A simple string value (currently unused in PromQL).
🌐
Satyanash
satyanash.net › software › 2021 › 01 › 04 › understanding-prometheus-range-vectors.html
Understanding Prometheus Range Vectors - Satyajeet Kanetkar
January 4, 2021 - To represent this in PromQL, we take the instant vector and append our duration [15m]. This part is called the range selector and it transforms the instant vector into a range vector.
🌐
Is It Observable
isitobservable.io › home › observability › prometheus › how to build a promql (prometheus query language)
How to build a PromQL (Prometheus Query Language) | Is It Observable
March 18, 2025 - When applying PromQL, Prometheus will transform the data and present it in 4 different formats: ... The first two are easy to understand: String is just a text format, and Scalar is a numerical value. However, instant vector and range vector are a bit more complex.
🌐
Chronosphere
docs.chronosphere.io › investigate › querying › promql
Using PromQL in Observability Platform - Chronosphere Documentation
Observability Platform provides built-in variables for PromQL queries. These are distinct from dashboard variables, and you can use both to write queries for dashboard panels. $__range: Defines a range for the current query or dashboard.
🌐
MetricFire
metricfire.com › blog › understanding-the-prometheus-rate-function
How the Prometheus rate() function works | MetricFire
March 12, 2026 - An instant vector is a set of time series data with a single scalar for each time series. A range vector is a set of time series data with a range of data points over time for each time series.
🌐
Robust Perception
robustperception.io › composing-range-vector-functions-in-promql
Composing range vector functions in PromQL – Robust Perception | Prometheus Monitoring Experts
December 5, 2016 - There are no functions that take a range vector and return a range vector, nor is there a way to do any form of subquery (prior to Prometheus 2.7.0). Even with support for subqueries, you wouldn't want to use them regularly as they'd be expensive.
🌐
Grafana
grafana.com › blog › 2020 › 02 › 04 › introduction-to-promql-the-prometheus-query-language
Introduction to PromQL, the Prometheus query language | Grafana Labs
February 5, 2020 - As supplements to this post, check ... sheet check out Timber’s PromQL for Humans or PromLabs’ PromQL Cheat Sheet. Prometheus uses three data types for metrics: the scalar, the instant vector, and the range vector....