ASGI-Prometheus
asgi-prometheus – Support Prometheus metrics for ASGI applications (Asyncio / Trio, / Curio)
Requirements
python >= 3.9
Installation
asgi-prometheus should be installed using pip:
pip install asgi-prometheus
Usage
Common ASGI applications:
from asgi_prometheus import PrometheusMiddleware
async def my_app(scope, receive, send):
"""Read session and get the current user data from it or from request query."""
await send({"type": "http.response.start", "status": status, "headers": headers})
await send({"type": "http.response.body", "body": b"Hello World!"})
app = PrometheusMiddleware(my_app, metrics_url="/metrics", group_paths=['/'])
# http GET / -> OK
# http GET /metrics -> [Prometheus metrics]
As ASGI-Tools Internal middleware
from asgi_tools import App
from asgi_prometheus import PrometheusMiddleware
app = App()
app.middleware(PrometheusMiddleware.setup(group_paths=['/views', '/api']))
@app.route('/')
async def index(request):
return 'Hello World!'
# http GET / -> OK
# http GET /prometheus -> [Prometheus metrics (default URL)]
Options
from asgi_sessions import PrometheusMiddleware
app = PrometheusMiddleware(
# Your ASGI application
app,
# Metrics URL for Prometheus (set empty string to disable)
metrics_url='/prometheus',
# List of path's prefixes to group. A path which starts from the prefix will be grouped.
# For example: group_paths=['/api/users'], "/api/users/1", "/api/users/2" will be grouped into "/api/users*"
group_paths=[],
)
Bug tracker
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/asgi-prometheus/issues
Contributing
Development of the project happens at: https://github.com/klen/asgi-prometheus
License
Licensed under a MIT license.
Metadata
Release files for asgi-prometheus 1.2.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 |
|---|---|---|---|---|
| asgi_prometheus-1.2.3.tar.gz | 5.1 kB | Without provenance | Details for asgi_prometheus-1.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asgi_prometheus-1.2.3-py3-none-any.whl | Python 3 | none | any | Details for asgi_prometheus-1.2.3-py3-none-any.whl |
Total release size: 10.2 kB
Release files / asgi_prometheus-1.2.3.tar.gz
| Download URL | asgi_prometheus-1.2.3.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e047959ff1cef1b1bad9ddce46723a8f030ad7e7b98bb3d58e1b1619ad166b8
|
|
BLAKE2b-256 checksum How to use checksums |
7ef059eeda10f472c450969042b952ce3b6f390ef41d683b7986d909237f2b16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / asgi_prometheus-1.2.3-py3-none-any.whl
| Download URL | asgi_prometheus-1.2.3-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c37e0d8dbd7561fd169511d4f0fde0c040d4e89e58ee4889a29fcf4bff0fef78
|
|
BLAKE2b-256 checksum How to use checksums |
016c43a1a98f014e9aab28bf3a1bd77d5182df12cd057131486352bde0013ec4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Security for asgi-prometheus 1.2.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.