🌐
client_python
prometheus.github.io › client_python › instrumenting › gauge
Gauge | client_python
April 24, 2026 - 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 · Gauge(name, documentation, labelnames=(), namespace='', subsystem='', unit='', registry=REGISTRY, multiprocess_mode='all')
🌐
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
Discussions

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
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
Can't create gauges with labels and sample values
I'd like to have a gauge with labels and a value. But if i try to do that, I get a AttributeError for _value. To reproduce: >>> from prometheus_client import Gauge >>> g = Gau... More on github.com
🌐 github.com
2
February 27, 2020
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
🌐
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
🌐
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
🌐
GitHub
github.com › prometheus › client_python › issues › 614
Cannot initialize Gauge label values with exception · Issue #614 · prometheus/client_python
January 26, 2021 - from prometheus_client import Gauge sample_gauge = Gauge(name='example', documentation='Some doc', labelnames=['one', 'two', 'three']) sample_gauge.labels(["1", "2", "3"]) sample_gauge.set(1) Running this snippet will throw the following exception in any case: Traceback (most recent call last): File "*/sample.py", line 5, in <module> sample_gauge.labels(["1", "2", "3"]) File "*/Library/Caches/pypoetry/virtualenvs/checkm8-MuaFxrMT-py3.9/lib/python3.9/site-packages/prometheus_client/metrics.py", line 164, in labels raise ValueError('Incorrect label count') ValueError: Incorrect label count ·
Author: prometheus
🌐
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
🌐
GitHub
github.com › prometheus › client_python › issues › 516
Can't create gauges with labels and sample values · Issue #516 · prometheus/client_python
February 27, 2020 - >>> from prometheus_client import Gauge >>> g = Gauge('my_inprogress_requests', 'Description of gauge', ['l1','l2']) >>> g.labels(l1='foo',l2='ba') <prometheus_client.metrics.Gauge object at 0x1078f5f50> >>> g.set(4) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/moritzfago/Softwareprojekt/repo/exporter/lib/python3.7/site-packages/prometheus_client/metrics.py", line 344, in set self._value.set(float(value)) AttributeError: 'Gauge' object has no attribute '_value' But: >>> g.labels(l1='foo',l2='ba').set(4) No one assigned ·
Author: prometheus
🌐
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() ...
🌐
GitHub
github.com › slok › prometheus-python
GitHub - slok/prometheus-python: Prometheus metric system client for python · GitHub
from prometheus.collectors import ... 4] for i in values: http_access.add({'time': '/static'}, i) Labels define the multidimensional magic in prometheus....
Starred by 19 users
Forked by 11 users
Languages: Python 99.9% | Shell 0.1%
Find elsewhere
🌐
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
🌐
GitHub
github.com › prometheus › client_python › issues › 365
Metrics accessed via labels() do not have collect() · Issue #365 · prometheus/client_python
August 1, 2019 - When accessing a Metric via labels(), it does not have collect(). This is due to labels() instantiating wrappedClass and not _MetricWrapper(wrappedClass). We need to read samples manually via collect() in unit tests. This allows us to test a Prometheus exporter against an existing statistics exporter interface. Minimal code example: import prometheus_client gauges = prometheus_client.Gauge("gauge", "", labelnames=["label"]) gauges.collect() # collect() works as expected.
Author: prometheus
🌐
GitHub
github.com › prometheus › docs › blob › main › docs › instrumenting › writing_clientlibs.md
docs/docs/instrumenting/writing_clientlibs.md at main · prometheus/docs
Labels are one of the most powerful aspects of Prometheus, but easily abused. Accordingly client libraries must be very careful in how labels are offered to users. Client libraries SHOULD NOT allow users to have different label names for the ...
Author: prometheus
🌐
GitHub
github.com › valohai › prometheus-client-python
GitHub - valohai/prometheus-client-python: Prometheus instrumentation library for Python applications · GitHub
The Python client supports parsing the Prometheus text format. This is intended for advanced use cases where you have servers exposing Prometheus metrics and need to get them into some other system. from prometheus_client.parser import text_string_to_metric_families for family in text_string_to_metric_families(u"my_gauge 1.0\n"): for sample in family.samples: print("Name: {0} Labels: {1} Value: {2}".format(*sample))
Author: valohai
🌐
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 - I tried to follow the guide in https://github.com/prometheus/client_python#exporting-to-a-pushgateway. I installed prometheus locally and ran the client after editing yaml file by replacing scrape config with: scrape_configs: - job_name: pushgateway honor_labels: true static_configs: - targets: - localhost:9091 ... # ( Class attribute ) iv_registry = CollectorRegistry() # Gauge to be passed to the Prometheus iv_gauge = Gauge(ic_gauge_name, ic_gauge_docu_labels, ic_labels_list, registry=iv_registry) def __create_gauge(self): """Fill gauge to be passed to the prometheus and graffana""" try: # Set labels and assign a metric self.iv_gauge.labels( label1 = "AAA", label2 = "BBB", label3 = "CCC" ).set(4) self.iv_gauge.labels( label1 = "AAA", label2 = "BBB", label3 = "DDD" ).set(0) # expose in a batch mode self.iv_gauge.set_to_current_time() # Does it have to be here?
🌐
GitHub
github.com › prometheus › client_python › blob › master › prometheus_client › metrics.py
client_python/prometheus_client/metrics.py at master · prometheus/client_python
self._labelvalues, self._documentation) ... """Reset the counter to zero. Use this when a logical process restarts without restarting the actual python process."""
Author: prometheus
🌐
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.
🌐
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()
🌐
client_python
prometheus.github.io › client_python › collector › custom
Custom Collectors | client_python
May 4, 2026 - Pass labels (a sequence of label names) and then call add_metric one or more times to emit labelled metrics. # single unlabelled value GaugeMetricFamily('my_gauge', 'Help text', value=7) # labelled metrics via add_metric g = GaugeMetricFamily('my_gauge', 'Help text', labels=['region']) ...
🌐
PyPI
pypi.org › project › pyprometheus
Client Challenge
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser