Skip to content

Commit

Permalink
migrate: global-usage-stats.jsonnet
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Apr 6, 2024
1 parent 19ac66b commit 65b5ec8
Showing 1 changed file with 48 additions and 48 deletions.
96 changes: 48 additions & 48 deletions global-dashboards/global-usage-stats.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,55 @@
// with useful stats about usage across all datasources
local grafonnet = import 'grafonnet/main.libsonnet';
local dashboard = grafonnet.dashboard;
local barGaugePanel = grafonnet.barGaugePanel;
local prometheus = grafonnet.prometheus;
local barGauge = grafonnet.panel.barGauge;
local prometheus = grafonnet.query.prometheus;

function(datasources)
local weeklyActiveUsers = barGaugePanel.new(
'Active users (over 7 days)',
datasource='-- Mixed --',
thresholds=[
{
value: 0,
color: 'green',
},
],
).addTargets([
prometheus.target(
// Removes any pods caused by stress testing
|||
count(
sum(
min_over_time(
kube_pod_labels{
label_app="jupyterhub",
label_component="singleuser-server",
label_hub_jupyter_org_username!~"(service|perf|hubtraf)-",
}[7d]
)
) by (pod)
)
|||,
legendFormat=x,
interval='7d',
datasource=x
)
// Create a target for each datasource
for x in datasources
]);
local weeklyActiveUsers =
barGauge.new('Active users (over 7 days)')
//thresholds=[
// {
// value: 0,
// color: 'green',
// },
//],
+ barGauge.queryOptions.withInterval('7d')
+ barGauge.queryOptions.withTargets([
prometheus.new(
x,
// Removes any pods caused by stress testing
|||
count(
sum(
min_over_time(
kube_pod_labels{
label_app="jupyterhub",
label_component="singleuser-server",
label_hub_jupyter_org_username!~"(service|perf|hubtraf)-",
}[7d]
)
) by (pod)
)
|||,
)
+ prometheus.withLegendFormat(x)
// Create a target for each datasource
for x in datasources
]);

dashboard.new(
'Global Usage Dashboard',
uid='global-usage-dashboard',
tags=['jupyterhub', 'global'],
editable=true,
time_from='now-7d',
).addPanel(
weeklyActiveUsers,
gridPos={
x: 0,
y: 0,
w: 25,
h: 10,
},
dashboard.new('Global Usage Dashboard')
+ dashboard.withUid('global-usage-dashboard')
+ dashboard.withTags(['jupyterhub', 'global'])
+ dashboard.withEditable(true)
// time_from='now-7d',
+ dashboard.withPanels(
grafonnet.util.grid.makeGrid([
weeklyActiveUsers,
])
// gridPos={
// x: 0,
// y: 0,
// w: 25,
// h: 10,
// },
)

0 comments on commit 65b5ec8

Please sign in to comment.