Skip to main content

prometheus-pusher

A lifecycle-safe helper for pushing application metrics to a Prometheus Pushgateway.

Requirements

Python 3.11 or newer. CI validates Python 3.11, 3.12, 3.13, and 3.14.

Install

uv add prometheus-pusher
pip install prometheus-pusher

Usage

from prometheus_client import CollectorRegistry, Counter

from prometheus_pusher import monitoring_adapter

registry = CollectorRegistry()
requests = Counter("demo_requests_total", "Number of demo requests", registry=registry)

monitoring_adapter.startup(
    gateway="http://127.0.0.1:9091",
    job_name="demo",
    registry=registry,
    is_enabled=True,
)

try:
    requests.inc()
    monitoring_adapter.send()  # Push immediately.
    monitoring_adapter.serve(worker_timeout=10)  # Then push every 10 seconds.
finally:
    monitoring_adapter.shutdown()

startup() configures the adapter. send() performs one push. serve() starts one daemon worker and is idempotent while that worker is alive. shutdown() signals and joins the adapter-owned worker; call it during application shutdown. A disabled adapter (is_enabled=False) remains a no-op.

Pass user and password for HTTP Basic authentication. Set ssl_verify=True for HTTPS endpoints with certificate verification; ssl_verify=False disables certificate validation and should be used only for trusted development environments. Push and network failures are logged and do not interrupt application execution.

Migrating from 0.1.0

  1. Upgrade the application to Python 3.11 or newer.
  2. Retain existing monitoring_adapter.startup(...), send(), and serve() calls.
  3. Add monitoring_adapter.shutdown() to the application's graceful-shutdown path.

Version 1.0.0 replaces the global, never-stopped worker with lifecycle owned by each MonitoringAdapter instance.

Development

uv sync --all-groups
uv run ruff format --check src tests examples
uv run ruff check src tests examples
uv run mypy src
uv run pytest --cov=prometheus_pusher
uv build

License and security

Distributed under the Apache License 2.0. See the security policy to report vulnerabilities.

Release files for prometheus-pusher 1.0.0

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

Source distribution (sdist)

Source distribution for prometheus-pusher 1.0.0
File Size Uploaded
prometheus_pusher-1.0.0.tar.gz 43.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prometheus-pusher 1.0.0
File Interpreter ABI Platform
prometheus_pusher-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 53.2 kB

Release files / prometheus_pusher-1.0.0.tar.gz

Download URL prometheus_pusher-1.0.0.tar.gz
Size 43.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e4752033de59a14fc7f6f2447b1631c542eade1e39afd7e0dd78279883bcac48
BLAKE2b-256 checksum
How to use checksums
eeb62a87b2528bff15c73c9a1b106a46bc0ebf9c25534385ffaca018eb287aff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 20, 2026.

Transparency log

Release files / prometheus_pusher-1.0.0-py3-none-any.whl

Download URL prometheus_pusher-1.0.0-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9840c9dae2b97f15a37d18c08b55e77d64b14831139472644ec134361c619ee0
BLAKE2b-256 checksum
How to use checksums
11e895cd8af48524dc08c8a3ce9bf520cc42f59bab8e542c266d0679a6017ec7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 20, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

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