1

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?

DazWilkin
  • 32,823
  • 5
  • 47
  • 88
Oded
  • 336
  • 1
  • 3
  • 17

1 Answers1

2

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(...);
DazWilkin
  • 32,823
  • 5
  • 47
  • 88