jupyter_server icon indicating copy to clipboard operation
jupyter_server copied to clipboard

[feat/1316] Support Serving Metrics On an Alternate Port

Open divyabiyani opened this issue 4 months ago • 0 comments

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=0 will 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 to true.
    • --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. Screenshot 2025-06-15 at 7 16 04 PM

  • 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. Screenshot 2025-06-15 at 7 09 59 PM

  • Verified behavior when no ServerApp.token='' or --ServerApp.password='' is provided:

    • With --ServerApp.authenticate_prometheus=False.
Screenshot 2025-06-15 at 7 10 08 PM
  • With --ServerApp.authenticate_prometheus=True.
Screenshot 2025-06-15 at 7 12 49 PM Screenshot 2025-06-15 at 7 16 00 PM
  • Verified behavior when both ServerApp.token and ServerApp.password are provided.
  • Verified functionality with --ServerApp.record_http_request_metrics=True.
Screenshot 2025-06-15 at 7 09 41 PM
  • Verified metrics served with --ServerApp.metrics_port=9009. Uploading Screenshot 2025-06-15 at 7.34.03 PM.png…

  • Verified fallback behavior with --ServerApp.metrics_port=0 (metrics served on main Tornado server). Uploading Screenshot 2025-06-15 at 7.33.44 PM.png…

  • Verified that when the configured metrics port is already in use, server startup fails with appropriate error. Uploading Screenshot 2025-06-15 at 11.24.08 PM.png…

divyabiyani avatar Jun 15 '25 14:06 divyabiyani