Search code examples
prometheus

Gauge function and counter function


I know that some functions are belong to gauge and some of them are for counter and we would get the wrong result if we don't use them correctly. I search in the net but i didn't find any good result or resource for this. I would appreciate if anyone can help me to find the good resource for finding out which functions we can use for gauges and which one for counter.


Solution

  • Functions that accept range-vector as an argument might might be specifically designed to be used with counter metrics. This comes down to the presence of mechanism to account for counter resets.

    Following functions have said mechanism:

    • increase()
    • irate()
    • rate()
    • resets()

    18 other functions accepting range-vectors don't have mentioned mechanism.

    But it's important to understand, that all these functions, both accounting for resets and not, can be used for both counters and gauges, if you understand what you are doing.


    Functions that take instant-vector as an argument can always be used with both gauges and counters.


    Documentation for functions in Prometheus.