Sgl-router Prometheus metrics endpoint and usage track metrics (#6537)

This commit is contained in:
Chao Yang
2025-05-24 22:28:15 -07:00
committed by GitHub
parent 022012aae8
commit 1a39979993
9 changed files with 167 additions and 2 deletions

View File

@@ -28,6 +28,8 @@ def popen_launch_router(
selector: list = None,
service_discovery_port: int = 80,
service_discovery_namespace: str = None,
prometheus_port: int = None,
prometheus_host: str = None,
):
"""
Launch the router server process.
@@ -45,6 +47,8 @@ def popen_launch_router(
selector: List of label selectors in format ["key1=value1", "key2=value2"]
service_discovery_port: Port to use for service discovery
service_discovery_namespace: Kubernetes namespace to watch for pods. If None, watches all namespaces.
prometheus_port: Port to expose Prometheus metrics. If None, Prometheus metrics are disabled.
prometheus_host: Host address to bind the Prometheus metrics server.
"""
_, host, port = base_url.split(":")
host = host[2:]
@@ -87,6 +91,12 @@ def popen_launch_router(
["--router-service-discovery-namespace", service_discovery_namespace]
)
if prometheus_port is not None:
command.extend(["--router-prometheus-port", str(prometheus_port)])
if prometheus_host is not None:
command.extend(["--router-prometheus-host", prometheus_host])
if log_dir is not None:
command.extend(["--log-dir", log_dir])