mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-07 18:14:10 +00:00

these should probably have been on `/api/` all along, but must be on /api/ for api-only hub routing
25 lines
610 B
Python
25 lines
610 B
Python
"""Handlers for serving prometheus metrics"""
|
|
from prometheus_client import CONTENT_TYPE_LATEST
|
|
from prometheus_client import generate_latest
|
|
from prometheus_client import REGISTRY
|
|
|
|
from ..utils import metrics_authentication
|
|
from .base import BaseHandler
|
|
|
|
|
|
class MetricsHandler(BaseHandler):
|
|
"""
|
|
Handler to serve Prometheus metrics
|
|
"""
|
|
|
|
@metrics_authentication
|
|
async def get(self):
|
|
self.set_header('Content-Type', CONTENT_TYPE_LATEST)
|
|
self.write(generate_latest(REGISTRY))
|
|
|
|
|
|
default_handlers = [
|
|
(r'/metrics$', MetricsHandler),
|
|
(r'/api/metrics$', MetricsHandler),
|
|
]
|