Get total number of servers in jupyterhub Prometheus metrics

Hello,
I am planning to display total number of servers created in Grafana. Unfortunately couldn’t able to get metrics for total servers, only jupyterhub Prometheus providing the active or running severs.
Can you suggest some way to get it ?

I dont think there is such metric, but to be clear, do you mean total number of server startups — or separate unique servers - where each user has a default server and x named servers?


I want all named servers irrespective of users. To show total number of servers created in hub.

above screenshot : all serves starts with ws name

1 Like

The REST API can provide that info i think, but no prometheus metric

checking api doc …
JupyterHub REST API — JupyterHub documentation

I have tried, REST api not helped. It lists under specific users not all servers

Is it possible to connect sqllite DB ?

You can connect to the db with:

python3 -m jupyterhub.dbutil shell

which gives you an IPython prompt connected to the db. I’m not sure I understand the question, but I think the query you are after would be:

 db.query(orm.Spawner).count()
1 Like

I will try. Its good to have total number of created servers in metrics.

We have this metric on our Grafana dashboard using this PromQL: sum(increase(jupyterhub_server_spawn_duration_seconds_count{}[$__range])) by (status). This gives number of server spawns by different status in the chosen period of time. This still works in JupyterHub 4.x

1 Like