/metrics and /docs (again?)
BillScherer opened this issue · comments
I am running FastAPI (0.79.1), starlette (0.19.1), satrlette_exporter (0.14.0), uvicorn (0.17.6) and prometheus_client (0.14.1). When I set root_path to fix my /docs (It is behind nginx), most of my application metrics disappeared from /metrics. I see this was supposed to be fixed in v0.12.0, so perhaps I am missing something? Thanks for any help or insight on this.
Sort of, I think. I use nginx to translate a specific path to a specific port. I have multiple FastAPI/Uvicorn apps running, on different ports, on two load balanced servers. The load balancer configuration available to me supports only a single port, so nginx is there to map different root paths to a specific API port. It's working well, just I cannot have both /metrics and /docs at the same time. Obviously, neither is critical to API operation, so no worries on the time frame.
Let me know if you need any further info. Thanks!
I tried to test running a simple app behind a proxy. I ran the app on 8000 and the proxy on 9000 with /api
as the prefix. I set root_path
like this:
FastAPI(root_path="/api")
I am able to access metrics at localhost:8000/metrics
or through the proxy at localhost:9000/api/metrics
. Are you setting root_path the same way or are you using uvicorn --root-path "/api"
?
uvicorn.run(app, host="0.0.0.0", port=8000, root_path="/api")
seems to be working for me as well.
Closing, feel free to re-open if still an issue.