prometheus / prometheus/client_python
Discrepancy between metrics names in prometheus and metadata
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 876
- Avg merge
- 8d 4h
- Merged PRs (30d)
- 1
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how Counter names are normalized and how metadata is exposed through /api/v1/metadata, using the two examples in the issue as reproductions. Compare the Prometheus exposition name with the metadata key and add regression coverage showing consistent naming for Counters created with and without the _total suffix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- prometheus, python
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100