jupyter_server
jupyter_server copied to clipboard
[feat/1316] Support Serving Metrics On an Alternate Port
Feature Request: Jupyter Server Issue #1316 — Support Serving Metrics On an Alternate Port
Label suggestion: enhancement
Summary Of Changes:
- Introduced support for serving metrics on an alternate port.
- Updated the default behavior to publish metrics on port
9090. - The port can be customized using the
--ServerApp.metrics_port=<port>argument. Setting--ServerApp.metrics_port=0will disable the separate server and serve metrics through the main Tornado server. - The metrics server honors the following configuration flags:
--ServerApp.authenticate_prometheus=<bool>— Enables authentication for metrics endpoint if set totrue.--ServerApp.record_http_request_metrics=<bool>— Enables or disables recording of HTTP request metrics.
- Enhanced info logs to include the metrics URL for better visibility.
Test Scenarios Verified:
-
Info logs correctly include the metrics URL.
-
Verified that when a custom metrics port is provided, metrics are only served on the specified port and not on the default port or tornado server port.
-
Verified behavior when no
ServerApp.token=''or--ServerApp.password=''is provided:- With
--ServerApp.authenticate_prometheus=False.
- With
- With
--ServerApp.authenticate_prometheus=True.
- Verified behavior when both
ServerApp.tokenandServerApp.passwordare provided. - Verified functionality with
--ServerApp.record_http_request_metrics=True.
-
Verified metrics served with
--ServerApp.metrics_port=9009. -
Verified fallback behavior with
--ServerApp.metrics_port=0(metrics served on main Tornado server). -
Verified that when the configured metrics port is already in use, server startup fails with appropriate error.