🌐
Reddit
reddit.com › r/prometheusmonitoring › avoid reading zero values after a restart
r/PrometheusMonitoring on Reddit: Avoid reading zero values after a restart
February 3, 2022 -

Is there a way to avoid reading zero values? This is my problem:

  • Lets say that I have a prometheus gauge that I update every few minutes with some number n.

  • Now let's say that I restart my software. Right after restarting, the value of the gauge will take a default value 0 because n hasn't been set yet.

  • Before n is set, prometheus reads the gauge value, which is 0

  • Is there way to make prometheus wait until the gaguge value is set?

I could also just filter out 0 values, but 0 can be also a valid value.

Counter reset after target restart Feb 22, 2023
r/PrometheusMonitoring
3y ago
Use Label Value as Returned Value Jun 20, 2024
r/PrometheusMonitoring
2y ago
Prometheus Counters - and how to deal with them May 20, 2019
r/PrometheusMonitoring
7y ago
More results from reddit.com
🌐
Stack Overflow
stackoverflow.com › questions › 54827960 › gauge-metric-initialisation
prometheus - Gauge Metric Initialisation - Stack Overflow
I can't speak for the creators of Prometheus, but 0 sounds like a reasonable default for anything. (Meaning it's more reasonable for a gauge to start at 0 than any other value, possibly excluding NaN.)
Discussions

question about initial gauge/counter values
(r@turbot)4> prometheus_gauge:... ok (r@turbot)9> prometheus_gauge:reset("name"). true (r@turbot)10> prometheus_gauge:value("name"). 0 · I expected the metric to be created with the default value, and also that reset would always work.... More on github.com
🌐 github.com
4
September 15, 2016
Gauge without label should not have a default value of 0 (zero)
A gauge that is registered but does not have a value set is currently set to 0 (zero). I believe this behavior to be incorrect because a gauge without a label does not work like it. const client = ... More on github.com
🌐 github.com
4
March 27, 2024
Gauge, counter or rates
The point of Prometheus is you only have to implement a counter and then Prometheus functions will derive the rate or delta if you need it. More on reddit.com
🌐 r/PrometheusMonitoring
7
3
May 17, 2023
How to add more information to Prometheus Gauge?
Are you adding the metrics into the running process? Or outside? You can use a label and store something like Resourcepath=“/cluster/ns-1/ns-pod-1/ns-pod-1-proc-1” https://prometheus.io/docs/practices/naming/ Later on when querying you can aggregate by prefixes Alternatively you can use multiple labels cluster_name, ns_name pod_name and proc_name. Fill them in setting the gauge, etc Good luck! More on reddit.com
🌐 r/PrometheusMonitoring
1
0
March 2, 2020
🌐
Prometheus
prometheus.io › docs › concepts › metric_types
Metric types | Prometheus
Gauges are typically used for measured values like temperatures or current memory usage, but also "counts" that can go up and down, like the number of concurrent requests.
🌐
GitHub
github.com › deadtrickster › prometheus.erl › issues › 37
question about initial gauge/counter values · Issue #37 · prometheus-erl/prometheus.erl
September 15, 2016 - (r@turbot)4> prometheus_gauge:... ok (r@turbot)9> prometheus_gauge:reset("name"). true (r@turbot)10> prometheus_gauge:value("name"). 0 · I expected the metric to be created with the default value, and also that reset would always work....
Author: prometheus-erl
🌐
Tom Gregory
tomgregory.com › how-and-when-to-use-a-prometheus-gauge
How and when to use a Prometheus gauge | Tom Gregory
February 5, 2021 - the gauge is then registered with a CollectorRegistry, the central store in your application for Prometheus metrics · when an item is added to the queue, the gauge can be incremented. The label value must also be passed at this point. likewise, when an item is read from the queue the gauge can be decremented, also passing the label value · By default Prometheus scrapes any configured targets once every minute.
🌐
InfluxData Documentation
docs.influxdata.com › flux › v0 › prometheus › metric-types › gauge
Work with Prometheus gauges - InfluxData Documentation
November 6, 2023 - Use Flux to query and transform Prometheus gauge metrics stored in InfluxDB. A gauge is a metric that represents a single numerical value that can arbitrarily go up and down.
🌐
GitHub
github.com › prometheus › client_js › issues › 622
Gauge without label should not have a default value of 0 (zero) · Issue #622 · prometheus/client_js
March 27, 2024 - A gauge that is registered but does not have a value set is currently set to 0 (zero). I believe this behavior to be incorrect because a gauge without a label does not work like it. const client = require('prom-client'); const gauge = ne...
Author: prometheus
🌐
client_python
prometheus.github.io › client_python › instrumenting › gauge
Gauge | client_python
April 24, 2026 - A Gauge tracks a value that can go up and down. Use it for things you sample at a point in time — active connections, queue depth, memory usage, temperature. from prometheus_client import Gauge g = Gauge('my_inprogress_requests', 'Description of gauge') g.inc() # Increment by 1 g.dec(10) # Decrement by given value g.set(4.2) # Set to a given value Constructor Gauge(name, documentation, labelnames=(), namespace='', subsystem='', unit='', registry=REGISTRY, multiprocess_mode='all') Parameter Type Default Description name str required Metric name. documentation str required Help text shown in the /metrics output and Prometheus UI. labelnames Iterable[str] () Names of labels for this metric.
Find elsewhere
🌐
Last9
last9.io › blog › prometheus-gauges-vs-counters
Prometheus Gauges vs Counters: What to Use and When | Last9
February 21, 2026 - If a gauge isn’t reinitialized, Prometheus may continue scraping an outdated value or drop the time series altogether, depending on scrape timing. ... Always set gauges on startup. Don’t assume zero is the default.
🌐
Jupp0r
jupp0r.github.io › prometheus-cpp › classprometheus_1_1Gauge.html
Prometheus Client Library for Modern C++: prometheus::Gauge Class Reference
A gauge metric to represent a value that can arbitrarily go up and down. The class represents the metric type gauge: https://prometheus.io/docs/concepts/metric_types/#gauge
🌐
Mirage
mirage.github.io › prometheus › prometheus › Prometheus › Gauge › index.html
Gauge (prometheus.Prometheus.Gauge)
v_labels ~label_names ~help ~namespace ~subsystem name is a family of metrics with full name namespace_subsystem_name and documentation string help. Each metric in the family will provide a value for each of the labels. The new family is registered with registry (default: CollectorRegistry.default).
🌐
HexDocs
hexdocs.pm › prometheus_ex › Prometheus.Metric.Gauge.html
Prometheus.Metric.Gauge — Prometheus.ex v5.1.0
Raises Prometheus.UnknownMetricError exception if a gauge for spec can't be found.<br> Raises Prometheus.InvalidMetricArityError exception if labels count mismatch. Sets the gauge identified by spec to value.
🌐
Prometheus
prometheus.io › docs › practices › instrumentation
Instrumentation | Prometheus
Time series that are not present until something happens are difficult to deal with, as the usual simple operations are no longer sufficient to correctly handle them. To avoid this, export a default value such as 0 for any time series you know may exist in advance.
🌐
OneUptime
oneuptime.com › home › blog › how to create prometheus gauge patterns
How to Create Prometheus Gauge Patterns
January 30, 2026 - When dealing with gauges, timestamps become important for understanding when a value was observed. Prometheus assigns the scrape timestamp to all metrics by default, but sometimes you need to handle stale data or external timestamps.
🌐
Prometheus
prometheus.io › docs › instrumenting › writing_clientlibs
Writing client libraries | Prometheus
There SHOULD be a way to initialize a given Child with the default value, usually just calling labels(). Metrics without labels MUST always be initialized to avoid problems with missing metrics. Metric names must follow the specification. As with label names, this MUST be met for uses of Gauge/Counter/Summary/Histogram and in any other Collector offered with the library.
🌐
GitHub
github.com › prometheus › client_python › issues › 404
push_to_gateway resets gauges if declared globally · Issue #404 · prometheus/client_python
May 8, 2019 - Hello everyone! I found that if I declare gauge_foo = Gauge( 'foo', 'Gauge Foo', registry=prometheus_registry, ) and then call push_to_gateway, it will send 0 value for the gauge to the push gateway. I gave a quick look in the code https...
Author: prometheus
🌐
Go Packages
pkg.go.dev › github.com › prometheus › client_golang › prometheus
prometheus package - github.com/prometheus/client_golang/prometheus - Go Packages
July 24, 2026 - A Gauge is typically used for measured values like temperatures or current memory usage, but also "counts" that can go up and down, like the number of running goroutines. To create Gauge instances, use NewGauge. ... package main import ( "github.com/prometheus/client_golang/prometheus" ) func main() { opsQueued := prometheus.NewGauge(prometheus.GaugeOpts{ Namespace: "our_company", Subsystem: "blob_storage", Name: "ops_queued", Help: "Number of blob storage operations waiting to be processed.", }) prometheus.MustRegister(opsQueued) // 10 operations queued by the goroutine managing incoming requests.
🌐
LinkedIn
linkedin.com › pulse › 4-types-prometheus-metrics-tom-gregory
The 4 Types Of Prometheus Metrics
December 27, 2019 - Info: by default Prometheus includes the configured help text and metric type for informational purposes · We can use the following query to calculate the per second rate of requests averaged over the last 5 minutes: ... Info: the rate function calculates the per second rate of increase averaged over the provided time interval. It can only be used with counters. The gauge metric type can be used for values that go down as well as up, such as current memory usage or the number of items in a queue.
🌐
Better Stack
betterstack.com › community › guides › monitoring › prometheus-metrics-explained
A Practical Guide to Prometheus Metric Types | Better Stack Community
Prometheus offers four core metric types to capture diverse system behaviors: Counters for tracking ever-increasing values, like the total number of exceptions thrown. Gauges for measuring fluctuating values, such as current CPU usage.
🌐
Dash0
dash0.com › home › knowledge base › understanding the prometheus metric types
Understanding the Prometheus Metric Types · Dash0
July 21, 2025 - This set() approach should be preferred for measuring stateful values like the number of items in a queue or current memory usage. By periodically checking the actual source of truth, your gauge remains stateless and self-correcting. Most Prometheus’ clients also allow you to use inc()Copy and dec()Copy for incrementing and decrementing a gauge respectively.