On 16 May 22:41, Julius Volz wrote:
> Hi,
>
> When your input is an absolute value, and one that can reset on you outside
> of your control, it sounds like you are translating existing third-party
> state into a Prometheus metric (rather than being the one in charge of
> counting things as they happen). So you are not looking to track state, but
> just to expose it. For that use case, you would use a custom collector and
> export a constant, throw-away metric for every scrape:
>
https://github.com/prometheus/client_java#custom-collectors
>
> See also
>
https://prometheus.io/docs/instrumenting/writing_exporters/#collectors
>
> Basically, direct instrumentation (with just .add() and no .set()) is for
> when you are the one tracking metrics, not just proxying existing state.
I would also add that a counter can not be set to 0 in Prometheus, nor
downgraded.
In such cases, you will need a Gauge.
https://prometheus.io/docs/concepts/metric_types/
regards,
>
> Cheers,
> Julius
>
> On Sat, May 16, 2020 at 9:19 PM Patrick Hemmer <
patrick...@gmail.com>
> wrote:
>
> > This is a feature request to add a `.set()` method to counters on the java
> > client.
> >
> > Currently java counters only have a `.inc()` method. This is not practical
> > to work with when your input is an absolute value instead of a relative
> > one, and on top of that, when the value can reset to 0 (which prometheus
> > counters do allow).
> >
> > Thanks
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Prometheus Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to
prometheus-use...@googlegroups.com.
> > To view this discussion on the web visit
> >
https://groups.google.com/d/msgid/prometheus-users/be9e8a91-45c5-49fc-96b9-c054fb33d74c%40googlegroups.com
> > <
https://groups.google.com/d/msgid/prometheus-users/be9e8a91-45c5-49fc-96b9-c054fb33d74c%40googlegroups.com?utm_medium=email&utm_source=footer>
> > .
> --
> You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
prometheus-use...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/CAObpH5xMxwm0PkqPJ-qxqsinONXVBF9am7j8Mz6Fjxgn91x-YQ%40mail.gmail.com.
--
Julien Pivotto
@roidelapluie