11#!/usr/bin/env -S jsonnet -J ../../vendor
22local grafonnet = import '../../vendor/gen/grafonnet-v11.4.0/main.libsonnet' ;
33local dashboard = grafonnet.dashboard;
4+ local ts = grafonnet.panel.timeSeries;
45local bc = grafonnet.panel.barChart;
56local bg = grafonnet.panel.barGauge;
67local tb = grafonnet.panel.table;
@@ -132,33 +133,28 @@ local NoGroup =
132133
133134local Hub =
134135 common.bcOptions
135- + bc .new('Hub – $hub_user, Component – $component' )
136- + bc .panelOptions.withDescription(
136+ + ts .new('Hub – $hub_user, Component – $component' )
137+ + ts .panelOptions.withDescription(
137138 |||
138139 Shows daily group costs by hub, with a total across all hubs, components and groups shown by default.
139140
140141 Try toggling the *hub*, *component* and *group* variable dropdown above to filter per group costs.
141142 |||
142143 )
143- + bg .panelOptions.withGridPos(h=12 , w=24 , x=0 , y=8 )
144- + bc .queryOptions.withTargets([
144+ + ts .panelOptions.withGridPos(h=12 , w=24 , x=0 , y=8 )
145+ + ts .queryOptions.withTargets([
145146 common.queryUsersTarget
146147 {
147148 url: 'http://jupyterhub-cost-monitoring.support.svc.cluster.local/costs-per-user?from=${__from:date}&to=${__to:date}&hub=$hub_user&component=$component&usergroup=$usergroup' ,
148149 },
149150 ])
150- + bc.panelOptions.withRepeat('hub_user' )
151- + bc.panelOptions.withRepeatDirection('v' )
152- + bc.queryOptions.withTransformations([
153- bc.queryOptions.transformation.withId('formatTime' )
154- + bc.queryOptions.transformation.withOptions({
155- "outputFormat" : "MMM DD" ,
156- "timeField" : "Date" ,
157- "timezone" : "utc" ,
158- "useTimezone" : true
159- }),
160- bc.queryOptions.transformation.withId('groupBy' )
161- + bc.queryOptions.transformation.withOptions({
151+ + ts.panelOptions.withRepeat('hub_user' )
152+ + ts.panelOptions.withRepeatDirection('v' )
153+ + ts.fieldConfig.defaults.custom.withLineInterpolation('stepAfter' )
154+ + ts.fieldConfig.defaults.custom.withFillOpacity(10 )
155+ + ts.queryOptions.withTransformations([
156+ ts.queryOptions.transformation.withId('groupBy' )
157+ + ts.queryOptions.transformation.withOptions({
162158 fields: {
163159 Cost: {
164160 aggregations: [
@@ -176,13 +172,15 @@ local Hub =
176172 },
177173 },
178174 }),
179- bc.queryOptions.transformation.withId('groupingToMatrix' )
180- + bc.queryOptions.transformation.withOptions({
181- "columnField" : "Group" ,
182- "emptyValue" : "zero" ,
183- "rowField" : "Date" ,
184- "valueField" : "Cost (sum)"
185- })
175+ ts.queryOptions.transformation.withId('prepareTimeSeries' )
176+ + ts.queryOptions.transformation.withOptions({
177+ "format" : "multi"
178+ }),
179+ ts.queryOptions.transformation.withId('renameByRegex' )
180+ + ts.queryOptions.transformation.withOptions({
181+ "regex" : "^Cost \\ (sum\\ )\\ s*(.*)$" ,
182+ "renamePattern" : "$1"
183+ }),
186184 ])
187185;
188186
0 commit comments