🌐
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

Need help with CPU usage alert Mar 22, 2020
r/PrometheusMonitoring
6y ago
Prometheus query to calculate a ratio between two series Jan 19, 2024
r/PrometheusMonitoring
2y ago
CPU usage VS requests and limits May 7, 2024
r/PrometheusMonitoring
2y ago
Help me understand this metric behaviour May 6, 2025
r/PrometheusMonitoring
last yr.
How can I understand rate() ? Nov 21, 2021
r/grafana
4y ago
More results from reddit.com
🌐
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. ... NOTE: This is only for assumption, we will not create any application and library to setup this architecture. Now, using either the Prometheus UI or Grafana Explore, we can inspect each metric and its corresponding values in real time.
Discussions

Do I understand Prometheus's rate vs increase functions correctly? - Stack Overflow
I have read the Prometheus documentation carefully, but its still a bit unclear to me, so I am here to get confirmation about my understanding. (Please note that for the sake of the simplest examples More on stackoverflow.com
🌐 stackoverflow.com
Why is CPU utilization calculated using irate or rate in Prometheus? - Stack Overflow
I know that CPU utilization is given by the percentage of non-idle time over the total time of CPU. In Prometheus, rate or irate functions calculate the rate of change in a vector array. People o... More on stackoverflow.com
🌐 stackoverflow.com
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

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
🌐
Last9
last9.io › blog › prometheus-rate-function
Prometheus Rate Function: A Practical Guide to Using It | Last9
June 15, 2026 - The key difference is that rate() averages across your entire time range, providing stability at the cost of potentially masking brief spikes, while irate() is more responsive but produces noisier visualizations.
🌐
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. ... irate() - "instantaneous rate of increase" - calculates a per-second increase over the time window, only considering the last ...
🌐
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.
🌐
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 - The most important branch: don’t apply rate() or irate() to a gauge. It produces results that look numeric but are meaningless. Memory usage doesn't have a "rate of increase per second" in the same sense. what you want is the current value or maybe a delta, not a rate. When a Prometheus-instrumented process restarts, its in-process counters reset to zero.
🌐
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
Find elsewhere
🌐
Medium
medium.com › @kavyaprathyusha › rate-vs-irate-in-promql-a172e3d9c38f
rate() vs irate() in promQL - by Kavya Prathyusha Chekka
August 16, 2021 - irate() — It calculates the instant rate of increase of the time series in the range vector. It graphs based on the last two endpoints. Wondering when to use each of these? rate() is generally used when graphing the slow moving counters.
🌐
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 in your Prometheus monitoring setup.
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.

🌐
Promlabs
promlabs.com › blog › 2021 › 01 › 29 › how-exactly-does-promql-calculate-rates
PromLabs | Blog - How Exactly Does PromQL Calculate Rates?
January 29, 2021 - Counters are a Prometheus metric type whose value only goes up, and which represent cumulative total counts like "How many requests have we handled in total?" or "How many seconds have we spent handling requests?". Since the value of a counter depends on the initial (re)start time of a process that tracks and exposes it, the absolute value of a counter is almost never useful. So before graphing or doing anything else with a counter, you typically want to wrap it in a function like rate(), irate(), or increase() to see how fast the counter is going up.
🌐
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])
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › functions
Query functions | Prometheus
irate should only be used when graphing volatile, fast-moving counters. Use rate for alerts and slow-moving counters, as brief changes in the rate can reset the FOR clause and graphs consisting entirely of rare spikes are hard to read.
🌐
Tech Annotation
techannotation.wordpress.com › 2021 › 07 › 19 › irate-vs-rate-whatre-they-telling-you
irate() vs rate() – What're they telling you? - Tech Annotation
July 22, 2021 - It depends on what you’re going to show and what you want to highlight. irate() is more susceptible to data variations, while rate() gives us an overall traffic trend of our application.
Top answer
1 of 2
25

There are a couple of things to unwrap here.

First, rate vs irate. Neither the linked question, nor the blog post address this (but Eitan's answer does touch on it). The difference is that rate estimates the average rate over the requested range (1 minute, in your case) while irate computes the rate based on the last 2 samples only. Leaving aside the "estimate" part (see this answer if you're curious) the practical difference between the 2 is that rate will smooth out the result, whereas irate will return a sampling of CPU usage, which is more likely to show extremes in CPU usage but also more prone to aliasing.

E.g. if you look at Prometheus' CPU usage, you'll notice that it's at a somewhat constant baseline, with a spike every time a large rule group is evaluated. Given a time range that was at least as long as Prometheus' evaluation interval, if you used rate you'd get a more or less constant CPU usage over time (i.e. a flat line). With irate (assuming a scrape interval of 5s) you'd get one of 2 things:

  1. if your resolution (i.e. step) was not aligned with Prometheus' evaluation interval (e.g. the resolution was 1m and the evaluation interval was 13s) you'd get a random sampling of CPU usage and would hopefully see values close to both the highest and lowest CPU usage over time on a graph;
  2. if your resolution was aligned with Prometheus' evaluation interval (e.g. 1m resolution and 15s evaluation interval) then you'd either see the baseline CPU usage everywhere (because you happen to look at 5s intervals set 1 minute apart, when no rule evaluation happens) or the peak CPU usage everywhere (because you happen to look at 5s intervals 1 minute apart that each cover a rule evaluation).

Regarding the second point, the apparent confusion over what the node_cpu_seconds_total metric represents, it is a counter. Meaning it's a number that increments continuously and essentially measures the amount of time the CPU was idle since the exporter started. The absolute value is not all that useful (as it depends on when the exporter started and will drop to 0 on every restart). What's interesting about it is by how much it increased over a period of time: from that you can compute for a given period of time a rate of increase per second (average, with rate; instant, with irate) or an absolute increase (with increase). So both rate(node_cpu_seconds_total{mode="idle"}[1m]) and irate(node_cpu_seconds_total{mode="idle"}[1m]) will give you a ratio (between 0.0 and 1.0) of how much the CPU was idle (over the past minute, and respectively between the last 2 samples).

2 of 2
0

Looks like this is already answered here: Prometheus - Convert cpu_user_seconds to CPU Usage %? Looking at the provided link in the answers: https://www.robustperception.io/understanding-machine-cpu-usage you can see the explanation. Personally, I think that irate in this context makes more sense, as it will show you the average on the last active points (vs. rate which will average the entire sampled timeslot).

🌐
MetricFire
metricfire.com › blog › understanding-the-prometheus-rate-function
How the Prometheus rate() function works | MetricFire
March 12, 2026 - Another function, irate, uses only the first and last data points. You might now say… why not delta()? Well, rate() we have just described has this excellent characteristic: it automatically adjusts for resets.
🌐
DevOps.dev
blog.devops.dev › prometheus-theory-rate-vs-irate-20e6243a3ab8
[Prometheus Theory] rate() vs. irate() | by - DevOps.dev
October 26, 2023 - Subscribe · Subscribe · Remember ... in · The rate() function would average using the first and last data points, averaged over the query interval (1m); whereas the irate() function would average using the last two data points, averaged over the scrape interval (15s)....
🌐
Chris's Wiki
utcc.utoronto.ca › ~cks › space › blog › sysadmin › PrometheusRateVsIrate
rate() versus irate() in Prometheus (and Grafana)
November 5, 2018 - Three out of every four metric points collected by Prometheus are actually the same thing; only every fourth one represents a genuine new data point. Similar things can happen with metrics scraped from Pushgateway.) Obviously, the difference between rate() and irate() basically vanish when the range interval gets sufficiently small.
🌐
Medium
pramodshehan.medium.com › prometheus-counter-metrics-1b0a4cbb79e1
Prometheus Counter metrics. There are three functions to calculate… | by Pramod Shehan | Medium
January 18, 2026 - Grafana Prometheus · Pramod Shehan ... understanding long-term trends. irate()- Calculates the instantaneous per-second rate of increase using only the two most recent samples in the time window....