https://github.com/perdy/starlette-prometheus
Prometheus integration for Starlette.
https://github.com/perdy/starlette-prometheus
asgi metrics middleware prometheus starlette
Last synced: 6 days ago
JSON representation
Prometheus integration for Starlette.
- Host: GitHub
- URL: https://github.com/perdy/starlette-prometheus
- Owner: perdy
- License: gpl-3.0
- Created: 2019-01-10T15:49:38.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-20T15:57:03.000Z (9 months ago)
- Last Synced: 2025-02-09T03:07:28.759Z (13 days ago)
- Topics: asgi, metrics, middleware, prometheus, starlette
- Language: Python
- Size: 201 KB
- Stars: 287
- Watchers: 5
- Forks: 31
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-fastapi - Starlette Prometheus - Prometheus integration for FastAPI and Starlette. (Third-Party Extensions / Utils)
- awesome-fastapi - Starlette Prometheus - Prometheus integration for FastAPI and Starlette. (Third-Party Extensions / Utils)
- best-of-web-python - GitHub - 34% open · ⏱️ 05.02.2024): (Monitoring)
README
# Starlette Prometheus
[](https://github.com/perdy/starlette-prometheus/actions)
[](https://pypi.org/project/starlette-prometheus/)
[](https://pypi.org/project/starlette-prometheus/)## Introduction
Prometheus integration for Starlette.
## Requirements
* Python 3.8+
* Starlette 0.12+## Installation
```console
$ pip install starlette-prometheus
```## Usage
A complete example that exposes prometheus metrics endpoint under `/metrics/` path.
```python
from starlette.applications import Starlette
from starlette_prometheus import metrics, PrometheusMiddlewareapp = Starlette()
app.add_middleware(PrometheusMiddleware)
app.add_route("/metrics/", metrics)
```Metrics for paths that do not match any Starlette route can be filtered by passing
`filter_unhandled_paths=True` argument to `add_middleware` method. Note that not
turning on this filtering can lead to unbounded memory use when lots of different
routes are called.## Contributing
This project is absolutely open to contributions so if you have a nice idea, create an issue to let the community
discuss it.