On Tue, 6 Oct 2020 at 12:17, John Dexter <[email protected]>
wrote:

> I've been looking at examples in the Java and C++ client libs, and it
> doesn't mirror my understanding of label rules:
> https://github.com/prometheus/client_java#labels
>
> I thought:
>
>    1. each metric could have zero or more named labels
>    2. each label must have a pre-determined set of allowed values
>
>
This is a should, not a must. Sometimes you just can't know in advance what
the label values would be.


>
>    1. when setting a metric value, all label dimensions *must* be
>    specified from these allowed values
>
>
And accordingly here this is also a should.


> But the examples don't work that way:
> Counter calculationsCounter = Counter.build()
> .name("my_library_calculations_total").help("Total calls.")
> .labelNames("key").register();
> ...
>   void processThatCalculates(String key) {
> calculationsCounter.labels(key).inc(); // Run calculations. } }
>
> In this example, I don't see where "key" allowed values are enumerated. I
> also don't see how labels(key) knows which label it is referring to. I
> might have multiple labels.
>

labels takes a varidic of strings, which matches the order of labels you
passed to labelNames.

Brian


>
> I wish I could find a non-trivial example which shows what the output
> scrape would look like. Can anyone help?
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-users/f221c413-04cf-495b-9ae5-2d825477bab7n%40googlegroups.com
> <https://groups.google.com/d/msgid/prometheus-users/f221c413-04cf-495b-9ae5-2d825477bab7n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Brian Brazil
www.robustperception.io

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/CAHJKeLrL03o5qpY69U0JZb0sc%3DgKXoiDKnQBj10k0SPByHGYQg%40mail.gmail.com.

Reply via email to