prometheus / prometheus/client_python
ASGI mounted to FastAPI mounts metrics to `/metrics/` instead of `/metrics`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 4.4k
- Forks
- 876
- Ø Merge
- 8 T. 4 Std.
- Gemergte PRs (30 T.)
- 1
Beschreibung
The documentation gives an example application which mounts the ASGI app to /metrics in a FastAPI app
from fastapi import FastAPI
from prometheus_client import make_asgi_app
# Create app
app = FastAPI(debug=False)
# Add prometheus asgi middleware to route /metrics requests
metrics_app = make_asgi_app()
app.mount("/metrics", metrics_app)
and says that you should be able to see the metrics at http://localhost:8000/metrics, however if you try to access this endpoint
$ uvicorn app:app
INFO: Started server process [1620866]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: 127.0.0.1:34428 - "GET / HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:34428 - "GET /favicon.ico HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:34444 - "GET /metrics HTTP/1.1" 307 Temporary Redirect
INFO: 127.0.0.1:34444 - "GET /metrics/ HTTP/1.1" 200 OK
you get redirected to /metrics/.
It would be better if this redirect could be avoided.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem FastAPI-Beispiel in der verlinkten Dokumentation und reproduziere die eingebundene /metrics-Anfrage mit uvicorn. Prüfe, ob die Weiterleitung durch das dokumentierte client_python-Beispiel oder das FastAPI-Mount-Verhalten gesteuert wird; abgeschlossen ist die Aufgabe, wenn entweder die Weiterleitung vermieden oder das tatsächliche Verhalten des Endpunkts klar dokumentiert wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- fastapi, python
- Bereich
- api, backend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100