In an ideal world (where your samples' timestamps are exactly on the second and your rule evaluation happens exactly on the second) rate(counter[1s]) would return exactly your ICH value and rate(counter[5s]) would return the average of that ICH and the previous 4. Except the ICH at second 1 is 0, not 1, because no one knows when your counter was zero: maybe it incremented right there, maybe it got incremented yesterday, and stayed at 1 since then. (This is the reason why you won't see an increase the first time a counter appears with a value of 1 -- because your code just created and incremented it.)

increase(counter[5s]) is exactly rate(counter[5s]) * 5 (and increase(counter[2s]) is exactly rate(counter[2s]) * 2).

Now what happens in the real world is that your samples are not collected exactly every second on the second and rule evaluation doesn't happen exactly on the second either. So if you have a bunch of samples that are (more or less) 1 second apart and you use Prometheus' rate(counter[1s]), you'll get no output. That's because what Prometheus does is it takes all the samples in the 1 second range [now() - 1s, now()] (which would be a single sample in the vast majority of cases), tries to compute a rate and fails.

If you query rate(counter[5s]) OTOH, Prometheus will pick all the samples in the range [now() - 5s, now] (5 samples, covering approximately 4 seconds on average, say [t1, v1], [t2, v2], [t3, v3], [t4, v4], [t5, v5]) and (assuming your counter doesn't reset within the interval) will return (v5 - v1) / (t5 - t1). I.e. it actually computes the rate of increase over ~4s rather than 5s.

increase(counter[5s]) will return (v5 - v1) / (t5 - t1) * 5, so the rate of increase over ~4 seconds, extrapolated to 5 seconds.

Due to the samples not being exactly spaced, both rate and increase will often return floating point values for integer counters (which makes obvious sense for rate, but not so much for increase).

Answer from Alin Sînpălean on Stack Overflow
🌐
SigNoz
signoz.io › guides › what is the difference between prometheus rate vs increase functions
Prometheus rate vs increase Functions Explained | SigNoz
June 23, 2026 - Rate() calculates per-second average change; increase() shows total change over time. Both functions are essential for analyzing counter metrics in Prometheus.
Top answer
1 of 3
273

In an ideal world (where your samples' timestamps are exactly on the second and your rule evaluation happens exactly on the second) rate(counter[1s]) would return exactly your ICH value and rate(counter[5s]) would return the average of that ICH and the previous 4. Except the ICH at second 1 is 0, not 1, because no one knows when your counter was zero: maybe it incremented right there, maybe it got incremented yesterday, and stayed at 1 since then. (This is the reason why you won't see an increase the first time a counter appears with a value of 1 -- because your code just created and incremented it.)

increase(counter[5s]) is exactly rate(counter[5s]) * 5 (and increase(counter[2s]) is exactly rate(counter[2s]) * 2).

Now what happens in the real world is that your samples are not collected exactly every second on the second and rule evaluation doesn't happen exactly on the second either. So if you have a bunch of samples that are (more or less) 1 second apart and you use Prometheus' rate(counter[1s]), you'll get no output. That's because what Prometheus does is it takes all the samples in the 1 second range [now() - 1s, now()] (which would be a single sample in the vast majority of cases), tries to compute a rate and fails.

If you query rate(counter[5s]) OTOH, Prometheus will pick all the samples in the range [now() - 5s, now] (5 samples, covering approximately 4 seconds on average, say [t1, v1], [t2, v2], [t3, v3], [t4, v4], [t5, v5]) and (assuming your counter doesn't reset within the interval) will return (v5 - v1) / (t5 - t1). I.e. it actually computes the rate of increase over ~4s rather than 5s.

increase(counter[5s]) will return (v5 - v1) / (t5 - t1) * 5, so the rate of increase over ~4 seconds, extrapolated to 5 seconds.

Due to the samples not being exactly spaced, both rate and increase will often return floating point values for integer counters (which makes obvious sense for rate, but not so much for increase).

2 of 3
50

Prometheus calculates rate(counter[d]) at timestamp t in the following way:

  1. It selects raw samples for the counter time series on the time range (t-d ... t]. Note that the t-d timestamp isn't included in the time range, while t timestamp is included in the time range. If the selected time range contains less than two raw samples, then Prometheus returns an empty value (a gap) at the timestamp t.
  2. Then it calculates the increase of the selected raw samples. Usually it is calculated as the difference between the last selected sample and the first selected sample. Calculations become slightly complicated if the counter was reset to zero during the selected time range. Let's skip this for the sake of clarity.
  3. Then the resulting increase can be extrapolated if timestamps for the first and/or the last raw samples are located too far from the bounds of the selected time range.
  4. Then the rate is calculated by dividing the extrapolated increase by d.

Prometheus calculates increase(counter[d]) in the same way except the last step.

Let's look at a few examples applied to the original data:

second   counter_value    increase calculated by hand(call it ICH from now)
1             1                    1
2             3                    2
3             6                    3
4             7                    1
5            10                    3
6            14                    4
7            17                    3
8            21                    4
9            25                    4
10           30                    5
  • The rate(counter[1s]) will return nothing at any timestamp t, since any time range (t-1s ... t] contains only a single raw sample, while Prometheus requires at least two samples for calculating both rate() and increase().

  • The rate(counter[2s]) and increase(counter[2]) would return the following values per each timestamp t when extrapolation isn't applied:

t       counter_value    rate(counter[2s])        increase(counter[2s])
1             1                    -                       -
2             3               (3-1)/2=1.0                3-1=2
3             6               (6-3)/2=1.5                6-3=3
4             7               (7-6)/2=0.5                7-6=1
5            10              (10-7)/2=1.5               10-7=3
6            14             (14-10)/2=2                14-10=4
7            17             (17-14)/2=1.5              17-14=3
8            21             (21-17)/2=2                21-17=4
9            25             (25-21)/2=2                25-21=4
10           30             (30-25)/2=2.5              30-25=5

In reality Prometheus results for rate(counter[2s]) and increase(counter[2s]) may be slightly bigger because of extrapolation, since the first sample on the selected time range is located comparatively far from the start of the time range.

Such calculations have the following issues:

  • Prometheus can return fractional results from increase() over time series, which contains only integer values. This is because of extrapolation. For example, Prometheus may return fractional results from increase(http_requests_total[5m]).

  • Prometheus returns empty results (aka gaps) from increase(counter[d]) and rate(counter[d]) when the lookbehind window d doesn't cover at least two samples - see rate(counter[1s]) and increase(counter[1s]) example above.

  • Prometheus completely misses the increase between the raw sample just before the (t-d ... t] interval and the first raw sample on this interval. This may result in inaccurate calculations. For example, increase(counter[1h]) doesn't equal to sum_over_time(increase(counter[1m])[1h:1m]).

Prometheus developers are aware of these issues - see this link. These issues are addressed in the system I work on - VictoriaMetrics - more specifically, in MetricsQL query language - see this comment and this article for technical details.

Discussions

irate() Vs rate() Functions in Prometheus

Let’s say you have a counter with these values observed at 1m intervals:

0
60
120
600
720
780

Now rate over 5m will be:

(780-0)/5/60 = 2.6/sec

And irate over 5m will be (only last two data points are used which happen to be only 1m apart)

(780-720)/1/60 = 1/sec

Increasing the resolution does not affect the irate function because the last two observed values do not change when you look further back.

More on reddit.com
🌐 r/PrometheusMonitoring
9
12
February 4, 2020
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
Counter reset after target restart
That's expected. Counters reset if the service being monitored restarts, or if they roll over at a max value. You should be viewing them using a function like rate(), increase(), etc. You should probably have a read of some documentation or guides, as just about all of them will mention this. Here's one of the places it's mentioned in the official docs . If you absolutely need to know the exact number of events which have occurred since some point in time then you could write persistence into the service you're monitoring, then expose that value as a gauge. However that type of metric is probably better off being inferred from another system, such as logs. More on reddit.com
🌐 r/PrometheusMonitoring
4
1
February 22, 2023
rate/sum confusion
What you're confusing is columns and rows. If you imagine each metric name like a column, and the label values as rows. If you want to add up a row, you use the + operator, if you want to add up a column, you use sum(). So if you want to sum up all the interfaces on a single instance, you do something like this: sum without (instance,name) ( rate(ifHCOutOctets{instance="10.1.2.3",job="Firewalls",name="Firewall-1"}[30s]) ) * 8 Note that I don't include the ifIndex label filter. This means all labels will match. If you want to match multiple labels at a time, you will need to use a regular expression match. Something like ifIndex=~"(500010723|500010724)". EDIT: An example of a valid use of the + operator would be something like this: sum by (name) (rate(ifHCOutOctets[1m])) + sum by (name) (rate(ifHCInOctets[1m])) Note that we're adding up two columns, in and out octets. More on reddit.com
🌐 r/PrometheusMonitoring
6
1
October 17, 2019
People also ask

How does the Prometheus rate() function differ from increase()?
While rate() calculates the per-second average rate of increase, increase() calculates the total increase in the counter's value over the time range. rate() is generally more useful for ongoing monitoring, while increase() can help understand total change over a specific period.
🌐
last9.io
last9.io › blog › prometheus-rate-function
Prometheus Rate Function: A Practical Guide to Using It | Last9
Can rate() be used with all types of Prometheus metrics?
No, rate() should only be used with counter-metrics. It doesn't make sense to use rate() with gauge metrics, as they don't represent cumulative values.
🌐
last9.io
last9.io › blog › prometheus-rate-function
Prometheus Rate Function: A Practical Guide to Using It | Last9
How do you calculate request rates using the Prometheus rate function?
To calculate request rates, use a query like rate(http_requests_total[5m]). This will give the per-second rate of requests over the last 5 minutes. These rates can be summed or grouped as needed, e.g., sum(rate(http_requests_total[5m])) for the total request rate across all instances.
🌐
last9.io
last9.io › blog › prometheus-rate-function
Prometheus Rate Function: A Practical Guide to Using It | Last9
🌐
OneUptime
oneuptime.com › home › blog › how to understand rate() vs increase() in prometheus
How to Understand rate() vs increase() in Prometheus
December 17, 2025 - 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 · # Counter values: 100, 150, 200, 0 (reset), 30 # rate() and increase() detect the drop from 200 to 0 # They add the post-reset increase to the pre-reset increases # The resets() function shows how many resets occurred resets(http_requests_total[1h])
🌐
Better Stack
betterstack.com › community › questions › do-i-understand-prometheus-rate-vs-increase-correctly
Do I Understand Prometheus's Rate Vs Increase Functions Correctly? | Better Stack Community
December 2, 2024 - Use increase when you need to know the total amount of something that occurred (e.g., total requests over a time period). ... Get notified with a radically better infrastructure monitoring platform.
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › functions
Query functions | Prometheus
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.
🌐
Medium
medium.com › @bhupender.rawat4 › demystifying-prometheus-a-deep-dive-into-rate-and-irate-ce02745231fc
Demystifying Prometheus: A Deep Dive into rate() and irate() | by Bhupender Singh Rawat | Medium
May 7, 2025 - It uses the full range of data points returned by the query http_requests_total[5m]. Since rate() works on counter metrics, it calculates the per-second average rate of increase by using the first and last data points in the range vector.
Find elsewhere
🌐
PagerTree
pagertree.com › learn › prometheus › promeql › counter rates & increases
Counter Rates & Increases | PagerTree
Logically, only the increase() function includes extrapolation because it measures an absolute increase. rate() and irate() functions calculate a slope (derivative), which will not change even if extrapolation is included.
🌐
Last9
last9.io › blog › prometheus-rate-function
Prometheus Rate Function: A Practical Guide to Using It | Last9
June 15, 2026 - Last9 is a managed observability platform compatible with Prometheus and OpenTelemetry. Run PromQL against your metrics without operating Prometheus storage yourself. Try Last9 free. While rate() calculates the per-second average rate of increase, increase() calculates the total increase in the counter’s value over the time range.
🌐
DoHost
dohost.us › home › 2025 › september › 28 › understanding rate vs. increase in promql
Understanding Rate vs. Increase in PromQL - DoHost
September 28, 2025 - You’ll learn when to use `rate()` to smooth out counter resets and when `increase()` provides a more accurate total change over a specific time window. We’ll also discuss potential pitfalls and best practices for leveraging these functions ...
🌐
DoiT
doit.com › home › blog › making peace with prometheus rate()
Making peace with Prometheus rate() - DoiT Cloud Intelligence
April 7, 2026 - A deep dive into why Prometheus rate() and increase() return zeros or extrapolated values, with fixes using custom ranges, xrate, and VictoriaMetrics.
🌐
Promlabs
promlabs.com › blog › 2021 › 01 › 29 › how-exactly-does-promql-calculate-rates
PromLabs | Blog - How Exactly Does PromQL Calculate Rates?
January 29, 2021 - You can imagine this as rate() creating a set of "virtual" samples from the underlying "real" samples. The final rate is then calculated from the virtual samples, as if the resets had never taken place: Note: Whenever a counter resets, there is the chance that it was incremented after Prometheus's last scrape, but before the reset.
🌐
Medium
medium.com › @rameshavutu › prometheus-rate-irate-increase-counters-gauges-explained-2e4a0eeedfa3
Prometheus rate() vs irate() vs increase(): Understanding Counters, Gauges, and Accurate Metrics | Medium
June 10, 2026 - Whenever the total count matters more than the rate. ... If someone asks, “How many?”, increase() is usually the right tool. There’s one subtle detail that surprises a lot of engineers. increase() doesn't simply subtract the first value from the last value...
🌐
GitConnected
levelup.gitconnected.com › conquer-promql-how-rate-and-increase-work-38d0acf91a0d
Conquer PromQL — How Rate and Increase Work | by Guy Erez | Level Up Coding
April 16, 2023 - Let’s start with increase() as it makes it much easier to understand rate(). When I read the documentation I felt like I needed a degree in statistics to make sense of it. So let’s break it down in simple terms: Let’s say you’re measuring the number of failed requests to your server. So you’ve initialized a counter metric called failed_requests, with the label path. If you decide to query Prometheus for the metric’s value, it’ll look something like this: failed_requests{path=”/cats”} and the result will simply be an integer value - let’s say it’s 10.
🌐
Google Groups
groups.google.com › g › prometheus-users › c › jqEt-FkJo0o
overhead of rate vs increase
In fact, the code for the two functions is identical. The only difference is when it's `rate()`, the resulting value is divided by the number of seconds in the range. https://github.com/prometheus/prometheus/blob/291ab4d0bc6ea9f0e61073f303bd3982e9727b8d/promql/functions.go#L152-L154
🌐
GitConnected
levelup.gitconnected.com › prometheus-counter-metrics-d6c393d86076
Working With Prometheus Counter Metrics | Level Up Coding
February 28, 2022 - Because of this, it is possible to get non-integer results despite the counter only being increased by integer increments¹. Similar to rate, we should only use increase with counters.
🌐
GitHub
github.com › prometheus › prometheus › discussions › 13900
inconsistency in prometheus rate/increase/deriv/delta calculation · prometheus/prometheus · Discussion #13900
April 6, 2024 - Hi , While reviewing Prometheus-related content online, I've come to understand that the rate / deriv is calculated as (v2 - v1) / (t2 - t1), and the increase/delta is simply (v2 - v1). Now, co...
Author: prometheus
🌐
Medium
mohansaiteki.medium.com › manually-calculate-the-rate-irate-and-increase-functions-in-prometheus-7e755fff9897
Manually calculate the rate, irate, and increase functions in Prometheus
August 21, 2023 - You can see the irate function doesn’t consider all the values in a time range and that is how it is designed and that is the reason why the prometheus document recommends the irate function for the fast-moving counter rather than the slow-moving counter. There is a problem with the irate function since it doesn’t consider all the values in the time range. There is a high chance of missing a spike if the spike falls under un-considered values in a given time range. This is clearly explained in this blog. Now let’s jump into the last function which is the increase function
🌐
Medium
medium.com › @armanihsan224 › rate-and-increase-function-in-promql-235bba167000
rate and increase function in promQL | by Arman ihsan | Apr, 2026 | Medium
April 12, 2026 - But rate() uses extrapolation that can exceed actual values. ... The problem: The last data point inside your window was at 10:00:15, not 10:00:20. Even though counter was 140 at 10:00:15, Prometheus assumed it would continue increasing at the same rate until 10:00:20.
🌐
Reddit
reddit.com › r/prometheusmonitoring › irate() vs rate() functions in prometheus
r/PrometheusMonitoring on Reddit: irate() Vs rate() Functions in Prometheus
February 4, 2020 -

Hi All,

I'm trying to understand how irate() & rate() functions work. Why does irate() produce a similar looking graph when the range / resolution is 24h or 5m ? While the difference in graph is clearly visible with rate() when using range as 24h (presents a smoothed out line) or 5m(more spikey).

In the below graph for irate() for 2 different resolutions the graph looks the same. As per prometheus docs irate() calculates the per second instant rate based on the last two data points. What does this mean if my range is 24h? Thank you.

https://preview.redd.it/08mc4pq2mye41.jpg?width=3206&format=pjpg&auto=webp&s=4aef0b681969c8b9831ec0f34310838511ea0350