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') # This code works without label
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). # I know there is
something wrong here.. I'm not able to figure out what !
# Latency_Time.set(latency) # This code works
without label
if __name__ == '__main__':
start_http_server(17500)
while True:
latency_request(random.randrange(1900, 2150))
On Wednesday, 2 June 2021 at 17:04:04 UTC+8 Rahul Sinha wrote:
> 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/2e844b18-8671-4f20-bc4d-721f432d703an%40googlegroups.com.