我正在考虑做这样的事情:
counter_name counter
sample_name_of_that_counter_name_1 {'key1'="value1"} 12
sample_name_of_that_counter_name_2 {'key1'="value8",'key2'="value2","key3"="value3"} 23
sample_name_of_that_counter_name_3 {'key4'="value4"} 2
因此,与指标名称相同的计数器将具有不同的标签集(作为键作为值),并因此具有不同的系列。
但是阅读文档让我很困惑。 在一个地方说(https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels):
"Every time series is uniquely identified by its metric name and optional key-value pairs called labels. "
-看来我可以创建一个带有标签:key1 => value1的计数器“ counter_name”,它将创建由counter_name + label确定的时间序列。 然后将使用相同的计数器名称但使用不同的标签创建另一个独特的系列:带有标签的计数器“ counter_name”:“ key1 => value1,key2 => value2”
然后稍后由文档确认:
"Changing any label value, including adding or removing a label, will create a new time series."
但是在同一文档的另一页(https://prometheus.io/docs/instrumenting/writing_clientlibs/#labels)上,我们看到:
"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."
它令人困惑,“如果客户端添加或删除标签-它将创建新的时间序列(具有相同的度量标准名称)”,但同时“绝对不允许”。
有人可以帮忙弄一下吗?