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 the per-second rate of change, while increase() computes the total change over a specified time range. No, these functions are designed for counter metrics. Gauge metrics should be analyzed using different PromQL functions.
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

Difficulties to display the right information with rate/increase PromQL function
Hi, I’m having some difficulties to display some values and to interprete them. My setup is : sFlow RT and Prometheus Exporter (to export network metrics in bits/sec) => Prometheus (where metrics are created/filtered) => Grafana (to display metrics, in Gbits/sec) Prometheus sFlow metrics ... More on community.grafana.com
🌐 community.grafana.com
4
0
April 23, 2025
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
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
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

Are there approaches for capturing spikes with PromQL?
Yes, max_over_time() can be used with rate() to capture spikes. For example, max_over_time(rate(http_requests_total[5m])[1h:]) will show the maximum rate observed in 5-minute windows over the last hour.
🌐
last9.io
last9.io › blog › prometheus-rate-function
Prometheus Rate Function: A Practical Guide to Using It | Last9
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
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
🌐
DoHost
dohost.us › home › 2025 › september › 28 › understanding rate vs. increase in promql
Understanding Rate vs. Increase in PromQL - DoHost
September 28, 2025 - We’ll delve into how each function ... behavior. 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....
🌐
OneUptime
oneuptime.com › home › blog › how to understand rate() vs increase() in prometheus
How to Understand rate() vs increase() in Prometheus
December 17, 2025 - Use rate() when you need per-second rates for monitoring, alerting, and time-series graphs. Use increase() when you need absolute counts for totals, billing, and single-value displays.
🌐
Promlabs
promlabs.com › blog › 2021 › 01 › 29 › how-exactly-does-promql-calculate-rates
PromLabs | Blog - How Exactly Does PromQL Calculate Rates?
January 29, 2021 - This function can be helpful if ... spiky than for rate(). increase(): This function is exactly equivalent to rate() except that it does not convert the final unit to "per-second" (1/s)....
🌐
PagerTree
pagertree.com › learn › prometheus › promeql › counter rates & increases
Counter Rates & Increases | PagerTree
rate() - "rate of increase" - calculates a per-second increase of a counter as averaged over a specified window. PromQL: rate() function · irate() - "instantaneous rate of increase" - calculates a per-second increase over the time window, only ...
🌐
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.
Find elsewhere
🌐
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 - PromQL. No matter how good you are, there will come a time when it’ll make you want to bang your head against the keyboard and beg for mercy. However, today is NOT that day my friends. Today, we learn! ... Let’s start with increase() as it makes it much easier to understand rate().
🌐
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
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › functions
Query functions | Prometheus
Use rate in recording rules so that increases are tracked consistently on a per-second basis. The info function is an experiment to improve UX around including labels from info metrics . The behavior of this function may change in future versions of Prometheus, including its removal from PromQL.
🌐
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 - Useful for calculating total occurrences (e.g., total requests) over a defined period. ... Use rate when you are interested in the speed of change or performance (e.g., how fast requests are coming in).
🌐
YouTube
youtube.com › prometheus monitoring with julius | promlabs
Understanding Counter Rates and Increases in PromQL | Reset Handling, Extrapolation, Edge Cases - YouTube
In this video, I explain the exact value calculation behaviors of the rate(), irate(), and increase() functions in PromQL for computing rates of increase for...
Published: July 10, 2023
Views: 15K
🌐
Advanced Beginner
advanced-beginner.github.io › advanced beginner › guides › observability › concepts › promql › rate and increase
rate and increase | Advanced Beginner
April 7, 2026 - With Counter alone, it’s like only looking at the odometer. Applying rate() and increase() gives you “current situation” and “period performance”.
🌐
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 - Because http_requests_total is a counter, the value of each time series increases over time with every incoming request to its respective path. In the flow diagram below, you’ll see how the values for each time series evolve based on traffic to /v1, /v2, and /v3. This setup is crucial for understanding how rate() and irate() behave when applied to such metrics.
🌐
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 - So you will get how much a value has increased in a given time range. ... From the above data, for the 1-minute time range the starting value and ending values are 694041.8 and 694002.44 respectively. ... From our calculation, the change of value in the 1-minute time range is 39.36. Let's compare our output with prometheus output ... Hurray! 🎉 Our output is the same as prometheus output (off-course it will otherwise I wouldn’t write this blog 🤪) I just explained how rate, irate, and increase functions work.
🌐
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 - rate() calculates the average per-second increase of a counter over a time window. Syntax · promql · rate(counter_name[time_window]) What It Returns · Instant Vector (one value per time series) Value = average requests per SECOND · How It ...
🌐
Grafana
community.grafana.com › prometheus
Difficulties to display the right information with rate/increase PromQL function - Prometheus - Grafana Labs Community Forums
April 23, 2025 - Hi, I’m having some difficulties to display some values and to interprete them. My setup is : sFlow RT and Prometheus Exporter (to export network metrics in bits/sec) => Prometheus (where metrics are created/filtered)…
🌐
Chris's Wiki
utcc.utoronto.ca › ~cks › space › blog › sysadmin › PrometheusRateVsIrate
rate() versus irate() in Prometheus (and Grafana)
November 5, 2018 - Often when we use either rate() or irate(), we want to graph the result. Graphing means moving through time with query steps and that means we get into interactions between the query step and both the range interval and the function you're using. In particular, as the query step grows large enough, irate() will miss increasingly large amounts of changes.
🌐
DoiT
doit.com › home › blog › making peace with prometheus rate()
Making peace with Prometheus rate() | DoiT
February 17, 2023 - You see, depending on how stars align if our 1-minute range buckets land just on metric change boundaries, there is no change in the metric within that bucket at all and this is exactly why rate(), together with its sister increase(), returns zeroes.