Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting metric unit to "total" #542

Closed
nritsche opened this issue May 7, 2020 · 3 comments
Closed

Setting metric unit to "total" #542

nritsche opened this issue May 7, 2020 · 3 comments
Labels

Comments

@nritsche
Copy link

nritsche commented May 7, 2020

a4dd93b enforced counters ending in _total, but the unit= parameter doesn't seem to interact well with that. If I pass unit="total" to a Counter, I get a _total_total suffix (but only in some places?).

$ python3.6
Python 3.6.8 (default, Aug  7 2019, 17:28:10) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from prometheus_client import Counter
>>> c = Counter('my_failures', 'Description of counter', unit="total")
>>> c.inc(6.6)
>>> from prometheus_client import start_http_server, Summary
>>> start_http_server(8000)
$ curl localhost:8000/metrics
...
# HELP my_failures_total_total Description of counter
# TYPE my_failures_total_total counter
my_failures_total 6.6
my_failures_created 1.5888939194938827e+09

This is with version 0.7.1.

@nritsche nritsche changed the title Setting metric unit to "_total" Setting metric unit to "total" May 7, 2020
@brian-brazil
Copy link
Contributor

That behaviour sounds correct to me, however total is not a good unit. What are you trying to do?

@nritsche
Copy link
Author

nritsche commented May 8, 2020

Oh, I see. I didn't read this careful enough: https://prometheus.io/docs/practices/naming/. The _total goes behind the unit. Anyways, note that the exposed metric doesn't match it's "HELP" and "TYPE".

@brian-brazil
Copy link
Contributor

That would be a bug, though not something that should arise in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants