Counter Range Vectors

Just as there are functions for ranges of gauges, there are functions for ranges of counters. These all return instant vectors.


rate() calculates per-second increase of a counter, allowing for resets and extrapolating at edges to provide better results.

This is the most common function you will use in PromQL.


increase() is syntactic sugar around rate(), it returns the increase across the period. So increase(metric[1h]) is the per-hour increase. Only use increase() for display, use rate() in rules and alerts.


irate() only looks at the last two data points and returns the per-second rate. It produces very responsive graphs, but doesn't do well for alerting or longer time frames.


resets() counts the number of counter resets. Useful mostly for debugging. If you want to track how often a process restarts, a timestamp gauge and changes() is better.


It is recommended to use a range of at least 4x the scrape_interval with range vector functions, so as to be resilient to failed scrapes. For example for a 10s scrape_interval you would usually use at least a 30s range, such as rate(my_counter_total[30s]).


A counter before applying rate():

The same counter after applying rate():


Complete and Continue