What you need is the increase() function, that will calculate the difference between the counter values at the start and at the end of the specified time interval. It also correctly handles counter resets during that time period (if any).

increase(http_requests_total[24h])

If you have multiple counters http_requests_total (e.g. from multiple instances) and you need to get the cumulative count of requests, use the sum() operator:

sum(increase(http_requests_total[24h]))

See also my answer to that part of the question about using Grafana's time range selection in queries.

Answer from Yoory N. on Stack Overflow
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › functions
Query functions | Prometheus
increase acts on histogram samples by calculating a new histogram where each component (sum and count of observations, buckets) is the increase between the respective component in the first and last native histogram in v.
Discussions

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
Possible to sum counter increase within range of hours, every day? - PromQL - Prometheus Monitoring System
Been around the internets, tried a thousand things, suspect it isn’t possible (or I’m out of my depth here), so last ditch is to seek out guidance on the forum… Basically we have a counter that tracks successful job runs. What I am trying to do is sum(increase(... within a 4h window every ... More on discuss.prometheus.io
🌐 discuss.prometheus.io
0
April 13, 2023
Why does increase() return a value of 1.33 in prometheus? - Stack Overflow
We graph a timeseries with sum(increase(foo_requests_total[1m])) to show the number of foo requests per minute. Requests come in quite sporadically - just a couple of requests per day. The value th... More on stackoverflow.com
🌐 stackoverflow.com
How to deal with Increase function and no data points
The correct thing to do is to init your counters at startup. This avoids null results for rare counters. More on reddit.com
🌐 r/PrometheusMonitoring
5
6
September 3, 2021
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 do I debug slow sum_over_time() queries?
Use count_over_time() to estimate how many data points the query touches, then limit the time range, increase the step size, and filter labels to reduce cardinality. Start with a simpler query and build it back up.
🌐
last9.io
last9.io › blog › how-sum_over_time-works-in-prometheus
sum_over_time in Prometheus: Syntax and Pitfalls | Last9
🌐
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 ).
🌐
OneUptime
oneuptime.com › home › blog › how to calculate cumulative increase in prometheus
How to Calculate Cumulative Increase in Prometheus
December 17, 2025 - # Total requests across all instances sum(increase(http_requests_total[1h])) # Total requests per service sum by (service) (increase(http_requests_total[1h])) # Total requests per status code sum by (status) (increase(http_requests_total[1h]))
🌐
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 - 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]))
🌐
Prometheus
discuss.prometheus.io › promql
Possible to sum counter increase within range of hours, every day? - PromQL - Prometheus Monitoring System
April 13, 2023 - Been around the internets, tried a thousand things, suspect it isn’t possible (or I’m out of my depth here), so last ditch is to seek out guidance on the forum… Basically we have a counter that tracks successful job runs. What I am trying to do is sum(increase(... within a 4h window every day over say, a 30d period.
Find elsewhere
Top answer
1 of 2
22

The challenge with calculating this number is that we only have a few data points inside a time range, and they tend not to be at the exact start and end of that time range (1 minute here). What do we do about the time between the start of the time range and the first data point, similarly the last data point and the end of the range?

We do a small bit of extrapolation to smooth this out and produce the correct result in aggregate. For very slow moving counters like this it can cause artifacts.

2 of 2
8

Prometheus calculates increase(foo_requests_total[1m]) at a timestamp t in the following way:

  1. It selects all the raw samples per each time series with foo_requests_total name on the time range (t-1m ... t]. Note that samples at the timestamp t-1m aren't included in the selection, while samples at the timestamp t are included in the selection.
  2. It calculates the difference d between the last and the first raw sample on the selected time range (Prometheus may also remove possible counter resets, but let's skip this step for the sake of clarity).
  3. It extrapolates the calculated difference d if the first and/or the last raw sample are located too far from the bounds of the selected time range.

The last step may result in fractional increase() values over integer counters as seen in the original question. See this issue for more details. Note also that increase() in Prometheus misses the difference between the first raw sample on the selected time range and the previous sample before the selected time range. This may result in smaller than expected increase() results.

Prometheus developers are going to fix these issues - see this design doc. In the mean time try VictoriaMetrics - its increase() function properly returns the expected integer result without any extrapolation over integer counters.

🌐
Last9
last9.io › blog › how-sum_over_time-works-in-prometheus
sum_over_time in Prometheus: Syntax and Pitfalls | Last9
July 25, 2025 - If you’re exploring how functions like sum_over_time() fit into the bigger picture, this Prometheus functions blog breaks it down with practical examples. Counters naturally increment over time, but sum_over_time() adds up the raw counter values, not the rate of increase.
🌐
Reddit
reddit.com › r/prometheusmonitoring › how to deal with increase function and no data points
r/PrometheusMonitoring on Reddit: How to deal with Increase function and no data points
September 3, 2021 -

I need to use the increase function, but the metric is very rare and when service restarts the counter is null for long time. The increase metric doesn’t play nicely with the null value and I can find a solution to consider null as zero.

Increase(my_counter[1h])

Works only if there are no null data points. Any other query I tried do not work like

Increase(my_metrics[1h] or vector(0))
🌐
MetricFire
metricfire.com › blog › understanding-the-prometheus-rate-function
How the Prometheus rate() function works | MetricFire
March 12, 2026 - You can use Prometheus functions such as the ones below to aggregate over a given range vector: ... As another example, you can use the increase() Prometheus function to count the number of HTTP requests over the past 5 minutes, e.g.:
🌐
Better Stack
betterstack.com › community › questions › get-total-requests-in-time-period
Get Total Requests in a Period of Time | Better Stack Community
February 26, 2025 - To calculate the total number of requests over a specified period of time using Prometheus, you can utilize the increase function. This function is ideal for summing up the total count of a counter metric over a given time interval.
🌐
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 - The counters from the restarted ... 0, the sum will decrease, which will then be treated by rate as a counter reset and you'd get a large spurious spike in the result. ... Similar applies to all other functions, operators and aggregates such as min, max, avg, ceil, histogram_quantile, predict_linear, division etc. To help keep you on the straight and narrow, remember this: The only mathematical operations you can safely directly apply to a counter's values are rate, irate, increase, and ...
🌐
Promlabs
promlabs.com › promql-cheat-sheet
PromLabs | PromQL Cheat Sheet
increase(demo_api_request_duration_seconds_count[1h]) Open in PromLens · Sum over all series: sum(node_filesystem_size_bytes) Open in PromLens · Preserve the instance and job label dimensions: sum by(job, instance) (node_filesystem_size_bytes) Open in PromLens ·
🌐
Grafana
community.grafana.com › prometheus
Why sum(increase(metric[10m])) return all 0 value? - Prometheus - Grafana Labs Community Forums
March 19, 2025 - What Grafana version and what operating system are you using? grafana cloud + prom-client + node.js What are you trying to achieve? Draw a chart about a counter metric increase. How are you trying to achieve it? I tried query sum(CLS), it shows the total count correctly, but is not the increase count of each time span I want : Then I tried sum(increase(CLS[10m])) query.
🌐
SigNoz
signoz.io › guides › what is the difference between prometheus rate vs increase functions
Prometheus rate vs increase Functions Explained | SigNoz
June 23, 2026 - Prometheus, a powerful open-source monitoring system, offers two essential functions for analyzing counter metrics: rate() and increase(). Understanding these functions correctly is crucial for effective data analysis and monitoring.
🌐
GitHub
github.com › prometheus › prometheus › issues › 2683
Surprising (incorrect?) behaviour of "increase" function · Issue #2683 · prometheus/prometheus
May 5, 2017 - $ curl -gs 'localhost:9090/api/v1/query?query=sum(increase(http_requests_total{job="api"}[10m]))' { "status":"success", "data":{ "resultType":"vector", "result":[ { "metric":{}, "value":[1494005782.193,"9.23076923076923"] } ] } } ... prometheus, version 1.5.2 (branch: master, revision: bd1182d29f462c39544f94cc822830e1c64cf55b) build user: root@a8af9200f95d build date: 20170210-14:41:22 go version: go1.7.5
Author: prometheus
🌐
GitHub
github.com › VictoriaMetrics › VictoriaMetrics › issues › 1215
sum(rate(metricselector[rangevector])) over-represents short lived timeseries · Issue #1215 · VictoriaMetrics/VictoriaMetrics
April 14, 2021 - Concretely, consider : given 15 ... beyond the range vector contribute 15R ; the bad pod contributes an increase of 1000R * 60 seconds / 60....
Author: VictoriaMetrics
🌐
OneUptime
oneuptime.com › home › blog › how to understand rate() vs increase() in prometheus
How to Understand rate() vs increase() in Prometheus
December 17, 2025 - # Total requests per day for capacity estimation sum(increase(http_requests_total[24h])) # Show total count in dashboard increase(http_requests_total[1h]) Both functions handle counter resets (when the counter goes back to zero after a restart): sequenceDiagram participant C as Counter participant P as Prometheus C->>P: Value: 100 C->>P: Value: 150 Note right of P: Normal increase: 50 C->>P: Value: 200 Note right of P: Normal increase: 50 C->>P: Value: 0 (restart) C->>P: Value: 30 Note right of P: Detects reset, adds<br/>post-reset increase ·