From reading https://prometheus.io/docs/prometheus/latest/querying/basics/ a 'Range Vector Selectors' are defined as :
Range vector literals work like instant vector literals, except that they select a range of samples back from the current instant. Syntactically, a time duration is appended in square brackets ([]) at the end of a vector selector to specify how far back in time values should be fetched for each resulting range vector element.
In this example, we select all the values we have recorded within the last 5 minutes for all time series that have the metric name http_requests_total and a job label set to prometheus: http_requests_total{job="prometheus"}[5m]
I'm failing to understand how these selector's behave. My understanding of the query :
sum(rate(data_total[1h]))
is return the rate of change of the data_total metric using a time during of 1h. Is this correct ? Is each point on the graph the sum(rate( of the previous hour ?
sum(rate(data_total[1h])) :
From the above definition shouldn't 1h of data be displayed ? Instead may of hours of data are displayed :

Changing from 1h to 4h :
sum(rate(data_total[4h])) :
renders :
Why has the shape changed when changing from [1h] to [4h] ?

The
range vectorselector is just an ordinary time series selector (which is confusingly namedinstant vectorselector) with the added lookbehind window in square brackets.An ordinary time series selector (aka
instant vectorselector) selects time series matching the given filter. For example,http_requests_total{path=~"/foo/bar|/baz"}selects time series with the namehttp_requests_totaland thepathlabel containing either/foo/baror/bazvalues.The corresponding
range vectorselector with the one hour lookbehind window looks like the followinghttp_requests_total{path=~"/foo/bar|baz"}[1h].The
range vectorselector can be used in the following places:It can be passed to /api/v1/query. In this case the API returns all the raw samples for matching time series on the interval
(time-d ... time], wheretimeis the query arg passed to/api/v1/query, whiledis the specified lookbehind window in square brackets ofrange vectorselector. See this article for details.It can be passed to e.g. rollup functions. These functions perform calculations over raw samples on the given lookbehind window in square brackets. The calculations are performed independently per each matching time series and per each requested point on the graph. Prometheus datasource in Grafana sends requests to /api/v1/query_range. This API accepts
start,endandstepquery args and calculatesN=1+(end-start)/steppoints per each matching time series at timestampsstart,start+step,start+2*step, ...,start+(N-1)*step.Let's look how
rate(m[d])is calculated on thestart ... endtime range with the givenstep:Prometheus selects all the time series matching
mon the given time range(start-d .. end]. Note that the time range starts fromstart-dinstead ofstart, wheredis the provided lookbehind window in square brackets.Then Prometheus calculates the average per-second increase rate over the given lookbehind window
dindividually per each matching time series per each requested point on the graph.See also this answer.