I'm new to Prometheus and I have a very basic question.
What is the syntax to add a label to my Metrics? I tried the following:
1. Gauge.build().name(name).labelNames("label"="someLabel").help(helpMsg).register(registry);
2. Gauge.build().name(name).labelNames(label=someLabel).help(helpMsg).register(registry);
4. Gauge.build().name(name).labelNames("someLabel").help(helpMsg).register(registry);
The docs say String value, which I tried...
Someone?
Your question lacks helpful detail to aid answering.
I assume you're using the Java SDK.
Here's the link to the documentation:
https://github.com/prometheus/client_java#labels
It appears you should use:
g = Gauge.build()
.name(name)
.labelNames("someLabel")
.help(helpMsg)
.register(registry);
And then, when you update your gauge (g
), you need to specify the label(s) value(s):
g
.labels("someLabelValue")
.set(...);