在 Grafana Prometheus 源代码中使用标签作为指标
Use label as metric in Grafana Prometheus source
大家好我有prometheus作为标签returns额。度量值是付款次数。我如何将一天的总金额提取到仪表板?即 value_metric*总和
据我所知,没有办法做到这一点,因为标签不应该用于计算。标签及其值本质上是 Prometheus 的 NoSQL TSDB 的索引,它们用于创建关系并将数据片段连接在一起。您不会存储值并使用关系数据库的列名进行数学运算,对吗?
另一个问题是具有高基数的标签会大大增加数据库的大小。这是来自 Prometheus best practices 的摘录:
CAUTION: Remember that every unique combination of key-value label pairs represents a new time series, which can dramatically increase the amount of data stored. Do not use labels to store dimensions with high cardinality (many different label values), such as user IDs, email addresses, or other unbounded sets of values.
虽然我看到您在标签中使用了一些固定值,但也许 histogram 会满足您的需要。
大家好我有prometheus作为标签returns额。度量值是付款次数。我如何将一天的总金额提取到仪表板?即 value_metric*总和
据我所知,没有办法做到这一点,因为标签不应该用于计算。标签及其值本质上是 Prometheus 的 NoSQL TSDB 的索引,它们用于创建关系并将数据片段连接在一起。您不会存储值并使用关系数据库的列名进行数学运算,对吗?
另一个问题是具有高基数的标签会大大增加数据库的大小。这是来自 Prometheus best practices 的摘录:
CAUTION: Remember that every unique combination of key-value label pairs represents a new time series, which can dramatically increase the amount of data stored. Do not use labels to store dimensions with high cardinality (many different label values), such as user IDs, email addresses, or other unbounded sets of values.
虽然我看到您在标签中使用了一些固定值,但也许 histogram 会满足您的需要。