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:

🌐
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.
Discussions

prometheus - Grafana - Promql cumulative graph - Stack Overflow
No I want a graph in Grafana which shows the cumulative result. E.g. ... This results in a graph plotting the current results. But I want a query plotting the cumulative results. When I try to wrap the whole query with a sum_over_time, I get the following exception: "expected type matrix in call to function "sum_over_time", got vector" ... PromQL in Prometheus ... More on stackoverflow.com
🌐 stackoverflow.com
Help with PromQL query (sum over time)
For a stat panel, you want to use increase() to compute the value. sum by (ifName) ( increase( ifHCInOctets{ instance="192.168.200.10", job="snmp_exporter", ifName=~".*(1001).*" }[$__range] ) ) * 8 Make sure to click the query options and change it from "Range" to "Instant". This will provde an efficient single computation of the value for the panel. Although you won't get the spark line. (but really, if you want a spark line, use a graph) For the graph query, I also recommend against using irate(). It leads to misleading results. Use this query instead: sum by (ifName) ( increase( rate{ instance="192.168.200.10", job="snmp_exporter", ifName=~".*(1001).*" }[$__rate_interval] ) ) * 8 This will give you accurate graphs as you in and zoom out over time. Make sure you set the query option "min step" to match your scrape interval (1m). More on reddit.com
🌐 r/PrometheusMonitoring
9
1
July 17, 2024
Display sum of all gauge's values
Hello, I’m very new to Grafana and Prometheus. I’m using Grafana v8.2.6 on Windows 10, along with Prometheus. It scrapes a Gauge metric that is sent every 2 minutes. I would like to display a stat that corresponds to a running sum of all values the Gauge ever had. More on community.grafana.com
🌐 community.grafana.com
3
0
May 31, 2023
How can I make a cumulative sum graph in grafana, from an elasticsearch data source? - Stack Overflow
Relevant info: Grafana v5.4.2 (commit: d812109) ElasticSearch version: 5.6.8 There is an ES index that is a log of events over time, and the events are categorised (per country). There is a grafana More on stackoverflow.com
🌐 stackoverflow.com
🌐
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, ...
🌐
OneUptime
oneuptime.com › home › blog › how to create cumulative function that resets daily in grafana
How to Create Cumulative Function That Resets Daily in Grafana
December 17, 2025 - Creating cumulative metrics that reset daily is a common requirement for tracking daily quotas, usage limits, or progress toward daily goals. While Prometheus counters are inherently cumulative, making the visualization start again at midnight requires specific techniques. This guide shows you multiple approaches to achieve daily-resetting cumulative functions in Grafana.
🌐
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

🌐
Grafana
grafana.com › blog › 2020 › 06 › 23 › how-to-visualize-prometheus-histograms-in-grafana
How to visualize Prometheus histograms in Grafana | Grafana Labs
June 24, 2020 - A Prometheus histogram consists of three elements: a _count counting the number of samples; a _sum summing up the value of all samples; and finally a set of multiple buckets _bucket with a label le which contains a count of all samples whose ...
Find elsewhere
🌐
Grafana
community.grafana.com › dashboards
Display sum of all gauge's values - Dashboards - Grafana Labs Community Forums
May 31, 2023 - Hello, I’m very new to Grafana and Prometheus. I’m using Grafana v8.2.6 on Windows 10, along with Prometheus. It scrapes a Gauge metric that is sent every 2 minutes. I would like to display a stat that corresponds to a running sum of all values the Gauge ever had.
🌐
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:
🌐
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 › 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 ).
🌐
Grafana
community.grafana.com › t › cumulative-sum-over-time › 42434
Cumulative sum over time - Grafana - Grafana Labs Community Forums
January 31, 2021 - Hello I’m trying to simply display the cumulative sum of my rain gauge over a certain periode of time. The rain gauge has a 5min resolution , that i would like to see over one 1hour As you can see on the graphs , the cumulative sum almost work but never goes back to zero when it doesn’t ...
🌐
DEV Community
dev.to › rhuturaj_takle › prometheus-and-grafana-metrics-monitoring-and-dashboards-38fa
Prometheus and Grafana: Metrics Monitoring and Dashboards - DEV Community
1 month ago - Since a counter (Section 2) only ever increases, rate() computes the per-second average rate of increase over the specified window — this is almost always how a counter is actually queried in practice; the raw cumulative counter value on its own is rarely the interesting number. sum(rate(http_requests_total[5m])) by (route, method)
🌐
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.
🌐
Grafana
community.grafana.com › dashboards
Dashboard Grafana, Prometheus, several counters - how calculate sum? - Dashboards - Grafana Labs Community Forums
October 9, 2023 - Hi. I have several counters from Prometheus. How can I calculate the total quantity over a period of time? In this case - 72. I have already tried the options with increase, last_over_time. Also, it was not possible …
🌐
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 - Connect Grafana to your Prometheus data source. Create a new dashboard and add a panel. Use PromQL queries to populate the panel with request data. Customize the panel's visualization type (e.g., graph, gauge, or table). 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]))