-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exposing metrics not hosted via starlette #36
Comments
Good question. The middleware isn't tied to any particular endpoint, so you could skip adding the Any contributions welcome! 👍 |
I will try something on this but will be slow .. but I have an idea what can it be done . |
Found a way .. but need to find a way to do the testing . |
This issue is getting old and I'm doing some clean up. The metrics can be exposed any way that Prometheus supports, and is not limited by |
Often in a production application one might want to hide the
/metrics
endpoint from public traffic. Using the methods listed in the README, one would have to explicitly mask the/metrics
route within a reverse proxy and bind to two different ports which can be non-trivial (see encode/uvicorn#571 for context).In my experience I've found it easier to just expose the metrics on a separate port (Ie. 9090) via Prometheus's default
start_http_server
function but I'm not sure if this is supported by starlette-exporter. This way the metrics requests are served completely internally (and, for example, can only be exposed internally within a kubernetes cluster). While probably not necessary, to be clean I also integrated the server used instart_http_server
with starlette's lifespan events (otherwise I'm worried for example the socket won't unbind for some period of time when hot reloading).My questions are (edit: updated questions):
start_http_server
be accepted into the README?start_http_server
handling lifespan hooks be accepted as a contribution?cc @NargiT
The text was updated successfully, but these errors were encountered: