Skip to main content

Prometheus exporter for tqdm

Publish your pretty CLI stats for monitoring elsewhere

Usage

There are no security or authentication mechanisms provided, be careful exposing the host more widely

Initalise the proxy

proxy = TqdmPromProxy(http_host='[::1]', http_port=3000, metric_func=metric_formatter_func)
proxy.start()

Use the proxy

Replace tqdm initalisers with proxy.tqdm.

for item in proxy.tqdm(range(100), desc='My first bar')
    item.doathing()

with proxy.tqdm(range(100), desc='My second bar') as f:
    f.update(50)

# etc

Formatting your content

TQDM bars are a lot more verbose than prometheus metrics. You can customise their names by passing in a function with this signature.

def metric_formatter_func(metric_name: str, metric_property: str, metric_scale: str) -> str:
    pass

metric_property is one of:

  • completed the number executions thus far in TQDM;
  • total the configured expected maximum in TQDM as tqdm(total=x);
  • active based on the naming, how many current bars are being grouped together as this name
  • finished based on the naming, how many bars with this name have been completely finished

The str that is returned must adhere to the metric naming conventions (A-Za-z0-9_) outlined in the prometheus docs https://prometheus.io/docs/practices/naming/

This function is called a lot, so avoid computation or cache your values

Additionally to control which properties are aggregated, provide a bucket_func: This example will aggregate all bars with a description starting with upload together

def bucketting_func(snapshot: TqdmSnapshot):
    if snapshot.desc.lowercase().startswith('upload'):
        return "Upload"

    return snapshot.desc

If you require tqdm.write for sticky console output,

from tqdm import tqdm as tqdm_og
tqdm_og.write('Job done')
curl http://[::1]:3000/metrics

Overview

---
Conceptual Overview
---
flowchart LR

    Queue@{ shape: das, label: "Update buffer" }
    TQDM@{ shape: process, label: "(your) faux TQDM instance"}
    Bucketting@{ shape: process, label: "Metric extraction & aggregation"}

    TQDM -- "Periodic Updates" --> Queue
    Queue --> Bucketting
    Bucketting -- "Expose aggregate metrics" --> HttpServer

Metadata

Release files for tqdm-prometheus-exporter 0.1.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tqdm-prometheus-exporter 0.1.15
File Size Uploaded
tqdm_prometheus_exporter-0.1.15.tar.gz 58.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tqdm-prometheus-exporter 0.1.15
File Interpreter ABI Platform
tqdm_prometheus_exporter-0.1.15-py3-none-any.whl Python 3 none any Details

Total release size: 68.0 kB

Release files / tqdm_prometheus_exporter-0.1.15.tar.gz

Download URL tqdm_prometheus_exporter-0.1.15.tar.gz
Size 58.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7a2a383b628f7abda50423fc14fc433b77e7b5749dbab9c441b593e0841602b0
BLAKE2b-256 checksum
How to use checksums
989fdd8cd2f6cbff2262f911823e93504c0c2bf25e6f9b9e6ff87c6d111270c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 27, 2025.

Transparency log

Release files / tqdm_prometheus_exporter-0.1.15-py3-none-any.whl

Download URL tqdm_prometheus_exporter-0.1.15-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd95bbe77c47ee90076d2e84e8893279b0b965b59425699228530190022a5054
BLAKE2b-256 checksum
How to use checksums
0438e2d761716df9720520c9e136abb713d6b0795257319ebb5814f0c15ce5c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 27, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.15 This release

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.4

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page