Code ::

from prometheus_client import start_http_server, Gauge
import random
from random import randrange

#Latency_Time = Gauge('consumer_gauge_seconds', 'Time spent in consuming 
message')
Latency_Time = Gauge('consumer_gauge_seconds', 'Time spent in consuming 
message', labelnames=['partition'])

@Latency_Time.track_inprogress()
def latency_request(latency):
     Latency_Time.labels('partition', '1').set(latency)
  # Latency_Time.set(latency)

if __name__ == '__main__':
start_http_server(17500)
while True:
latency_request(random.randrange(1900, 2150))


Error Message::

/Users/rahulsinha/anaconda3/envs/envpy37/bin/python 
/Users/rahulsinha/PycharmProjects/pythonProject/prom_pythonclient.py
Traceback (most recent call last):
  File 
"/Users/rahulsinha/PycharmProjects/pythonProject/prom_pythonclient.py", 
line 8, in <module>
    @Latency_Time.track_inprogress()
  File 
"/Users/rahulsinha/anaconda3/envs/envpy37/lib/python3.7/site-packages/prometheus_client/metrics.py",
 
line 377, in track_inprogress
    self._raise_if_not_observable()
  File 
"/Users/rahulsinha/anaconda3/envs/envpy37/lib/python3.7/site-packages/prometheus_client/metrics.py",
 
line 66, in _raise_if_not_observable
    raise ValueError('%s metric is missing label values' % str(self._type))
ValueError: gauge metric is missing label values

Process finished with exit code 1

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/9889a108-a328-4238-8c65-2891b31baf9an%40googlegroups.com.

Reply via email to