pachifast-metrics
Prometheus metrics for pachifast (source) projects: an extension package. It adds a GET /metrics endpoint and a middleware that counts and times every request.
Status: alpha. It follows pachifast 0.x: the minor versions of this package may break, and each release works with one minor of pachifast (
requires_pachifast).
Install
uv add pachifast-metrics
Then list the module in the project_modules.py of your project (see extending pachifast):
from pachifast.presets import core_module
from pachifast_metrics import module as metrics_module
MODULES = (core_module, metrics_module, ...)
What it exposes
GET /metrics (at the root, not under /api), in the Prometheus text format:
| Metric | Type | Labels |
|---|---|---|
pachifast_http_requests_total |
counter | method, route, status |
pachifast_http_request_duration_seconds |
histogram | method, route |
pachifast_http_requests_in_progress |
gauge |
route is the route template (/api/users/{user_id}), never the path with the real id, and a request that matches no route is unmatched: the number of series stays bounded whatever the clients send. The scrape of /metrics is not counted.
Settings
Environment variables, read when the endpoint is called:
| Variable | Default | Effect |
|---|---|---|
PACHIFAST_METRICS_TOKEN |
empty | When set, /metrics answers only to Authorization: Bearer <token> (401 otherwise). Empty: open, so keep it off the public internet (a reverse proxy rule, or a network that only Prometheus reaches). |
PACHIFAST_METRICS_ENABLED |
true |
false makes /metrics answer 404. |
Prometheus:
scrape_configs:
- job_name: myproject
authorization:
credentials: <the token>
static_configs:
- targets: ["myproject:8000"]
With several workers each process keeps its own counters: scrape every worker (one per port or pod), or put prometheus_client's multiprocess mode behind your server; this package does not do it for you.
Develop
uv sync
uv run pytest -q
uv run ruff check . && uv run ruff format --check .
License
MIT, see LICENSE.
Disclaimer. pachifast-metrics is provided "as is", without warranty of any kind. It is alpha software: it can contain bugs and change incompatibly between minor releases. You are responsible for reviewing, testing and securing the applications you build with it before using them in production.
Metadata
Release files for pachifast-metrics 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pachifast_metrics-0.1.3.tar.gz | 7.3 kB | Without provenance | Details for pachifast_metrics-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pachifast_metrics-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for pachifast_metrics-0.1.3-py3-none-any.whl |
Total release size: 14.9 kB
Release files / pachifast_metrics-0.1.3.tar.gz
| Download URL | pachifast_metrics-0.1.3.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6f2e9c796ffaa27d55b6e894a81e46f0bc5d101ffeeefbe3f6aa9190b4ad789
|
|
BLAKE2b-256 checksum How to use checksums |
9406ff32a68ea52cba7508d82b2e82d3b43119bf29cbdffedda87c349a7c6c70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pachifast_metrics-0.1.3-py3-none-any.whl
| Download URL | pachifast_metrics-0.1.3-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fbd58f21caa595c0794fa24bffbf0e274818510207314b86ae44d08e98e82216
|
|
BLAKE2b-256 checksum How to use checksums |
3f9c19908931ca9875397e47309d775041c38dc2dc41fbb64ef2c316b98c8731
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pachifast-metrics 0.1.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.