Prometheus Counter Zero Initialisation Problem #952
Replies: 3 comments 5 replies
-
Currently it is expected that you manually initialize counters, I believe this can be done just by calling That said I would not be opposed to building something that makes this easier when the labelset is known ahead of time. An easy solution may also help people who don't know about this issue. |
Beta Was this translation helpful? Give feedback.
-
Thanks @csmarchbanks we do have a proposal for this using the zero injection method https://github.com/prometheus/proposals/blob/main/proposals/2023-06-13_created-timestamp.md Until then, I am planning to manually do the zero init as you recommended i.e. my_counter.labels(**tags).
Will this work out ? or do I need to delay the actual increment (by value) to ensure it happens after the zero value has been scraped and sent to mimir I will experiment with this, putting it out here for any interesting insights from you |
Beta Was this translation helpful? Give feedback.
-
I was discussing this with folks from Prometheus (the team that has come up with the zero injection solution) here https://cloud-native.slack.com/archives/C167KFM6C/p1698243223038169 The challenge here is that Prometheus needs to scrape the target when the value is zero i.e before the subsequent increment happens and I cannot guarantee that without either a 'delay' or the 'push zero' idea proposed in that thread. I am still thinking about it. |
Beta Was this translation helpful? Give feedback.
-
Hi Folks,
Do we have anything in the Python client lib to circumvent the classic Zero Initialization Problem in Prometheus Counters or is it expected from to implement the recommendation by manually initing all time-series with ZERO
https://prometheus.io/docs/practices/instrumentation/#avoid-missing-metrics
https://groups.google.com/g/prometheus-users/c/w69L7w6Z5y0
https://docs.google.com/document/d/1kakDVn8aP1JerimLeazuMfy2jaB14W2kZDHMRokPcv4/edit
prometheus/client_golang#1313 - Go Client
prometheus/client_ruby#141 - Ruby Client
https://www.section.io/blog/beware-prometheus-counters-that-do-not-begin-at-zero/
https://github.com/goto-opensource/smart-prometheus-client
Beta Was this translation helpful? Give feedback.
All reactions