Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prometheus max limit for counters

Tags:

prometheus

When using counters in prometheus, would we ever hit the problem of reaching the max limit for the counter (assuming the application never restarts) ? If so, would it affect the underlying application that is trying to expose the metric or would it be taken care by prometheus?

like image 212
sathyz Avatar asked Oct 31 '25 04:10

sathyz


1 Answers

If you take a look at the declaration of counter metrics type from prometheus/client_golang.

type counter struct {
    // valBits contains the bits of the represented float64 value, while
    // valInt stores values that are exact integers. Both have to go first
    // in the struct to guarantee alignment for atomic operations.
    // http://golang.org/pkg/sync/atomic/#pkg-note-BUG
    valBits uint64
    valInt  uint64

    selfCollector
    desc *Desc

    labelPairs []*dto.LabelPair
}

They used unsigned int64 type for valInt counter. So once it exceeds the limit of int64, it will be set to zero again. I guess it will be similar for other client libraries too.

like image 59
Kamol Hasan Avatar answered Nov 02 '25 23:11

Kamol Hasan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!