Name | fastapi-prometheus-exporter JSON |
Version |
0.2.2
JSON |
| download |
home_page | |
Summary | FastAPI Prometheus Exporter |
upload_time | 2023-12-04 07:13:14 |
maintainer | |
docs_url | None |
author | Yibu Ma |
requires_python | >=3.11,<4.0 |
license | BSD-3-Clause |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# fastapi-prometheus-exporter
[![codecov](https://codecov.io/gh/yibuma/fastapi-prometheus-exporter/graph/badge.svg?token=QDbwB7a9kP)](https://codecov.io/gh/yibuma/fastapi-prometheus-exporter)
FastAPI Prometheus Exporter is a simple Prometheus exporter for FastAPI applications. It provides a set of metrics by default and allows you to add your own metrics as well.
## Installation
```bash
pip install fastapi-prometheus-exporter
```
or
```bash
poetry add fastapi-prometheus-exporter
```
## Usage
```python
from fastapi import FastAPI
from fastapi_prometheus_exporter import PrometheusExporterMiddleware
app = FastAPI()
PrometheusExporterMiddleware.setup(
app=app,
metrics_path="/metrics",
# ignore_paths=["/healthz", "/metrics"],
)
```
### Parameters
- `app`: FastAPI application instance
- `ignore_paths`: List of paths to ignore. Default: `[]`
- `metrics_path`: Path to expose metrics. Default: `/metrics`
- `metrics_registry`: Prometheus registry to use. Default: `prometheus_client.CollectorRegistry`
- `request_latency_name`: Name of the request latency metric. Default: `http_request_duration_seconds`
- `request_latency_doc`: Description of the request latency metric. Default: `HTTP Request Latency`
- `request_latency_buckets`: Buckets for the request latency metric. Default: `prometheus_client.Histogram.DEFAULT_BUCKETS`
- `request_latency_labels`: Labels for the request latency metric. Default: `["method", "endpoint", "http_status"]`
- `request_count_name`: Name of the request count metric. Default: `http_requests_total`
- `request_count_doc`: Description of the request count metric. Default: `Total HTTP Requests`
- `request_count_labels`: Labels for the request count metric. Default: `["method", "endpoint", "http_status"]`
## Metrics
### Default Metrics
- `http_request_duration_seconds`: HTTP request latency in seconds
- `http_requests_total`: Total HTTP requests
Raw data
{
"_id": null,
"home_page": "",
"name": "fastapi-prometheus-exporter",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.11,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Yibu Ma",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/73/4f/3e08d09b8ba29daa10e750022f7038b2d11770ff4d7b9be02615ed4de17e/fastapi_prometheus_exporter-0.2.2.tar.gz",
"platform": null,
"description": "# fastapi-prometheus-exporter\n[![codecov](https://codecov.io/gh/yibuma/fastapi-prometheus-exporter/graph/badge.svg?token=QDbwB7a9kP)](https://codecov.io/gh/yibuma/fastapi-prometheus-exporter) \nFastAPI Prometheus Exporter is a simple Prometheus exporter for FastAPI applications. It provides a set of metrics by default and allows you to add your own metrics as well.\n\n## Installation\n```bash\npip install fastapi-prometheus-exporter\n```\nor\n```bash\npoetry add fastapi-prometheus-exporter\n```\n\n## Usage\n```python\nfrom fastapi import FastAPI\nfrom fastapi_prometheus_exporter import PrometheusExporterMiddleware\napp = FastAPI()\n\nPrometheusExporterMiddleware.setup(\n app=app,\n metrics_path=\"/metrics\",\n # ignore_paths=[\"/healthz\", \"/metrics\"],\n)\n```\n### Parameters\n- `app`: FastAPI application instance\n- `ignore_paths`: List of paths to ignore. Default: `[]`\n- `metrics_path`: Path to expose metrics. Default: `/metrics`\n- `metrics_registry`: Prometheus registry to use. Default: `prometheus_client.CollectorRegistry`\n- `request_latency_name`: Name of the request latency metric. Default: `http_request_duration_seconds`\n- `request_latency_doc`: Description of the request latency metric. Default: `HTTP Request Latency`\n- `request_latency_buckets`: Buckets for the request latency metric. Default: `prometheus_client.Histogram.DEFAULT_BUCKETS`\n- `request_latency_labels`: Labels for the request latency metric. Default: `[\"method\", \"endpoint\", \"http_status\"]`\n- `request_count_name`: Name of the request count metric. Default: `http_requests_total`\n- `request_count_doc`: Description of the request count metric. Default: `Total HTTP Requests`\n- `request_count_labels`: Labels for the request count metric. Default: `[\"method\", \"endpoint\", \"http_status\"]`\n\n## Metrics\n### Default Metrics\n- `http_request_duration_seconds`: HTTP request latency in seconds\n- `http_requests_total`: Total HTTP requests\n",
"bugtrack_url": null,
"license": "BSD-3-Clause",
"summary": "FastAPI Prometheus Exporter",
"version": "0.2.2",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7943b3a6b35b3d832280119b96b7c2775ca4cf776a09cb96c32a2f6aeeb46336",
"md5": "31f3a33bf5869ec1078907897295082c",
"sha256": "e14ee4350131768d3ec0588d62b12b8b6d2cf870467b4d0761d5925cf2a65960"
},
"downloads": -1,
"filename": "fastapi_prometheus_exporter-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "31f3a33bf5869ec1078907897295082c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11,<4.0",
"size": 4407,
"upload_time": "2023-12-04T07:13:12",
"upload_time_iso_8601": "2023-12-04T07:13:12.171253Z",
"url": "https://files.pythonhosted.org/packages/79/43/b3a6b35b3d832280119b96b7c2775ca4cf776a09cb96c32a2f6aeeb46336/fastapi_prometheus_exporter-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "734f3e08d09b8ba29daa10e750022f7038b2d11770ff4d7b9be02615ed4de17e",
"md5": "4b4abd6d92142d1f6e57730004558e48",
"sha256": "1eb6d88b638e1e234e071879d413b64f466a31fd6f0afc5dfdc869956c1d2b1e"
},
"downloads": -1,
"filename": "fastapi_prometheus_exporter-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "4b4abd6d92142d1f6e57730004558e48",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11,<4.0",
"size": 3371,
"upload_time": "2023-12-04T07:13:14",
"upload_time_iso_8601": "2023-12-04T07:13:14.560155Z",
"url": "https://files.pythonhosted.org/packages/73/4f/3e08d09b8ba29daa10e750022f7038b2d11770ff4d7b9be02615ed4de17e/fastapi_prometheus_exporter-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-04 07:13:14",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "fastapi-prometheus-exporter"
}