-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace global dashboard with activity dashboard
The activity.jsonnet dashboard is extracting four panels from the jupyterhub.jsonnet dashboard. The running servers panel and daily/weekly/monhtly active users panels. By doing this, we get a dashboard with only those four panels, grouped into a row. This row is then made repeatable over the prometheus datasource variable. With a repeating row, we could end up with very many rows, making any panels below hard to get to. Due to that, it makes sense to use repeating rows in a dedicated dashboard. The global dashboard that is being deleted made use of hardcoded state in the grafana instance it was being deployed to. This then also required regular re-deploys of the dashboard just to update the hardcoded entries. Further, the global dashboard couldn't be pre-rendered and re-used across grafana instances - because it had grafance instance specific state within it. With the new Activity dashboard, we can avoid all this complexity and possibly publish pre-rendered dashboards that any grafana instance can install directly.
- Loading branch information
1 parent
dfd56e4
commit 924e4de
Showing
9 changed files
with
154 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
#!/usr/bin/env -S jsonnet -J ../vendor | ||
local grafonnet = import 'grafonnet/main.libsonnet'; | ||
local dashboard = grafonnet.dashboard; | ||
local ts = grafonnet.panel.timeSeries; | ||
local prometheus = grafonnet.query.prometheus; | ||
local row = grafonnet.panel.row; | ||
local var = grafonnet.dashboard.variable; | ||
|
||
local common = import './common.libsonnet'; | ||
|
||
local activeUserTsOptions = | ||
common.tsOptions | ||
+ ts.standardOptions.withDecimals(0) | ||
// stacking is used here as the total number of users is as relevant as the | ||
// number of users per hub | ||
+ ts.fieldConfig.defaults.custom.stacking.withMode('normal') | ||
// stepAfter is used here as these metrics indicate what has happened the time | ||
// before the metric is read | ||
+ ts.fieldConfig.defaults.custom.withLineInterpolation('stepAfter') | ||
+ ts.panelOptions.withDescription( | ||
||| | ||
Number of unique users who were active within the preceding period. | ||
||| | ||
) | ||
; | ||
|
||
local runningServers = | ||
common.tsOptions | ||
+ ts.new('Running Servers') | ||
+ ts.standardOptions.withDecimals(0) | ||
+ ts.fieldConfig.defaults.custom.stacking.withMode('normal') | ||
+ ts.fieldConfig.defaults.custom.withLineInterpolation('stepBefore') | ||
+ ts.panelOptions.withDescription( | ||
||| | ||
Number of running user servers at any given time. | ||
Note that a single user could have multiple servers running if the | ||
JupyterHub is configured with `c.JupyterHub.allow_named_servers = True`. | ||
||| | ||
) | ||
+ ts.queryOptions.withTargets([ | ||
prometheus.new( | ||
'$PROMETHEUS_DS', | ||
||| | ||
max( | ||
jupyterhub_running_servers{namespace=~"$hub"} | ||
) by (namespace) | ||
||| | ||
) | ||
+ prometheus.withLegendFormat('{{ namespace }}'), | ||
]); | ||
|
||
local dailyActiveUsers = | ||
activeUserTsOptions | ||
+ ts.new('Daily Active Users') | ||
+ ts.queryOptions.withTargets([ | ||
prometheus.new( | ||
'$PROMETHEUS_DS', | ||
||| | ||
max( | ||
jupyterhub_active_users{period="24h", namespace=~"$hub"} | ||
) by (namespace) | ||
||| | ||
) | ||
+ prometheus.withLegendFormat('{{ namespace }}'), | ||
]); | ||
|
||
local weeklyActiveUsers = | ||
activeUserTsOptions | ||
+ ts.new('Weekly Active Users') | ||
+ ts.queryOptions.withTargets([ | ||
prometheus.new( | ||
'$PROMETHEUS_DS', | ||
||| | ||
max( | ||
jupyterhub_active_users{period="7d", namespace=~"$hub"} | ||
) by (namespace) | ||
||| | ||
) | ||
+ prometheus.withLegendFormat('{{ namespace }}'), | ||
]); | ||
|
||
local monthlyActiveUsers = | ||
activeUserTsOptions | ||
+ ts.new('Monthly Active Users') | ||
+ ts.queryOptions.withTargets([ | ||
prometheus.new( | ||
'$PROMETHEUS_DS', | ||
||| | ||
max( | ||
jupyterhub_active_users{period="30d", namespace=~"$hub"} | ||
) by (namespace) | ||
|||, | ||
) | ||
+ prometheus.withLegendFormat('{{ namespace }}'), | ||
]); | ||
|
||
|
||
dashboard.new('Activity') | ||
+ dashboard.withTags(['jupyterhub']) | ||
+ dashboard.withUid('jhgd-activity') | ||
+ dashboard.withEditable(true) | ||
+ dashboard.time.withFrom('now-90d') | ||
+ dashboard.withVariables([ | ||
/* | ||
* This dashboard repeats the single row it defines once per datasource, due | ||
* to that we allow multiple or all datasources to be selected in this | ||
* dashboard but not in others. This repeating is only usable for repeating | ||
* panels or rows, as individual panels can't repeat queries based on the | ||
* available datasources. | ||
*/ | ||
common.variables.prometheus | ||
+ var.query.selectionOptions.withMulti() | ||
+ var.query.selectionOptions.withIncludeAll(), | ||
/* | ||
* The hub variable will behave weirdly when multiple datasources are selected, | ||
* only showing hubs from one datasource. This is currently an accepted issue. | ||
* Many deployments of these dashboard will only be in a Grafana instance with | ||
* a single prometheus datasource. | ||
*/ | ||
common.variables.hub, | ||
]) | ||
+ dashboard.withPanels( | ||
grafonnet.util.grid.makeGrid( | ||
[ | ||
row.new('Activity ($PROMETHEUS_DS)') | ||
+ row.withPanels([ | ||
runningServers, | ||
dailyActiveUsers, | ||
weeklyActiveUsers, | ||
monthlyActiveUsers, | ||
]) | ||
+ row.withRepeat('PROMETHEUS_DS'), | ||
], | ||
panelWidth=6, | ||
panelHeight=8, | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.