prometheus / prometheus/client_python

Discrepancy between metrics names in prometheus and metadata

未关闭
#892 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
4.4k
派生
876
平均合并
8 天 4 小时
30 天内合并 PR
1

描述

Hello,

When creating a Counter metric with client_python 0.4.0 - 0.16.0:

my_metric_count = Counter(name='my_metric_count',
                      documentation='My helpful description',
                      registry=MY_REGISTRY)

The metric will show in prometheus as my_metric_count_total. This is absolutely fine with the world however that same metric will show under http://prometheus:9090/api/v1/metadata as the original name:

    "my_metric_count": [
      {
        "type": "counter",
        "help": "My helpful description",
        "unit": ""
      }
    ],

If one creates the metric with '_total' suffix:

my_metric_count = Counter(name='my_metric_count_total',
                      documentation='My helpful description',
                      registry=MY_REGISTRY)

It will show in prometheus as that exact name my_metric_count_total but the name in the /api/v1/metadata will now be truncated.

    "my_metric_count": [
      {
        "type": "counter",
        "help": "My helpful description",
        "unit": ""
      }
    ],

This breaks certain input plugins with telegraf that rely on the prometheus metadata and remote write to fetch the metric type. Version of this library starting with 0.4.0 exhibit this behavior which is when metrics names began to be munged with '_total' for compatibility with OpenMetrics.

Thank you.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先跟踪 Counter 名称如何被规范化,以及 metadata 如何通过 /api/v1/metadata 暴露,并使用 issue 中的两个示例作为复现。比较 Prometheus exposition name 与 metadata key,并添加回归覆盖,展示使用和不使用 _total 后缀创建的 Counter 的命名一致性。

由索引模型根据 Issue 内容生成。

评估

技术栈
prometheus, python
领域
observability-sre
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
40/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。