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
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:

🌐
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. sequenceDiagram participant P as Prometheus participant M as Metric M->>P: Sample: 100 M->>P: Sample: 150 Note right of P: increase = 50 M->>P: Sample: 200 Note right of P: increase = 50 M->>P: Sample: 10 (after restart) Note right of P: Detects reset Note right of P: increase = (200 - 150) + 10 = 60 ·
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
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
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
🌐
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 - Instead of seeing point-in-time values, you get the cumulative total of all data points within your chosen range—useful for calculating totals from rate data, tracking accumulated errors, or understanding resource consumption patterns over ...
🌐
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.
🌐
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.
Find elsewhere
🌐
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

🌐
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 - At the core of Prometheus' request tracking functionality is the counter metric type. A counter is a cumulative metric that only increases over time, resetting to zero when the process restarts.
🌐
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.
🌐
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).
🌐
Wavefront
docs.wavefront.com › ts_cumulativeHisto.html
cumulativeHisto Function | VMware Aria Operations for Applications Documentation
Converts a cumulative histogram coming from Prometheus, Telegraf, or other source to an ordinary histogram in Operations for Applications histogram format. Users can then manipulate the histogram with Operations for Applications histogram query functions. Note: Always use the _bucket metric.
🌐
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 ...
🌐
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 ).
🌐
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, ...
🌐
Fiberplane
fiberplane.com › blog › why-are-prometheus-queries-hard
Why are Prometheus queries hard? | Fiberplane Blog
July 4, 2023 - One of the most important and confusing aspects of Prometheus is that most of the values it tracks just go up. Prometheus does not store how many events happened in each little time period. Instead, it keeps track of the cumulative total over time.
🌐
Akuszyk
akuszyk.com › 2020-07-24-prometheus-histograms.html
Prometheus Histograms. Run that past me again? | akuszyk.com
Prometheus histograms are cumulative. In Prometheus, our example above would have different buckets: <=10, <=100 and <=1000. Let’s see how this would look: You can see that now, each bucket is bigger than the one before and contains a sum of all values up until the bucket’s threshold.
🌐
New Relic
docs.newrelic.com › whats-new › 2023 › 03 › whats-new-03-14-cumulative-metrics
We now support cumulative metrics from OpenTelemetry and Prometheus | New Relic Documentation
April 25, 2023 - Simplify your monitoring workflow by easily querying both cumulative and delta metrics, without the need for client-side configuration. ... Get more insights into your Prometheus and OpenTelemetry data faster with cumulative metrics.
🌐
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.
🌐
The Mail Archive
mail-archive.com › prometheus-users@googlegroups.com › msg08511.html
[prometheus-users] Re: How to get the cumulative/total resource usage of resources say RAM or CPU over a selected duration of time?
August 17, 2021 - @Brian Candler., 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.