🌐
GitHub
github.com › prometheus › client_python › discussions › 910
[Question] Pushing gauge metric with label · prometheus/client_python · Discussion #910
Realized the issue was that g.set_to_current_time() should be g.labels("mylabel="testing").set_to_current_time() as well to make this work · Beta Was this translation helpful? Give feedback. ... There was an error while loading. Please reload this page. Something went wrong. There was an error while loading. Please reload this page. ... registry = CollectorRegistry() g = Gauge('my_metric', 'Description of my_metric', labelnames=['ln'], registry=registry) g.labels(ln='labelvalue').set(32)
Author: prometheus
🌐
client_python
prometheus.github.io › client_python › instrumenting › gauge
Gauge | client_python
April 24, 2026 - A Gauge tracks a value that can go up and down. Use it for things you sample at a point in time — active connections, queue depth, memory usage, temperature. from prometheus_client import Gauge g = Gauge('my_inprogress_requests', 'Description of gauge') g.inc() # Increment by 1 g.dec(10) # Decrement by given value g.set(4.2) # Set to a given value Constructor Gauge(name, documentation, labelnames=(), namespace='', subsystem='', unit='', registry=REGISTRY, multiprocess_mode='all') Parameter Type Default Description name str required Metric name. documentation str required Help text shown in the /metrics output and Prometheus UI. labelnames Iterable[str] () Names of labels for this metric.
Discussions

Python. prometheus_client ValueError: gauge metric is missing label values - Stack Overflow
I try to use prometheus_client for export RabbitMQ metrics. I have a problem with decorator functions. #!/usr/bin/env python3 # -*- coding: utf-8 -*- #from prometheus_client import start_http_serv... More on stackoverflow.com
🌐 stackoverflow.com
Missing gauge metrics for labels only used in subprocess
When using the multiprocess collector and gauges, the exposed metrics only list those gauges that have labels set in the parent process. Output of test case: # HELP some_gauge Multiprocess metric # TYPE some_gauge gauge some_gauge{labeln... More on github.com
🌐 github.com
4
August 7, 2019
Initializing a metric with a tuple for labels leads to incorrect label count
g = prometheus_client.Gauge( "my_super_special_metric", "This is ametric", ["label"]) g.labels({"label" : "somevalue"}).set(1) ... Since both are iterable types, it would be idiomatic python to ensure that any non-string sequence type supplied for the labels be treated as a list of labels. More on github.com
🌐 github.com
5
August 25, 2015
Cannot initialize Gauge label values with exception
When trying to initialise label values for a Gauge like so (following examples in Readme): from prometheus_client import Gauge sample_gauge = Gauge(name='example', documentation='Some d... More on github.com
🌐 github.com
7
January 26, 2021
🌐
Stack Overflow
stackoverflow.com › questions › 73785963 › prometheus-client-how-to-specify-a-list-of-labels
Prometheus-client : how to specify a list of labels - Stack Overflow
I use prometheus client, but have issues specifying the correct label values, corresponding to a metric I just created. import pprint from prometheus_client import Gauge # --- At one location, a specific set of labels is defined for a metric.
🌐
client_python
prometheus.github.io › client_python › instrumenting › labels
Labels | client_python
April 9, 2026 - All metrics can have labels, allowing grouping of related time series. See the best practices on naming and labels. Taking a counter as an example: from prometheus_client import Counter c = Counter('my_requests_total', 'HTTP Failures', ['method', 'endpoint']) c.labels('get', '/').inc() ...
🌐
ProgramCreek
programcreek.com › python › example › 105491 › prometheus_client.Gauge
Python Examples of prometheus_client.Gauge
def setUp(self): self.registry = prometheus_client.CollectorRegistry() self.some_gauge = prometheus_client.Gauge( "some_gauge", "Some gauge.", registry=self.registry ) self.some_gauge.set(42) self.some_labelled_gauge = prometheus_client.Gauge( "some_labelled_gauge", "Some labelled gauge.", ["labelred", "labelblue"], registry=self.registry, ) self.some_labelled_gauge.labels("pink", "indigo").set(1) self.some_labelled_gauge.labels("pink", "royal").set(2) self.some_labelled_gauge.labels("carmin", "indigo").set(3) self.some_labelled_gauge.labels("carmin", "royal").set(4) self.test_case = SomeTestCase()
🌐
Prometheus
prometheus.io › docs › instrumenting › writing_clientlibs
Writing client libraries | Prometheus
Generated/dynamic metric names are a sign that you should be using labels instead. Gauge/Counter/Summary/Histogram MUST require metric descriptions/help to be provided. Any custom Collectors provided with the client libraries MUST have descriptions/help on their metrics.
🌐
Pub.dev
pub.dev › documentation › prometheus_client › latest › prometheus_client › Gauge-class.html
Gauge class - prometheus_client library - Dart API
Construct a new Gauge with a name, help text and optional labelNames. If labelNames are provided, use labels(...) to assign label values.
🌐
GitHub
github.com › prometheus › client_python › discussions › 896
Questions about Gauge labels · prometheus/client_python · Discussion #896
I would like to ask if it is possible to customize the label. The example is as follows metrics_one = prometheus_client.Gauge("mysql_data", "mysql_data", ["label1", "label2", "label3", "label4", "label5", "label6"]) metrics_two = prometheus_client.Gauge("mysql_data", "mysql_data", ["label1", "label2", ]) metrics_three = prometheus_client.Gauge("mysql_data", "mysql_data", ["label1", "label3", ]) metrics_four = prometheus_client.Gauge("mysql_data", "mysql_data", ["label1", "label2", "label4" ])
Author: prometheus
Find elsewhere
🌐
GitHub
github.com › prometheus › client_python › issues › 446
Missing gauge metrics for labels only used in subprocess · Issue #446 · prometheus/client_python
August 7, 2019 - When using the multiprocess collector and gauges, the exposed metrics only list those gauges that have labels set in the parent process. Output of test case: # HELP some_gauge Multiprocess metric # TYPE some_gauge gauge some_gauge{labeln...
Author: prometheus
🌐
PyPI
pypi.org › project › prometheus-client › 0.14.0
Prometheus Python Client
The client also automatically exports some metadata about Python. If using Jython, metadata about the JVM in use is also included. This information is available as labels on the python_info metric. The value of the metric is 1, since it is the labels that carry information. There are several options for exporting metrics. Metrics are usually exposed over HTTP, to be read by the Prometheus server.
      » pip install prometheus-client
    
Published: Apr 05, 2022
Version: 0.14.0
🌐
GitHub
github.com › prometheus › client_python › issues › 38
Initializing a metric with a tuple for labels leads to incorrect label count · Issue #38 · prometheus/client_python
August 25, 2015 - g = prometheus_client.Gauge( "my_super_special_metric", "This is ametric", ["label"]) g.labels({"label" : "somevalue"}).set(1) works normally. Since both are iterable types, it would be idiomatic python to ensure that any non-string sequence type supplied for the labels be treated as a list of labels.
Author: prometheus
🌐
Google Groups
groups.google.com › g › prometheus-developers › c › 7JrCXo8iNlg
How to set multiple label values with using tuple or list to gauge object?
September 13, 2017 - labels_values = [u'Admin Tenant', u'RE-P01-IN01-C', u'us-west-1', u'Web Services', u'Admin Tenant', u'SXPServerHealthCheck', u'SO Server', u'mon...@cscloud.com', u'PR01', u'SXPServerHealthCheck'] ... File "/Library/Python/2.7/site-packages/prometheus_client/core.py", line 516, in labels raise ValueError('Incorrect label count') ValueError: Incorrect label count
🌐
Google Groups
groups.google.com › g › prometheus-users › c › 6Orp-M80K2o
prometheus_client with labels is not working
June 2, 2021 - 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)) ... /Users/rahulsinha/anaconda3/envs/envpy37/bin/python /Users/rahulsinha/PycharmProjects/pythonProject/prom_pythonclient.py ... File "/Users/rahulsinha/anaconda3/envs/envpy37/lib/python3.7/site-packages/prometheus_client/metrics.py", line 377, in track_inprogress
🌐
GitHub
github.com › prometheus › client_python › blob › master › prometheus_client › metrics_core.py
client_python/prometheus_client/metrics_core.py at master · prometheus/client_python
labels: Optional[Sequence[str]] = None, unit: str = '', ): Metric.__init__(self, name, documentation, 'gaugehistogram', unit) if labels is not None and buckets is not None: raise ValueError('Can only specify at most one of buckets and labels.') if labels is None: labels = [] self._labelnames = tuple(labels) if buckets is not None: self.add_metric([], buckets, gsum_value) ·
Author: prometheus
🌐
Tom Gregory
tomgregory.com › how-and-when-to-use-a-prometheus-gauge
How and when to use a Prometheus gauge | Tom Gregory
February 5, 2021 - the gauge is then registered with a CollectorRegistry, the central store in your application for Prometheus metrics · when an item is added to the queue, the gauge can be incremented. The label value must also be passed at this point.
🌐
GitHub
github.com › prometheus › client_python › issues › 614
Cannot initialize Gauge label values with exception · Issue #614 · prometheus/client_python
January 26, 2021 - When trying to initialise label values for a Gauge like so (following examples in Readme): from prometheus_client import Gauge sample_gauge = Gauge(name='example', documentation='Some doc', labelnames=['one', 'two', 'three']) sample_gaug...
Author: prometheus
🌐
Readthedocs
aioprometheus.readthedocs.io › en › stable › user › index.html
User Guide — aioprometheus Documentation - Read the Docs
To add a metric to a collector you first identify it with a label. In the following example a Gauge collector is created for tracking memory usage.
🌐
Stack Overflow
stackoverflow.com › questions › 58134539 › how-to-push-a-gauge-with-multiple-metrics-to-prometheus-problem-with-gateway
python - How to push a gauge with multiple metrics to Prometheus? Problem with gateway - Stack Overflow
September 27, 2019 - TYPE gauge_name gauge gauge_name{label1="AAA",label2="BBB",label3="CCC"} 4.0 gauge_name{label1="AAA",label2="BBB",label3="DDD"} 0.0 ... Please correct me if my "solution" is wrong. I had to install pushgateway and modify scrap config in prometheus client. Sources: prometheus.io/download/#pushgateway Once I did that, My metrics were exposed at <localhost:9091>. Could you please tell if that is everything I should do?
🌐
OneUptime
oneuptime.com › home › blog › how to add custom metrics to python applications with prometheus
How to Add Custom Metrics to Python Applications with Prometheus
January 6, 2025 - from prometheus_client import Gauge # Create gauges - no labels for simple single-value metric active_connections = Gauge( 'active_connections', 'Number of active database connections' ) # Gauge with labels for multiple queues queue_size = Gauge( 'task_queue_size', 'Number of tasks in the queue', ['queue_name'] # Label to identify different queues ) # Set, increment, decrement operations active_connections.set(5) # Set to absolute value active_connections.inc() # Now 6 (increment by 1) active_connections.dec() # Now 5 (decrement by 1) # With labels - track multiple queues independently queue_size.labels(queue_name='email').set(42) # Email queue has 42 items queue_size.labels(queue_name='notifications').set(18) # Notifications has 18