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
max_over_time(range-vector): the maximum value of all float samples in the specified interval. sum_over_time(range-vector): the sum of all float or histogram samples in the specified interval (see details below).
🌐
Last9
last9.io › blog › how-sum_over_time-works-in-prometheus
sum_over_time in Prometheus: Syntax and Pitfalls | Last9
July 25, 2025 - How sum_over_time() aggregates samples over a range in PromQL, how it differs from increase, avg_over_time, and count_over_time, and how gaps skew results.
🌐
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

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
When should I use recording rules with sum_over_time()?
Use them when the same heavy sum_over_time() query runs in dashboards or alerts. Recording rules precompute the result and cut response time.
🌐
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 › prometheus › latest › querying › examples
Query examples | Prometheus
topk(3, sum by (app, proc) (rate(instance_cpu_time_ns[5m]))) Assuming this metric contains one time series per running instance, you could count the number of running instances per application like this: ... If we are exploring some metrics for their labels, to e.g. be able to aggregate over ...
🌐
OneUptime
oneuptime.com › home › blog › how to calculate cumulative increase in prometheus
How to Calculate Cumulative Increase in Prometheus
December 17, 2025 - To calculate increase since a specific time, you need a different approach: # Current value http_requests_total # Value at a point in the past http_requests_total offset 1h # Increase since 1 hour ago (doesn't handle resets) http_requests_total - http_requests_total offset 1h · Note: Simple subtraction doesn't handle counter resets. For accurate results, use increase() or calculate carefully. # 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 › promql sum_over_time with only positiv values
r/PrometheusMonitoring on Reddit: PromQL sum_over_time with only positiv values
November 12, 2024 -

Hi there, I am using the fronius-exporter to scrape metrics from my PV inverter. One of the interesting metrics is

fronius_site_power_grid, this describes the power in Watt that is consumed or supplied to the grid.

Example:

  • fronius_site_power_grid = 4242W --> buying energy from the grid

  • fronius_site_power_grid = -2424W --> selling energy from the grid

Now I want to sum-up all the energy that was bought or sold in one day. The following PromQL came into my mind:

sum_over_time(fronius_site_power_grid[24h]) *15 / 3600

This should give me the Energy in Wh that was transferred to/from grid.

How can I get a summed-up value for consumed or supplied that is not combined?
With PromQL is tried the following code that was failing:

sum_over_time(clamp_max(last_over_time(fronius_site_power_grid[15s]), 0)[24h]) *15 / 3600

Hint: 15s is my scrape interval

🌐
Promlabs
promlabs.com › promql-cheat-sheet
PromLabs | PromQL Cheat Sheet
Per-second rate of increase, calculated over last two samples in a 1-minute time window: irate(demo_api_request_duration_seconds_count[1m]) Open in PromLens · Absolute increase over last hour: increase(demo_api_request_duration_seconds_count[1h]) Open in PromLens · Sum over all series: sum(node_filesystem_size_bytes) Open in PromLens ·
Find elsewhere
🌐
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 - Speaking generally though, given ... the whole window period. This may give a non-integer result). You should then be able to sum() over that: sum(increase(foo[time]))....
🌐
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]))
🌐
GitHub
github.com › prometheus › docs › issues › 1194
How to get maximum of a sum over a period of time · Issue #1194 · prometheus/docs
October 17, 2018 - E.g. if start=now()-1hour, end=now() ... values I see depends on the step: curl -kv "http://localhost:9090/api/v1/query_range?query=sum(cell_value) by (pdbID)&start=1539527216&end=$NOW&step=3000" .......
Author: prometheus
🌐
Iximiuz
iximiuz.com › en › posts › prometheus-functions-agg-over-time
Prometheus Cheat Sheet - Moving Average, Max, Min, etc (Aggregation Over Time)
July 2, 2021 - Prometheus has a bunch of functions called <smth>_over_time(). They can be applied only to range vectors. It essentially makes them window aggregation functions.
🌐
Google Groups
groups.google.com › g › prometheus-users › c › 8m7tkdB_8sk
Sum over time without instance
to Prometheus Users · First understand what your metric does, and what change in that metric you're looking for. Decide whether it is a counter (it increments for each server restart, resetting to zero only when some collector restarts) or is a gauge (e.g. the number of restarts in a 5 minute period). If it's a counter, sum_over_time() is not what you're looking for.
🌐
Google Groups
groups.google.com › g › prometheus-developers › c › pul4HF4OS0E
Is it possible to sum a metric by day?
sum_over_time(your_recorded_rule[1y]) to get separate sums over each day (although you probably want to record an · increase(your_series) for that to be of any use). Probably not worth it, though. :o) ... -- You received this message because you are subscribed to a topic in the Google Groups ...
🌐
OneUptime
oneuptime.com › home › blog › how to create prometheus metrics for over time analysis
How to Create Prometheus Metrics for Over Time Analysis
December 17, 2025 - Prometheus offers several functions that aggregate values across a time range: flowchart LR subgraph "Input: Range Vector" S1[Sample 1: 10] S2[Sample 2: 15] S3[Sample 3: 12] S4[Sample 4: 18] S5[Sample 5: 14] end subgraph "Over Time Functions" AVG["avg_over_time() = 13.8"] MAX["max_over_time() = 18"] MIN["min_over_time() = 10"] SUM["sum_over_time() = 69"] end S1 --> AVG S2 --> AVG S3 --> AVG S4 --> AVG S5 --> AVG
🌐
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.
🌐
Prometheus
prometheus.io › docs › practices › histograms
Histograms and summaries | Prometheus
In the case of a summary or a classic histogram, you have separate time series for the sum and count of observations, marked by the magic suffixes _sum and _count, respectively. Thus, a summary or classic histogram called http_request_duration_seconds will result in the series http_request_duration_seconds_sum and http_request_duration_seconds_count, and the expression to calculate the average request duration over the last 5m will look like this:
🌐
Last9
last9.io › blog › prometheus-functions
Prometheus Functions: How to Make the Most of Your Metrics | Last9
February 28, 2025 - sum_over_time(): Returns the sum of every sample in the range — see how sum_over_time() works for where it differs from increase() Instead of triggering alerts based on a single point-in-time measurement, range vectors let you create alerts ...