siimon / prom-client

Prometheus client for node.js
Apache License 2.0
3.14k stars 376 forks source link

Ability to explicitly set the counter value? #618

Open MA-MacDonald opened 7 months ago

MA-MacDonald commented 7 months ago

Is there a way to explicitly set the counter value besides the increment function?

I have a service that gets it data from an external API which already returns the incremented count value.

After reading the docs the only option I see would be to reset the counter every time I record the new value.

I guess it's similar to this past Issue. https://github.com/siimon/prom-client/issues/534

It feels wrong to use a Gauge since its technically a count metric but i guess I don't fully know the implications of using the incorrect metric type or if it really matters?

pradig commented 6 months ago

Same problem here, my underpinning value is a monotonic increasing value, but I do not get the increments, just the new value. I would to set() it, not to inc() it.