diff --git a/dashboards/jupyterhub.jsonnet b/dashboards/jupyterhub.jsonnet index 375a6c9..7aa7c90 100755 --- a/dashboards/jupyterhub.jsonnet +++ b/dashboards/jupyterhub.jsonnet @@ -16,11 +16,6 @@ local jupyterhub = import 'jupyterhub.libsonnet'; local currentActiveUsers = common.tsOptions + ts.new('Currently Active Users') - + ts.panelOptions.withDescription( - ||| - TODO - ||| - ) + ts.standardOptions.withDecimals(0) + ts.fieldConfig.defaults.custom.stacking.withMode('normal') + ts.queryOptions.withTargets([ @@ -278,10 +273,12 @@ local hubResponseCodes = local allComponentsMemory = jupyterhub.memoryPanel( 'All JupyterHub Components', component='singleuser-server', + multi=true, ); local allComponentsCPU = jupyterhub.cpuPanel( 'All JupyterHub Components', component='singleuser-server', + multi=true, ); local hubDBUsage = diff --git a/dashboards/jupyterhub.libsonnet b/dashboards/jupyterhub.libsonnet index 4a79e1a..96ec93e 100644 --- a/dashboards/jupyterhub.libsonnet +++ b/dashboards/jupyterhub.libsonnet @@ -72,14 +72,16 @@ local prometheus = grafonnet.query.prometheus; * @param title The title of the timeseries panel. * @param metric The metric to be observed. * @param component The component to be measured (or excluded). + * Optional if `multi=true`, in which case it is an exclusion, otherwise required. + * @param multi (default `false`) If true, do a multi-component chart instead of single-component. + * The chart will have a legend table for each component. */ - componentResourcePanel(title, metric, component):: + componentResourcePanel(title, metric, component, multi, namespace):: ts.new(title) // show legend as a table with current, avg, max values //legend_hideZero=true, // legend_values is required for any of the above to work //legend_values=true, - //min=0, + ts.options.legend.withDisplayMode('table') + ts.options.legend.withCalcs(['min', 'mean', 'max']) + ts.queryOptions.withTargets([ @@ -94,11 +96,15 @@ local prometheus = grafonnet.query.prometheus; |||, [ metric, - self.onComponentLabel(component, cmp='!=', group_left='container, label_component'), + self.onComponentLabel( + component, + cmp=if multi then '!=' else '=', group_left='container, label_component', + namespace=namespace, + ), ], ) ) - + prometheus.withLegendFormat('{{ label_component }}'), + + prometheus.withLegendFormat(if multi then '{{ label_component }}' else title), ]), /** @@ -108,11 +114,16 @@ local prometheus = grafonnet.query.prometheus; * * @param name The name of the resource. Used to create the title. * @param component The component to be measured (or excluded). + * Optional if `multi=true`, in which case it is an exclusion, otherwise required. + * @param multi (default `false`) If true, do a multi-component chart instead of single-component. + * The chart will have a legend table for each component. */ - memoryPanel(name, component):: + memoryPanel(name, component, multi=false, namespace='$hub'):: self.componentResourcePanel( std.format('%s Memory (Working Set)', [name]), component=component, + multi=multi, + namespace=namespace, metric=||| # exclude name="" because the same container can be reported # with both no name and `name=k8s_...`, @@ -130,11 +141,16 @@ local prometheus = grafonnet.query.prometheus; * * @param name The name of the resource. Used to create the title. * @param component The component to be measured (or excluded). + * Optional if `multi=true`, in which case it is an exclusion, otherwise required. + * @param multi (default `false`) If true, do a multi-component chart instead of single-component. + * The chart will have a legend table for each component. */ - cpuPanel(name, component):: + cpuPanel(name, component, multi=false, namespace='$hub'):: self.componentResourcePanel( std.format('%s CPU', [name]), component=component, + multi=multi, + namespace=namespace, metric=||| # exclude name="" because the same container can be reported # with both no name and `name=k8s_...`, diff --git a/dashboards/support.jsonnet b/dashboards/support.jsonnet index 25c980d..c020d8b 100755 --- a/dashboards/support.jsonnet +++ b/dashboards/support.jsonnet @@ -112,6 +112,21 @@ local nfsServerReadLatency = ]); // Support Metrics + +// FIXME: Can we transition to using the function to generate the prometheus memory and cpu panels? +// +// Currently held back by hardcoded label selection on the label +// "component" and selection on a single label instead of optionally +// multiple. +// +//local prometheusMemory = jupyterhub.memoryPanel( +// 'Prometheus Memory (Working Set)', +// // app.kubernetes.io/component: server +// // app.kubernetes.io/name: prometheus +// component='singleuser-server', +// multi=false, +//); + local prometheusMemory = common.tsOptions + ts.new('Prometheus Memory (Working Set)')