|
3 | 3 | // with useful stats about usage across all datasources
|
4 | 4 | local grafonnet = import 'grafonnet/main.libsonnet';
|
5 | 5 | local dashboard = grafonnet.dashboard;
|
6 |
| -local barGaugePanel = grafonnet.barGaugePanel; |
7 |
| -local prometheus = grafonnet.prometheus; |
| 6 | +local barGauge = grafonnet.panel.barGauge; |
| 7 | +local prometheus = grafonnet.query.prometheus; |
8 | 8 |
|
9 | 9 | function(datasources)
|
10 |
| - local weeklyActiveUsers = barGaugePanel.new( |
11 |
| - 'Active users (over 7 days)', |
12 |
| - datasource='-- Mixed --', |
13 |
| - thresholds=[ |
14 |
| - { |
15 |
| - value: 0, |
16 |
| - color: 'green', |
17 |
| - }, |
18 |
| - ], |
19 |
| - ).addTargets([ |
20 |
| - prometheus.target( |
21 |
| - // Removes any pods caused by stress testing |
22 |
| - ||| |
23 |
| - count( |
24 |
| - sum( |
25 |
| - min_over_time( |
26 |
| - kube_pod_labels{ |
27 |
| - label_app="jupyterhub", |
28 |
| - label_component="singleuser-server", |
29 |
| - label_hub_jupyter_org_username!~"(service|perf|hubtraf)-", |
30 |
| - }[7d] |
31 |
| - ) |
32 |
| - ) by (pod) |
33 |
| - ) |
34 |
| - |||, |
35 |
| - legendFormat=x, |
36 |
| - interval='7d', |
37 |
| - datasource=x |
38 |
| - ) |
39 |
| - // Create a target for each datasource |
40 |
| - for x in datasources |
41 |
| - ]); |
| 10 | + local weeklyActiveUsers = |
| 11 | + barGauge.new('Active users (over 7 days)') |
| 12 | + //thresholds=[ |
| 13 | + // { |
| 14 | + // value: 0, |
| 15 | + // color: 'green', |
| 16 | + // }, |
| 17 | + //], |
| 18 | + + barGauge.queryOptions.withInterval('7d') |
| 19 | + + barGauge.queryOptions.withTargets([ |
| 20 | + prometheus.new( |
| 21 | + x, |
| 22 | + // Removes any pods caused by stress testing |
| 23 | + ||| |
| 24 | + count( |
| 25 | + sum( |
| 26 | + min_over_time( |
| 27 | + kube_pod_labels{ |
| 28 | + label_app="jupyterhub", |
| 29 | + label_component="singleuser-server", |
| 30 | + label_hub_jupyter_org_username!~"(service|perf|hubtraf)-", |
| 31 | + }[7d] |
| 32 | + ) |
| 33 | + ) by (pod) |
| 34 | + ) |
| 35 | + |||, |
| 36 | + ) |
| 37 | + + prometheus.withLegendFormat(x) |
| 38 | + // Create a target for each datasource |
| 39 | + for x in datasources |
| 40 | + ]); |
42 | 41 |
|
43 |
| - dashboard.new( |
44 |
| - 'Global Usage Dashboard', |
45 |
| - uid='global-usage-dashboard', |
46 |
| - tags=['jupyterhub', 'global'], |
47 |
| - editable=true, |
48 |
| - time_from='now-7d', |
49 |
| - ).addPanel( |
50 |
| - weeklyActiveUsers, |
51 |
| - gridPos={ |
52 |
| - x: 0, |
53 |
| - y: 0, |
54 |
| - w: 25, |
55 |
| - h: 10, |
56 |
| - }, |
| 42 | + dashboard.new('Global Usage Dashboard') |
| 43 | + + dashboard.withUid('global-usage-dashboard') |
| 44 | + + dashboard.withTags(['jupyterhub', 'global']) |
| 45 | + + dashboard.withEditable(true) |
| 46 | + // time_from='now-7d', |
| 47 | + + dashboard.withPanels( |
| 48 | + grafonnet.util.grid.makeGrid([ |
| 49 | + weeklyActiveUsers, |
| 50 | + ]) |
| 51 | + // gridPos={ |
| 52 | + // x: 0, |
| 53 | + // y: 0, |
| 54 | + // w: 25, |
| 55 | + // h: 10, |
| 56 | + // }, |
57 | 57 | )
|
0 commit comments