Reputation: 799
I want to set Prometheus Counter value to 0 when the server restarts in a manner similar to,
private static final Gauge SERVER_UP = Gauge.build(MetricConstants.SERVER_UP, "Server status").labelNames(labels).register();
Gauge gauge = (Gauge) map.get(SERVER_UP);
gauge.labels(serviceName, serviceType).set(0);
How can this be done with Counter in Prometheus?
Upvotes: 0
Views: 7540
Reputation: 1514
Check this link out. tl;dr; counter is not intended to decrease its value, therefore there are some valid uses cases that were under discussion in this thread.
Their recommendation is to unregister the counter and build a new one as a workaround.
Upvotes: 0