The reason behind requiring client libraries to have consistent label per metrics.

16 views
Skip to first unread message

Alvin Lin

unread,
Aug 6, 2020, 5:29:43 PM8/6/20
to Prometheus Users
Hello

In https://prometheus.io/docs/instrumenting/writing_clientlibs/ under the section "Labels" it says 

"Client libraries MUST NOT under any circumstances allow users to have different label names for the same metric for Gauge/Counter/Summary/Histogram or any other Collector offered by the library."

Does anyone know the background behind this rule? My understanding is that Prometheus' data model is that a metrics is uniquely identified by metric name and set of labels, so technically it should be possible to 
have metrics that has the same name but different set of label names. Is the rule to enforce best practice? 

Cheers, 
Alvin 

Brian Brazil

unread,
Aug 6, 2020, 5:47:20 PM8/6/20
to Alvin Lin, Prometheus Users
The set of label names a given metric has should be static, and it's going to be very difficult to write correct PromQL if that's not the case. Generally if someone is asking for this for direct instrumentation they're trying to do event logging rather than metrics, as with metrics you should always know your label names a-priori. 

--
Reply all
Reply to author
Forward
0 new messages