N.Chandimali
N.Chandimali

Reputation: 799

Set Prometheus Counter value to 0

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

Answers (1)

Sergio Santiago
Sergio Santiago

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

Related Questions