prometheus / prometheus/client_python

Discrepancy between metrics names in prometheus and metadata

Đang mở
#892 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
4.4k
Fork
876
Merge trung bình
8 ngày 4 giờ
Pull request đã merge (30 ngày)
1

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách lần theo cách tên của Counter được chuẩn hóa và metadata được cung cấp qua /api/v1/metadata như thế nào, sử dụng hai ví dụ trong issue làm các trường hợp tái hiện. So sánh tên exposition của Prometheus với metadata key và bổ sung phạm vi kiểm thử hồi quy cho thấy cách đặt tên nhất quán đối với các Counter được tạo có và không có hậu tố _total.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
prometheus, python
Lĩnh vực
observability-sre
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
40/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.