Skip to content

Commit

Permalink
Add graph to measure images used by user pods
Browse files Browse the repository at this point in the history
With KubeSpawner's profileList, users may use different images
when starting their servers. Measuring and displaying this helps
admins know which images are popular, and help support users more.

This becomes more relevant with
jupyterhub/kubespawner#735,
as end users can now specify arbitrary images.

Added some docs along with this!

Query thanks to @pnasrat, from
2i2c-org/infrastructure#2582 (comment)

Co-authored-by: Pris Nasrat <[email protected]>
  • Loading branch information
yuvipanda and Pris Nasrat committed Jul 21, 2023
1 parent 4e6c6c9 commit 3af4bf5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
26 changes: 26 additions & 0 deletions dashboards/jupyterhub.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,28 @@ local highMemoryUsagePods = tablePanel.new(
),
]).hideColumn('Time');

# Show images used by different users on the hub
local notebookImagesUsed = graphPanel.new(
'Images used by user pods',
description=|||
Number of user servers using a container image
|||,
legend_hideZero=false,
decimals=0,
stack=true,
min=0,
datasource='$PROMETHEUS_DS'
).addTargets([
prometheus.target(
|||
sum (
# User pods are named "notebook" by kubespawner
kube_pod_container_info{container="notebook", namespace=~"$hub"}
) by(image_spec, namespace)
|||,
legendFormat='{{image_spec}} (prod)',
),
]);

dashboard.new(
'JupyterHub Dashboard',
Expand All @@ -543,6 +565,10 @@ dashboard.new(
weeklyActiveUsers, {}
).addPanel(
monthlyActiveUsers, {}
).addPanel(
row.new('Container Images'), {},
).addPanel(
notebookImagesUsed, {}
).addPanel(
row.new('User Resource Utilization stats'), {}
).addPanel(
Expand Down
9 changes: 9 additions & 0 deletions docs/howto/images.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Find what images users are using

With kubespawner's `profileList` feature, end users may choose different
images to launch. It is useful to measure what images are being used so we
can serve our users better over time.

The "Images used by user pods" graph in the JupyterHub dashboard helps with this.
It shows the popularity of various images used over time. Note that if an image
is no used at all, it will not be shown.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ via code. This can then be deployed on any Grafana instance!
:maxdepth: 2
howto/deploy.md
howto/user-diagnostics.md
howto/images.md
```

## Contributing
Expand Down

0 comments on commit 3af4bf5

Please sign in to comment.