Skip to content
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

add /health_check for load balancers #1857

Closed
cailiang9 opened this issue Oct 28, 2016 · 13 comments
Closed

add /health_check for load balancers #1857

cailiang9 opened this issue Oct 28, 2016 · 13 comments

Comments

@cailiang9
Copy link

No description provided.

@takluyver
Copy link
Member

I'm not quite sure what this means - is it related to tmpnb or jupyterhub, perhaps?

@cailiang9
Copy link
Author

Thanks! we have our own docker spawner which is hard to integrate with tmpnb. So I run notebook directly and need a /health_check.

@takluyver
Copy link
Member

I'm still not sure what you're after. What information would be in the response of /health_check? What are you trying to load balance? Sorry if this is obvious relative to tmpnb or something - I don't know much about that part of the project.

@ellisonbg
Copy link
Contributor

Are you interest in a /health_check REST endpoint that a load balancer can hit to get the status of the notebook server?

@danielfrg
Copy link

I +1 a /health endpoint. This is useful in also for some schedulers for example for a liveliness check for Kubernetes (https://lukemarsden.github.io/docs/user-guide/liveness/).

I personally like what Elasticsearch does: https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html - but in general a return code of 200 would be good enough in most cases.

@gsemet
Copy link

gsemet commented Feb 23, 2018

would be really useful

@afaq404alam
Copy link

afaq404alam commented Jun 11, 2018

Do we have any updates on this? It would be really useful to have a /health endpoint which just simply returns status 200.

@skully
Copy link

skully commented Mar 18, 2019

Any update regarding this issue?

@mgax
Copy link

mgax commented Apr 2, 2021

For a quick-and-dirty solution, the /static/favicons/favicon.ico URL always returns a 200 response.

@FlorinAndrei
Copy link

For a quick-and-dirty solution, the /static/favicons/favicon.ico URL always returns a 200 response.

I've tried that with the latest version and I get 404.

Having a plain, dumb URL that always returns code 200 would be really useful.

@afshin
Copy link
Member

afshin commented Jun 24, 2021

You can hit /api and it will return a JSON response that contains the version of the notebook package and it does not require authentication.

cf.

class APIVersionHandler(APIHandler):
def get(self):
# not authenticated, so give as few info as possible
self.finish(json.dumps({"version":notebook.__version__}))

@FlorinAndrei
Copy link

You can hit /api and it will return a JSON response that contains the version of the notebook package and it does not require authentication.

cf.

class APIVersionHandler(APIHandler):
def get(self):
# not authenticated, so give as few info as possible
self.finish(json.dumps({"version":notebook.__version__}))

That does it. Folks, we have a solution. A good endpoint to check the health of a Jupyter Notebook instance is simply /api - it returns 200 OK and not much else.

# curl -v http://localhost:8888/api
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8888 (#0)
> GET /api HTTP/1.1
> Host: localhost:8888
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: TornadoServer/6.1
< Content-Type: application/json
< Date: Fri, 25 Jun 2021 18:50:32 GMT
< X-Content-Type-Options: nosniff
< Content-Security-Policy: frame-ancestors 'self'; report-uri /api/security/csp-report; default-src 'none'
< Etag: "846b4f8f33764576d6b3026face5fa7e4d0bd57b"
< Content-Length: 20

@kevin-bates
Copy link
Member

Thanks for the tip @afshin - closing.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests