Prometheus doesn't provide functionality, which can be used for returning cumulative increase over multiple time series on the selected time range.

If you still need this functionality, then try VictoriaMetrics - Prometheus-like monitoring solution I work on. It allows calculating cumulative increase over multiple counters. For example, the following MetricsQL query returns cumulative increase over all the time series with http_requests_total name on the selected time range in Grafana:

running_sum(sum(increase(http_requests_total)))

How does it work?

  1. It calculates increase per each time series with the http_requests_total name. Note that the increase() in the query above doesn't contain lookbehind window in square brackets. VictoriaMetrics automatically sets the lookbehind window to the step value, which is passed by Grafana to /api/v1/query_range endpoint. The step value is the interval between points on the graph.

  2. It sums increases returned at step 1 with the sum() function individually per each point on the graph.

  3. It calculates cumulative increase over per-step increases returned at step 2 with the running_sum function.

Answer from valyala on Stack Overflow
🌐
OneUptime
oneuptime.com › home › blog › how to calculate cumulative increase in prometheus
How to Calculate Cumulative Increase in Prometheus
December 17, 2025 - # Shows a rolling cumulative increase over time in a graph sum_over_time( sum(increase(http_requests_total[1m]))[1h:1m] ) increase() automatically handles counter resets by detecting when a value drops and assuming it reset from zero. ...
Top answer
1 of 3
3

Prometheus doesn't provide functionality, which can be used for returning cumulative increase over multiple time series on the selected time range.

If you still need this functionality, then try VictoriaMetrics - Prometheus-like monitoring solution I work on. It allows calculating cumulative increase over multiple counters. For example, the following MetricsQL query returns cumulative increase over all the time series with http_requests_total name on the selected time range in Grafana:

running_sum(sum(increase(http_requests_total)))

How does it work?

  1. It calculates increase per each time series with the http_requests_total name. Note that the increase() in the query above doesn't contain lookbehind window in square brackets. VictoriaMetrics automatically sets the lookbehind window to the step value, which is passed by Grafana to /api/v1/query_range endpoint. The step value is the interval between points on the graph.

  2. It sums increases returned at step 1 with the sum() function individually per each point on the graph.

  3. It calculates cumulative increase over per-step increases returned at step 2 with the running_sum function.

2 of 3
1

Using sum(increase(http_requests_total{method="POST",path="/resource/aaa",statusClass="2XX"}[$__interval])) as query is a good starting point and that's as far as Prometheus can go.

However, in order to get the cumulative graph, you need to leverage a "Transformation" in the Grafana UI as I'll describe below with a concrete example.

See for example this graph in the Grafana Playground

Let's select a single timeseries upper_95 that we want to plot the cumulative sum for:

Then select the "Transformations" tab and click "Add Transformation"

Choose the "Add field from calculation" transformation

Then choose Mode "Cumulative functions" and Calculation "Total" (should be the default). The documentation says:

Cumulative functions - Apply functions on the current row and all preceding rows. Total - Calculates the cumulative total up to and including the current row.

which is exactly what we want.

Since we have multiple timeseries we need to also select "upper_95" as Field, but if you only have one you can leave it as blank.

Now you have the cumulative sum graph available and you can select it in the legend to hide the other ones:

People also ask

What is the difference between sum_over_time() and sum()?
sum() aggregates across different time series at a single point in time. sum_over_time() aggregates across multiple time points for the same time series.
🌐
last9.io
last9.io › blog › how-sum_over_time-works-in-prometheus
sum_over_time in Prometheus: Syntax and Pitfalls | Last9
How does sum_over_time() handle missing data points?
Missing data points are ignored. Prometheus treats data as stale when there is a gap longer than 5x the scrape interval, and those stale points are excluded from the sum.
🌐
last9.io
last9.io › blog › how-sum_over_time-works-in-prometheus
sum_over_time in Prometheus: Syntax and Pitfalls | Last9
Can sum_over_time() cause high memory usage?
Yes. Long time ranges combined with small step sizes and high-cardinality metrics produce memory spikes. Reduce the query size or precompute with recording rules.
🌐
last9.io
last9.io › blog › how-sum_over_time-works-in-prometheus
sum_over_time in Prometheus: Syntax and Pitfalls | Last9
🌐
Prometheus
prometheus.io › docs › practices › histograms
Histograms and summaries | Prometheus
histogram_fraction(0, 0.3, sum by (job) (rate(http_request_duration_seconds[5m]))) + histogram_fraction(0.3, 1.2, sum by (job) (rate(http_request_duration_seconds[5m]))) / 2 · In the “pure classic” case, you must have buckets present at the exact boundaries (giving you an accurate calculation in return). The corresponding PromQL expression looks quite different because the classic buckets are cumulative:
🌐
Last9
last9.io › blog › how-sum_over_time-works-in-prometheus
sum_over_time in Prometheus: Syntax and Pitfalls | Last9
July 25, 2025 - The sum_over_time() function in Prometheus gives you a way to aggregate counter resets, gauge fluctuations, and histogram samples across specific time windows. Instead of seeing point-in-time values, you get the cumulative total of all data ...
🌐
Google Groups
groups.google.com › g › prometheus-users › c › W2qqok5rnis
How to get the cumulative/total resource usage of resources say RAM or CPU over a selected duration of time?
August 12, 2021 - What Touseef is trying to do is sum all the container CPU and Memory and get a counter over a period of time. For example, yesterday 5 Pods with 7 containers were spawned. In total, the cumulative CPU request and Memory request was 300CPU and 500GB of RAM over the last 24h.
🌐
Reddit
reddit.com › r/prometheusmonitoring › help with promql query (sum over time)
r/PrometheusMonitoring on Reddit: Help with PromQL query (sum over time)
July 17, 2024 -

Hello,

I have this graph monitoring the bandwidth of a VLAN on a switch every 1m using SNMP Exporter, but I also what to get the total/sum data over time, so if I select the last hour it will show x amount inbound and x amount outbound.

sum by(ifName) (irate(ifHCInOctets{instance=~"192.168.200.10", job="snmp_exporter", ifName=~".*(1001).*"}[1m])) * 8

My current graph:

I'd like to duplicate and create a stat panel show how much data in total has passed over what period I choose that's all.

For the metric I'm not sure whether to use bytes(SI) or bytes(IEC), but are similar if I change to either.

Not sure how to calculate this, but I have this created for the past 1 hour.

by copying the PromQL in Grafana and changing to a stat panel and then editing to use this:

Not sure if this is ok as I'm not sure how to calculate it all, maths was never my best subject.

Any help would be great.

I think something like is close: with sum_over_time

sum by(ifName) (sum_over_time(ifHCInOctets{instance=~"192.168.200.10", job="snmp_exporter", ifName=~".*(1001).*"}[1m])) * 8

but it comes back as 85.8 Pib when it should be 85.8 TB with my calculations.

EDIT

Observium:

What Grafana shows

Find elsewhere
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › functions
Query functions | Prometheus
Buckets of classic histograms are cumulative. Therefore, the following should always be the case: The counts in the buckets are monotonically increasing (strictly non-decreasing). A lack of observations between the upper limits of two consecutive buckets results in equal counts in those two buckets. However, floating point precision issues (e.g. small discrepancies introduced by computing of buckets with sum(rate(...))) or invalid data might violate these assumptions.
🌐
Grafana
community.grafana.com › prometheus
How to get the cumulative/total resource usage of resources say RAM or CPU over a selected duration of time - Prometheus - Grafana Labs Community Forums
August 12, 2021 - Hi, I want to calculate the total consumption of memory/cpu usage (with underlying kubernetes infrastructure) monotonously over a period of time(lets say 3 months). I tried query like sum(container_memory_usage_bytes{namespace=~“$namespace”,pod=~“$pod”})/1024/1024/1024 I also tried to use the increase() and sum_over_time() functions to get the cumulative sum of the total resource consumed.
🌐
SigNoz
signoz.io › guides › how to measure total requests with prometheus - a time-based guide
How to Measure Total Requests with Prometheus - A Time-Based Guide | SigNoz
July 25, 2024 - For example, to display total requests over the last 24 hours in a time series graph: Add a new panel to your dashboard. In the query editor, enter: sum(increase(http_requests_total[24h]))
🌐
Google Groups
groups.google.com › g › prometheus-users › c › V7IbFb-w4ag
Simple increase - sum of the metrics in time range with dynamic metric count
September 22, 2023 - In VictoriaMetrics you can use the following MetricsQL query for bulilding summary increase graph over multiple time series of counter type, which starts from zero on the left side: ... Note that you don't need specifying lookbehind window in square brackets at increase(...), since VictoriaMetrics automatically sets it to the interval between points shown on the graph (aka step query arg automatically passed by Grafana to /api/v1/query_range - see https://prometheus.io/docs/prometheus/latest/querying/api/#range-queries ).
🌐
Prometheus
prometheus.io › docs › concepts › metric_types
Metric types | Prometheus
A native histogram is exposed and ingested as composite samples, where each sample represents the count and sum of observations together with a dynamic set of buckets. A classic histogram, however, consists of multiple time series of simple float samples. A classic histogram with a base metric name of <basename> results in the following time series: cumulative counters for the observation buckets, exposed as <basename>_bucket{le="<upper inclusive bound>"}
🌐
New Relic
docs.newrelic.com › docs › data-apis › understand-data › metric-data › cumulative-metrics
Cumulative metrics (OTel and Prometheus) | New Relic Documentation
Cumulative indicates there is no reset and the measurements are accumulated. Prometheus is a common example of a cumulative metrics collector (Prometheus docs on data types), and OpenTelemetry also defines ways to collect cumulative metrics (OpenTelemetry docs on temporality).
🌐
Robust Perception
robustperception.io › why-are-prometheus-histograms-cumulative
Why are Prometheus histograms cumulative? – Robust Perception | Prometheus Monitoring Experts
If additional labels are added to the histogram, or more buckets are added, then histograms can get rather expensive. Having cumulative histograms means that some buckets can be dropped at ingestion time, reducing the cost to Prometheus while still allowing (somewhat less accurate) quantiles to be calculated.
🌐
Long-term Memory
blog.dest-unreach.be › 2020 › 08 › 16 › cumulative-graphs-prometheus
Long-term Memory – Cumulative graphs in Prometheus
August 16, 2020 - Since this is a counter (_total suffix), Prometheus does all the magic to compensate if this counter would reset to zero. This also means that the absolute value of the counter is irrelevant, only the changes are meaningful. If you are only interested in the changes, rate(metric) will give you exactly that: it will calculate the rate of change (for this case, this will yield the average power in Watt between every two datapoints). But I wanted a cumulative view: how much energy have I produced over this day, this week, ...
🌐
Robust Perception
robustperception.io › rate-then-sum-never-sum-then-rate
Rate then sum, never sum then rate – Robust Perception | Prometheus Monitoring Experts
May 9, 2016 - Aggregation is core functionality of Prometheus, and it's most commonly applied to counters. As you'll recall from a previous article counters only go up and reset.
🌐
Promlabs
promlabs.com › promql-cheat-sheet
PromLabs | PromQL Cheat Sheet
Available aggregation operators: sum(), min(), max(), avg(), stddev(), stdvar(), count(), count_values(), group(), bottomk(), topk(), quantile()
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › operators
Operators | Prometheus
For /, the histogram sample has to be on the left hand side (LHS), followed by the scalar on the right hand side (RHS). All bucket populations and the count and the sum of observations are then divided by the scalar.
🌐
Promlabs
promlabs.com › blog › 2020 › 09 › 25 › metric-types-in-prometheus-and-promql
PromLabs | Blog - Metric Types in Prometheus and PromQL
September 25, 2020 - Prometheus differentiates between four types of metrics that are used to track aspects of a system. These types are: Gauge: A gauge is for tracking current tallies, or things that can naturally go up or down, like memory usage, queue lengths, in-flight requests, or current CPU usage. Counter: A counter is for tracking cumulative totals over a number of events or quantities like the total number of HTTP requests or the total number of seconds spent handling requests.
🌐
Last9
last9.io › blog › promql-cheat-sheet
PromQL Cheat Sheet: Queries, Functions, and Labels | Last9
September 12, 2024 - Also explore our guide on PromQL: A Developer’s Guide to Mastering Prometheus Queries. To view average available memory as a percentage over the last hour: avg_over_time(node_memory_MemAvailable_bytes[1h]) / avg_over_time(node_memory_MemTotal_bytes[1h]) * 100 · This shows average available memory as a percentage over the last hour. If you need a cumulative total for the window rather than a mean, swap in sum_over_time() — the sum_over_time() guide covers when each one applies.