When I was checking the Prometheus github issues, I stumbles upon this line of code that basically resets the gauge.

YOUR_GAUGE._metrics.clear()
Answer from RonZhang724 on Stack Overflow
🌐
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. Resets the value of the gauge identified by spec.
🌐
Chris's Wiki
utcc.utoronto.ca › ~cks › space › blog › sysadmin › PrometheusResetsFunction
Some uses for Prometheus's resets() function
But you may not always have that data, especially in a Prometheus metric.) Applying resets() to a continuous metric that counts up until something happens will obviously tell you how many times that thing has happened over your time range. However, most counter metrics are associated with more directly usable indicators of things like host reboots or process restarts, and most gauge ...
🌐
Prometheus
prometheus.io › docs › concepts › metric_types
Metric types | Prometheus
A counter is a cumulative metric ... or be reset to zero on restart. For example, you can use a counter to represent the number of requests served, tasks completed, or errors. Do not use a counter to expose a value that can decrease. For example, do not use a counter for the number of currently running processes; instead use a gauge...
🌐
GitHub
github.com › envoyproxy › envoy › issues › 10806
Inconsistent gauges after hot-restart on endpoints /clusters and /stats/prometheus · Issue #10806 · envoyproxy/envoy
April 16, 2020 - Description: After hot-restart, gauges, especially upstream_cx_active on /stats/prometheus endpoint, do not reset themselves. Values from previous instances are added to current. Sending POST to /reset_counters does not reset gauges eith...
Author: envoyproxy
🌐
Reddit
reddit.com › r/prometheusmonitoring › what is the correct way to reset combinations of labels to 0 in a gauge?
r/PrometheusMonitoring on Reddit: What is the correct way to reset combinations of labels to 0 in a gauge?
September 9, 2023 - The issue I'm running into is: on every tick of my worker manager, I want to update the gauge based on my database. However, if there is a missing combination (e.g, "no Foo workers with the label starting") -- then I should set that combination to 0 to indicate that there are no "Foo" workers that are starting.
🌐
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 gatewa...
Author: prometheus
Find elsewhere
🌐
Google Groups
groups.google.com › g › prometheus-users › c › gpEYVmtMqAU
/metrics lifecycle
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/663233c1-7bdf-4903-9aa2-d7dce327a27bn@googlegroups.com. ... Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message ... A call to /metrics should always return the "current" value of every metric. For counters (which are generally recommended) they always increase and therefore only reset to zero if the application itself is restarted. For gauges the ideal situation is that the scraping request returns the live value of those metrics.
🌐
GitHub
github.com › deadtrickster › prometheus.erl › issues › 37
question about initial gauge/counter values · Issue #37 · prometheus-erl/prometheus.erl
September 15, 2016 - ok (r@turbot)9> prometheus_gauge:reset("name"). true (r@turbot)10> prometheus_gauge:value("name").
Author: prometheus-erl
🌐
GitHub
github.com › prometheus-net › prometheus-net › issues › 63
Counter allows no way to reset to zero · Issue #63 · prometheus-net/prometheus-net
October 27, 2017 - It's my understanding that the Prometheus server itself does this math. The documentation at https://prometheus.io/docs/instrumenting/writing_clientlibs/ allows client libraries to offer a method to reset Counter values to zero.
Author: prometheus-net
🌐
GitHub
github.com › prometheus › statsd_exporter › issues › 83
Metric expiry/reset · Issue #83 · prometheus/statsd_exporter
August 2, 2017 - statsd will automatically reset counters when publishing to graphite and i'm looking for a similar feature in the exporter too. Did i miss the settings for this or isn't this available? Currently we use counters which get reset on every ...
Author: prometheus
🌐
Last9
last9.io › blog › prometheus-gauges-vs-counters
Prometheus Gauges vs Counters: What to Use and When | Last9
February 21, 2026 - Before getting into implementation, it’s worth understanding the most frequent (and costly) misuse patterns developers run into when working with Prometheus gauges: Treating gauges like counters Using Inc() to track events — such as HTTP requests — breaks reset detection and invalidates rate() or increase() calculations.
🌐
GitHub
github.com › prometheus › prometheus › issues › 11433
Prometheus does not detect counter resets (using increase() or resets()) · Issue #11433 · prometheus/prometheus
October 7, 2022 - What did you do? I have a counter like the following, scraped from a Shelly Plug, counting watthours. Whenever I unplug the Shelly (or on power outage), the counter starts with 0. # HELP shelly_met...
Author: prometheus
🌐
Robust Perception
robustperception.io › how-does-a-prometheus-gauge-work
How does a Prometheus Gauge work? – Robust Perception | Prometheus Monitoring Experts
December 26, 2016 - The Prometheus gauge is essentially the same simple idea as gauges in other monitoring systems. Gauges can go up and down over time, and scrapes take a snapshot of the current value. There's no potential for messing around with moving averages or resets, as there is with counters.
🌐
Better Stack
betterstack.com › community › questions › how-to-manage-prometheus-counters
How To Manage Prometheus Counters | Better Stack Community
November 29, 2024 - Counters are designed to reset only when the application restarts. Prometheus does not allow manual resets for counters to prevent misrepresentation of data. If you need a reset-like behavior, consider using a gauge instead.
🌐
GitHub
github.com › prometheus › client_python › issues › 277
How to clear a particular metric's all labels and values · Issue #277 · prometheus/client_python
May 26, 2018 - According to the prometheus documentation in the below link, https://prometheus.io/docs/instrumenting/writing_clientlibs/#labels · Metrics with labels SHOULD support a remove() method with the same signature as labels() that will remove a Child from the metric no longer exporting it, and a clear() method that removes all Children from the metric. These invalidate caching of Children. This seems to be missing in this python library. my_gauge_metric = Gauge(..) my_gauage_metric._metrics.clear() would do the job, but I felt little discomfort in using underscore variables outside.
Author: prometheus
🌐
ADHDecode
adhdecode.com › articles › prometheus › prometheus-metric-types-counter-gauge-histogram
Prometheus Metric Types: Counter, Gauge, Histogram (2026) | ADHDecode
They calculate the rate based on the increase since the last scrape and add the difference from the scrape before that to account for the reset. This allows you to get a consistent, accurate rate of events even across application restarts. The Gauge metric type, on the other hand, represents a value that can go up and down.
🌐
Robust Perception
robustperception.io › how-does-a-prometheus-counter-work
How does a Prometheus Counter work? – Robust Perception | Prometheus Monitoring Experts
April 8, 2016 - Any time a counter appears to decrease it'll be treated as though there was a reset to 0 right after the first data point. This makes it important that it not be possible for Counters to be decremented, a Counter that has the potential to be decremented is in reality a Gauge.