Counters and Gauges allow for labels to be added to them. When I try to add labels to a Summary, I get an "incorrect number of labels" error.
This is what I'm trying:
private static final Summary latencySummary = Summary.build()
.name("all_latencies")
.help("all latencies.")
.register();
latencySummary.labels("xyz_api_latency").observe(timer.elapsedSeconds());
I've looked at the Summary github source code, but can't find the answer. How are labels added to a Summary?
A label is a certain attribute of a metric. Generally, labels are populated by metric producers (servers in the example above). However, in Prometheus, it's possible to enrich a metric with some static labels based on the producer's identity while recording it on the Prometheus node's side.
Getting the meaning and type of a metric name This information is not directly accessible via PromQL, but the Prometheus server keeps it in memory for each target and it can be queried via another metadata API endpoint. For example: https://demo.promlabs.com/api/v1/metadata.
You need to provide the labelname in the metric:
private static final Summary latencySummary = Summary.build()
.name("latency_seconds")
.help("All latencies.")
.labelNames("api")
.register();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With