Problem with labels method on metrics objects
See original GitHub issueI am expecting to be able to set labels on a Counter like in the examples:
from prometheus_client import Counter
c = Counter('my_requests_total', 'HTTP Failures', ['method', 'endpoint'])
c.labels(method='get', endpoint='/').inc()
I am using prometheus-client (0.0.14) from PyPI.
$ python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 26 2016, 12:10:39)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from prometheus_client import Counter, CollectorRegistry
>>> reg = CollectorRegistry()
>>> c = Counter('items_total', 'number of items total', registry=reg)
>>> c.labels(first=1, another=2).inc()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Counter' object has no attribute 'labels'
>>>
>>> type(c)
<class 'prometheus_client.core.Counter'>
>>> dir(c)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_reserved_labelnames', '_samples', '_type', '_value', 'collect', 'count_exceptions', 'inc']
The Counter object does not seem to have a labels method attached to it. Perhaps some recent changes has affected the application of the decorator that applies it to the metrics? #99 kind of indicates this same problem but has words relating it to pushgateway.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
The Hardness of Metric Labeling - TTIC
The Metric Labeling problem is an elegant and powerful mathematical model capturing a wide range of classifica- tion problems. The input to the...
Read more >Configure labels on log-based metrics - Google Cloud
All log-based metrics come with some predefined labels: Resource labels: All metrics use a monitored resource object to identify the source of time...
Read more >Metric Labeling and Markov Random Fields
1.2. THE METRIC LABELING PROBLEM. One can make these issues precise in the following way. Consider a set P of n objects that...
Read more >Evaluating Multi-label Classifiers - Towards Data Science
Even for the case we just discussed — multi-label classification — there's another metric called a Hamming Score, which evaluates how close your ......
Read more >Metric Clustering via Consistent Labeling
Our technical approach is to cast a number of metric clustering problems that have been well ... Labeling problem, take both the object...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Usage questions are best asked on https://groups.google.com/forum/#!aboutgroup/prometheus-users
you can try: g = Gauge(‘node_load5_norm’, ‘node_load5_norm’, [“host”], registry=registry) g.labels(hostname).set(value) push_to_gateway(gateway_uri, job=‘pushgateway’, registry=registry)
then: metric like this: node_load5_norm{‘host’=xx} 0.1