Change the name of the healthz endpoint

  • Is it possible to change the name of healthz to health (or any other string)?
  • Where is this endpoint is documented? What other endpoints are there?
1 Like

Hi @drorata,

We have a few debugging endpoints that are not currently well-documented:

  • /debugz: returns a string containing bits of information about the server’s current state (status of connections, running reports, etc). This is currently broken.

  • /metrics: returns Prometheus metrics from the server, if you have the global.metrics config option set. (By default this is False, so the server won’t gather any of these metrics unless you enable the option.)

There are two additional non-debug endpoints that are used by the frontend code:

  • /healthz: returns a 200 status code if the server is “healthy” (that is, ready to receive a browser connection.)

  • /message: retrieves cached protobuf messages for the current app being run. This is used to speed up apps that send large dataframes to the client; when the server detects that a dataframe will be sent that the client has already received, it will instead send a short message containing the hash to that message, and the client can retrieve the full message from its own internal cache. If the client is missing that message from its cache, it hits the /message endpoint to retrieve it instead.

You can see the names of these endpoints in Server. _create_app. Changing the names of debugz, and metrics should currently be safe, I believe (they’re not called by the frontend, but this could change). If you change healthz or message, you’ll need to update the frontend code with the new names as well, or things will break. (So we don’t recommend doing that!)

The debugz and healthz namings are Google-isms (many of the Streamlit team comes from Google); these endpoints are (or at least were) so named across most internal Google services.

@tim is it possible as a simpler solution to add a new endpoint called health and it will clone healthz?

Just for the record, I learned I could configure the name of the health check endpoint from my infra side, so changing healthz's name is not so critical. But still might be interesting for others.

Sure - you could edit Server._create_app, and add a new entry to the routes list that it constructs:

# Make a duplicate of the /healthz endpoint called "/health"
    make_url_path_regex(base, "health"),
    dict(callback=lambda: self.is_ready_for_browser_connection),

how do i access “global.metrics”
where is it? couldn’t any reference to it anywhere.
i would like to set the metrics endpoint to True


if anyone interested,
in config.toml