To calculate aggregate sum of data points with resolution in time of one minute, you can specify that resolution in the range selector like this

sum_over_time(my_requests[$__range:1m])
Answer from markalex on Stack Overflow
🌐
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.
Discussions

promql function to sum distinct for gauge value
So I'm trying to get the sum_over_time from that gauge, but since Prometheus keeps pulling the same value until telegraf flushes the gauge from memory. More on github.com
🌐 github.com
11
November 19, 2021
How to sum up Gauges in PromQL (for alerting) - PromQL - Prometheus Monitoring System
Hi there, so I have my own exporter which exposes some gauges: my_latencies{endpoint="a", metric="p100"} 12 my_latencies{endpoint="a", metric="p50"} 7 my_latencies{endpoint="a", metric="p0"} 1 my_latencies{endpoint="b", metric="p100"} 299 ... It’s important to know that these gauges are scraped ... More on discuss.prometheus.io
🌐 discuss.prometheus.io
0
April 11, 2022
prometheus - How to sum up Gauges in PromQL (for alerting) - Stack Overflow
so I have my own Prometheus Exporter which exposes some gauges: my_latencies{endpoint="a", metric="p100"} 12 my_latencies{endpoint="a", metric="p50"} 7 my_latencies{endpoint="a", metric="p0"} 1 my_latencies{endpoint="b", metric="p100"} 299 ... It’s important to know that these gauges are scraped every minute, but not every minute there will be data. So plotted graphs will contain holes… · What I do want to achieve is an alerting when the sum ... More on stackoverflow.com
🌐 stackoverflow.com
grafana - prometheus: is it possible to use event number of gauge as a counter? - Stack Overflow
I use prometheus to monitor a api service. Currently, I use a Counter to count number of requests received and a Gauge for the response time in milliseconds. I've tried to use something like More on stackoverflow.com
🌐 stackoverflow.com
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › functions
Query functions | Prometheus
delta acts on histogram samples by calculating a new histogram where each component (sum and count of observations, buckets) is the difference between the respective component in the first and last native histogram in v. However, each element in v that contains a mix of float samples and histogram samples within the range will be omitted from the result vector, flagged by a warn-level annotation. delta should only be used with gauges (for both floats and histograms).
🌐
GitHub
github.com › prometheus › prometheus › issues › 9822
promql function to sum distinct for gauge value · Issue #9822 · prometheus/prometheus
November 19, 2021 - So I'm trying to get the sum_over_time from that gauge, but since Prometheus keeps pulling the same value until telegraf flushes the gauge from memory.
Author: prometheus
🌐
Prometheus
discuss.prometheus.io › promql
How to sum up Gauges in PromQL (for alerting) - PromQL - Prometheus Monitoring System
April 11, 2022 - Hi there, so I have my own exporter which exposes some gauges: my_latencies{endpoint="a", metric="p100"} 12 my_latencies{endpoint="a", metric="p50"} 7 my_latencies{endpoint="a", metric="p0"} 1 my_latencies{endpoint="b", metric="p100"} 299 ... It’s important to know that these gauges are scraped every minute, but not every minute there will be data.
🌐
VictoriaMetrics
victoriametrics.com › blog › prometheus metrics explained: counters, gauges, histograms & summaries
Prometheus Metrics Explained: Counters, Gauges, Histograms & Summaries
February 21, 2025 - To address these issues, VictoriaMetrics introduces a new histogram format: Improving Histogram Usability for Prometheus and Grafana - Aliaksandr Valialkin. Additionally, Prometheus introduced native histograms in version v2.40.0. A summary works similarly to a histogram, but the key difference is where quantiles are estimated.
🌐
TigerData
tigerdata.com › blog › four-types-prometheus-metrics-to-collect
A Deep Dive Into the Four Types of Prometheus | Tiger Data
December 10, 2025 - The metric name uses the _sum suffix. Optionally, a number of quantiles of measurements are exposed as a gauge using the metric name with a quantile label. Since you don’t want those quantiles to be measured from the entire time an application has been running, Prometheus client libraries use streamed quantiles that are computed over a sliding time window (which is usually configurable).
🌐
Promlabs
promlabs.com › blog › 2020 › 09 › 25 › metric-types-in-prometheus-and-promql
PromLabs | Blog - Metric Types in Prometheus and PromQL
September 25, 2020 - There are no functions that are specific to summary metrics (as there is not much you can compute over a quantile value), but you can conceptually see the quantile values exported from a summary metric as a set of gauges. PromQL functions can usually not figure out and complain automatically when you are passing in the wrong metric type, but we recommend following the Prometheus metric naming best practices to at least make it easy for humans to see what type of metric they are dealing with.
Find elsewhere
🌐
Prometheus
prometheus.io › docs › concepts › metric_types
Metric types | Prometheus
Instrumentation library usage documentation for gauges: ... A histogram records observations (usually things like request durations or response sizes) by counting them in configurable buckets. It also provides a sum of all observed values. As such, a histogram is essentially a bucketed counter.
🌐
Stack Overflow
stackoverflow.com › questions › 71828344 › how-to-sum-up-gauges-in-promql-for-alerting
prometheus - How to sum up Gauges in PromQL (for alerting) - Stack Overflow
so I have my own Prometheus Exporter which exposes some gauges: my_latencies{endpoint="a", metric="p100"} 12 my_latencies{endpoint="a", metric="p50"} 7 my_latencies{endpoint="a", metric="p0"} 1 my_latencies{endpoint="b", metric="p100"} 299 ... It’s important to know that these gauges are scraped every minute, but not every minute there will be data. So plotted graphs will contain holes… · What I do want to achieve is an alerting when the sum of the latencies breaks a certain threshold.
Top answer
1 of 2
5

count_over_time(response_time_ms[1m]) will tell you the number of samples, not the number of times your Gauge was updated within (what I assume to be) a Java process. Based on the value of 10 you're seeing, I'm assuming your scrape interval is 6 seconds.

For an explanation of why this doesn't work as you would expect it, a Gauge is simply a Java object wrapping a double value. Every time you set its value, that value changes, but nothing more. There's no count of how many times the value changed or any notification sent to Prometheus that this happened. Prometheus simply polls every 6 seconds and collects whatever value was there at the time (never the wiser that the value changed 15 times since the last time it was collected). This is why gauges are intended to measure single values that go up and down (such as memory utilization: it's now 645 MB, in 6 seconds it's 648 MB, in 12 seconds 543 MB): you know the value constantly changes, but the best you can do is sample it every now and then.

For something like request latency, you should use a Histogram: it's basically a counter for the number of observations (i.e. number of requests); a counter for the sum of all observations (i.e. how long all requests put together took); and separate counters for each bucket (i.e. how many requests took less than 1 ms; how many requests took less than 10 ms; etc.). From this you can get an accurate average over any multiple of your scrape interval (i.e. change in total time divided by change in number of requests) as well as estimates for any percentile (including the median). How precise said percentiles are depends on the bucket sizes you choose (and how well they actually match the actual measurements).

Or, if all you're interested in is the number of requests, then a counter that's incremented on every request will be enough. To adjust for counter resets (e.g. job restarts), you should use increase() rather than the simple difference suggested above:

increase(number_of_requests_total[1m])
2 of 2
0

If you want to count number of requests in some specific time from now (in last 1m in this case) just use

number_of_requests_counter - number_of_requests_counter offset 1m

If you want to have sth like requests per second, than use

rate(number_of_requests_counter[1m])

I can tell you why it's not working with your Gauge, but first of all specify what do you assign to this metric. I mean, do you assing some avarage, last response time, or some other stuff?

For response time you should use Summary or Histogram (more info here)

🌐
OpenObserve
openobserve.ai › home › blog › prometheus metrics types
Prometheus Metric Types (Counters, Gauges, Histograms, Summaries)
November 19, 2025 - When Prometheus metrics are ingested into O2, each sample becomes a row with: metric → name of the metric (e.g., http_requests_total) ... Gauge values can go up or down, so queries focus on current state, min/max, average, trends. ... Histogram metrics expose bucket counts, sum, and count, ...
🌐
Google Groups
groups.google.com › g › prometheus-users › c › I7Vcd7nY41Q
Sum over range vector?
... Either email addresses are ... On Wednesday, January 3, 2018 at 11:03:15 AM UTC-7, Ben Kochie wrote: You can use sum_over_time(foo[5m]) to add up all the values in a metric over time....
🌐
MetricFire
metricfire.com › blog › understanding-the-prometheus-rate-function
How the Prometheus rate() function works | MetricFire
March 12, 2026 - In addition, there are four different metric types in the Prometheus client libraries: Counter: Useful for increasing values; the counter resets to zero on restart. Gauge: Useful for counts that go up and down or for rising and falling values. Histogram: Useful for sampling observations (such as response sizes), counting them in buckets for configuration, and providing a sum of the observed values.
🌐
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.
🌐
Last9
last9.io › blog › prometheus-metrics-types-a-deep-dive
Prometheus Metrics Types - A Deep Dive | Last9
June 17, 2026 - Prometheus metrics are structured time series built on a flexible data model. Each metric includes a name, labels, a sample value, and a timestamp. Samples are collected at intervals and queried using PromQL. ... Gauges are ideal for system values that fluctuate over time. Use a histogram when you need to analyze value distributions or percentiles, such as: ... Summary metrics are computed on the client side.
🌐
Tom Gregory
tomgregory.com › how-and-when-to-use-a-prometheus-gauge
How and when to use a Prometheus gauge | Tom Gregory
February 5, 2021 - The max_over_time function calculates the gauge's maximum value over the time range. ... Most Prometheus functions do work with gauges, but there are some important exceptions such as increase and rate.
🌐
Medium
ikod.medium.com › understanding-the-metric-types-of-prometheus-324890c29843
Understanding the Metric Types of Prometheus | by Jakir Patel | Medium
April 8, 2019 - A Histogram consists the combination ... is <basename>_bucket {le = “<bound_value>”} ii. Sum of the observation: This is sum of all observations....
🌐
Iximiuz
iximiuz.com › en › posts › prometheus-functions-agg-over-time
Prometheus Cheat Sheet - Moving Average, Max, Min, etc (Aggregation Over Time)
However, a range vector of gauges is physically indistinguishable from a range vector of counters. And here we go... functions min_over_time(), max_over_time(), avg_over_time(), sum_over_time(), stddev_over_time(), and stdvar_over_time() makes sense to use only with gauge metrics.