Skip to content

Commit 9bcc61b

Browse files
committed
migrate: add back unused functionality in libsonnet
I think we could manage to get prometheus server cpu/metrics etc presented with the same helper functions if we retain these things.
1 parent ddcb0e5 commit 9bcc61b

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

dashboards/jupyterhub.jsonnet

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ local jupyterhub = import 'jupyterhub.libsonnet';
1616
local currentActiveUsers =
1717
common.tsOptions
1818
+ ts.new('Currently Active Users')
19-
+ ts.panelOptions.withDescription(
20-
|||
21-
TODO
22-
|||
23-
)
2419
+ ts.standardOptions.withDecimals(0)
2520
+ ts.fieldConfig.defaults.custom.stacking.withMode('normal')
2621
+ ts.queryOptions.withTargets([
@@ -278,10 +273,12 @@ local hubResponseCodes =
278273
local allComponentsMemory = jupyterhub.memoryPanel(
279274
'All JupyterHub Components',
280275
component='singleuser-server',
276+
multi=true,
281277
);
282278
local allComponentsCPU = jupyterhub.cpuPanel(
283279
'All JupyterHub Components',
284280
component='singleuser-server',
281+
multi=true,
285282
);
286283

287284
local hubDBUsage =

dashboards/jupyterhub.libsonnet

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,16 @@ local prometheus = grafonnet.query.prometheus;
7272
* @param title The title of the timeseries panel.
7373
* @param metric The metric to be observed.
7474
* @param component The component to be measured (or excluded).
75+
* Optional if `multi=true`, in which case it is an exclusion, otherwise required.
76+
* @param multi (default `false`) If true, do a multi-component chart instead of single-component.
77+
* The chart will have a legend table for each component.
7578
*/
76-
componentResourcePanel(title, metric, component)::
79+
componentResourcePanel(title, metric, component, multi, namespace)::
7780
ts.new(title)
7881
// show legend as a table with current, avg, max values
7982
//legend_hideZero=true,
8083
// legend_values is required for any of the above to work
8184
//legend_values=true,
82-
//min=0,
8385
+ ts.options.legend.withDisplayMode('table')
8486
+ ts.options.legend.withCalcs(['min', 'mean', 'max'])
8587
+ ts.queryOptions.withTargets([
@@ -94,11 +96,15 @@ local prometheus = grafonnet.query.prometheus;
9496
|||,
9597
[
9698
metric,
97-
self.onComponentLabel(component, cmp='!=', group_left='container, label_component'),
99+
self.onComponentLabel(
100+
component,
101+
cmp=if multi then '!=' else '=', group_left='container, label_component',
102+
namespace=namespace,
103+
),
98104
],
99105
)
100106
)
101-
+ prometheus.withLegendFormat('{{ label_component }}'),
107+
+ prometheus.withLegendFormat(if multi then '{{ label_component }}' else title),
102108
]),
103109

104110
/**
@@ -108,11 +114,16 @@ local prometheus = grafonnet.query.prometheus;
108114
*
109115
* @param name The name of the resource. Used to create the title.
110116
* @param component The component to be measured (or excluded).
117+
* Optional if `multi=true`, in which case it is an exclusion, otherwise required.
118+
* @param multi (default `false`) If true, do a multi-component chart instead of single-component.
119+
* The chart will have a legend table for each component.
111120
*/
112-
memoryPanel(name, component)::
121+
memoryPanel(name, component, multi=false, namespace='$hub')::
113122
self.componentResourcePanel(
114123
std.format('%s Memory (Working Set)', [name]),
115124
component=component,
125+
multi=multi,
126+
namespace=namespace,
116127
metric=|||
117128
# exclude name="" because the same container can be reported
118129
# with both no name and `name=k8s_...`,
@@ -130,11 +141,16 @@ local prometheus = grafonnet.query.prometheus;
130141
*
131142
* @param name The name of the resource. Used to create the title.
132143
* @param component The component to be measured (or excluded).
144+
* Optional if `multi=true`, in which case it is an exclusion, otherwise required.
145+
* @param multi (default `false`) If true, do a multi-component chart instead of single-component.
146+
* The chart will have a legend table for each component.
133147
*/
134-
cpuPanel(name, component)::
148+
cpuPanel(name, component, multi=false, namespace='$hub')::
135149
self.componentResourcePanel(
136150
std.format('%s CPU', [name]),
137151
component=component,
152+
multi=multi,
153+
namespace=namespace,
138154
metric=|||
139155
# exclude name="" because the same container can be reported
140156
# with both no name and `name=k8s_...`,

dashboards/support.jsonnet

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,21 @@ local nfsServerReadLatency =
112112
]);
113113

114114
// Support Metrics
115+
116+
// FIXME: Can we transition to using the function to generate the prometheus memory and cpu panels?
117+
//
118+
// Currently held back by hardcoded label selection on the label
119+
// "component" and selection on a single label instead of optionally
120+
// multiple.
121+
//
122+
//local prometheusMemory = jupyterhub.memoryPanel(
123+
// 'Prometheus Memory (Working Set)',
124+
// // app.kubernetes.io/component: server
125+
// // app.kubernetes.io/name: prometheus
126+
// component='singleuser-server',
127+
// multi=false,
128+
//);
129+
115130
local prometheusMemory =
116131
common.tsOptions
117132
+ ts.new('Prometheus Memory (Working Set)')

0 commit comments

Comments
 (0)