Skip to content

Commit 9c581aa

Browse files
authored
Merge branch 'main' into pre-commit-ci-update-config
2 parents a2b09e2 + eb113a9 commit 9c581aa

2 files changed

Lines changed: 133 additions & 26 deletions

File tree

dashboards/cloud-cost-aws.jsonnet

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ local dailyCostsPerComponent =
8181
+ ts.new('Total daily costs per component')
8282
+ ts.panelOptions.withDescription(
8383
|||
84-
Components are human friendly groupings of AWS services, as [defined
85-
here](https://github.com/2i2c-org/infrastructure/blob/main/helm-charts/jupyterhub-cost-monitoring/mounted-files/const.py#L11-L20).
84+
Components are human-friendly groupings of AWS services, as [defined
85+
here](https://github.com/2i2c-org/jupyterhub-cost-monitoring/blob/6465946221dd0ecdba622bf482db3844e6fb1f06/src/jupyterhub_cost_monitoring/const_cost_aws.py#L11).
8686
8787
---
8888
@@ -92,19 +92,22 @@ local dailyCostsPerComponent =
9292
- All costs are pure usage costs, and doesn't consider credits etc.
9393
|||
9494
)
95-
+ ts.queryOptions.withTargets([
96-
common.queryComponentTarget
97-
{
98-
url: 'http://jupyterhub-cost-monitoring.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}',
99-
},
100-
])
95+
+ common.tsStylingComponents
96+
+ ts.queryOptions.withTargets(common.queryComponentArray)
10197
+ ts.queryOptions.withTransformations([
102-
ts.queryOptions.transformation.withId('groupingToMatrix')
98+
ts.queryOptions.transformation.withId('prepareTimeSeries')
99+
+ ts.queryOptions.transformation.withOptions({
100+
"format": "wide",
101+
}),
102+
ts.queryOptions.transformation.withId('organize')
103103
+ ts.queryOptions.transformation.withOptions({
104-
columnField: 'Component',
105-
emptyValue: 'zero',
106-
rowField: 'Date',
107-
valueField: 'Cost',
104+
"renameByName": {
105+
"Cost compute": "compute",
106+
"Cost home storage": "home storage",
107+
"Cost object storage": "object storage",
108+
"Cost core": "core",
109+
"Cost networking": "networking",
110+
},
108111
}),
109112
])
110113
;
@@ -116,7 +119,7 @@ local dailyCostsPerComponentAndHub =
116119
+ ts.panelOptions.withDescription(
117120
|||
118121
Components are human friendly groupings of AWS services, as [defined
119-
here](https://github.com/2i2c-org/infrastructure/blob/main/helm-charts/jupyterhub-cost-monitoring/mounted-files/const.py#L11-L20).
122+
here](https://github.com/2i2c-org/jupyterhub-cost-monitoring/blob/6465946221dd0ecdba622bf482db3844e6fb1f06/src/jupyterhub_cost_monitoring/const_cost_aws.py#L11).
120123
121124
**Note**
122125
@@ -126,21 +129,24 @@ local dailyCostsPerComponentAndHub =
126129
- All costs are pure usage costs, and doesn't consider credits etc.
127130
|||
128131
)
132+
+ common.tsStylingComponents
129133
+ ts.panelOptions.withRepeat('hub_general')
130134
+ ts.panelOptions.withMaxPerRow(2)
131-
+ ts.queryOptions.withTargets([
132-
common.queryComponentTarget
133-
{
134-
url: 'http://jupyterhub-cost-monitoring.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}&hub=$hub_general',
135-
},
136-
])
135+
+ ts.queryOptions.withTargets(common.queryComponentHubArray)
137136
+ ts.queryOptions.withTransformations([
138-
ts.queryOptions.transformation.withId('groupingToMatrix')
137+
ts.queryOptions.transformation.withId('prepareTimeSeries')
138+
+ ts.queryOptions.transformation.withOptions({
139+
"format": "wide",
140+
}),
141+
ts.queryOptions.transformation.withId('organize')
139142
+ ts.queryOptions.transformation.withOptions({
140-
columnField: 'Component',
141-
emptyValue: 'zero',
142-
rowField: 'Date',
143-
valueField: 'Cost',
143+
"renameByName": {
144+
"Cost compute": "compute",
145+
"Cost home storage": "home storage",
146+
"Cost object storage": "object storage",
147+
"Cost core": "core",
148+
"Cost networking": "networking",
149+
},
144150
}),
145151
])
146152
;

dashboards/common.libsonnet

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,55 @@ local bg = grafonnet.panel.barGauge;
180180
data: '',
181181
},
182182
format: 'table',
183-
refId: 'A',
184183
},
185184

185+
// Individual queries for each component for accurate aggregation in table totals in the legend.
186+
queryComponentArray: [
187+
$.queryComponentTarget + {
188+
url: 'http://jupyterhub-cost-monitoring.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}' + '&component=compute',
189+
refid: 'compute',
190+
},
191+
$.queryComponentTarget + {
192+
url: 'http://jupyterhub-cost-monitoring.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}' + '&component=home%20storage',
193+
refid: 'home storage',
194+
},
195+
$.queryComponentTarget + {
196+
url: 'http://jupyterhub-cost-monitoring.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}' + '&component=object%20storage',
197+
refid: 'object storage',
198+
},
199+
$.queryComponentTarget + {
200+
url: 'http://jupyterhub-cost-monitoring.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}' + '&component=core',
201+
refid: 'core',
202+
},
203+
$.queryComponentTarget + {
204+
url: 'http://jupyterhub-cost-monitoring.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}' + '&component=networking',
205+
refid: 'networking',
206+
},
207+
],
208+
209+
queryComponentHubArray: [
210+
$.queryComponentTarget + {
211+
url: 'http://jupyterhub-cost-monitoring.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}' + '&component=compute' + '&hub=$hub_general',
212+
refid: 'compute',
213+
},
214+
$.queryComponentTarget + {
215+
url: 'http://jupyterhub-cost-monitoring.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}' + '&component=home%20storage' + '&hub=$hub_general',
216+
refid: 'home storage',
217+
},
218+
$.queryComponentTarget + {
219+
url: 'http://jupyterhub-cost-monitoring.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}' + '&component=object%20storage' + '&hub=$hub_general',
220+
refid: 'object storage',
221+
},
222+
$.queryComponentTarget + {
223+
url: 'http://jupyterhub-cost-monitoring.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}' + '&component=core' + '&hub=$hub_general',
224+
refid: 'core',
225+
},
226+
$.queryComponentTarget + {
227+
url: 'http://jupyterhub-cost-monitoring.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}' + '&component=networking' + '&hub=$hub_general',
228+
refid: 'networking',
229+
},
230+
],
231+
186232
queryUsersTarget: {
187233
datasource: {
188234
type: 'yesoreyeram-infinity-datasource',
@@ -252,6 +298,7 @@ local bg = grafonnet.panel.barGauge;
252298
+ ts.fieldConfig.defaults.custom.withLineInterpolation('stepAfter')
253299
+ ts.fieldConfig.defaults.custom.withFillOpacity(10)
254300
+ ts.standardOptions.withUnit('currencyUSD')
301+
+ ts.standardOptions.withNoValue('$0.00')
255302
+ ts.standardOptions.withDecimals(2)
256303
+ ts.options.withLegend({
257304
calcs: [
@@ -328,4 +375,58 @@ local bg = grafonnet.panel.barGauge;
328375
+ bg.standardOptions.withMin(0)
329376
+ bg.standardOptions.withDecimals(2)
330377
+ bg.standardOptions.withUnit('currencyUSD'),
378+
379+
tsStylingComponents:
380+
ts.standardOptions.withOverrides([
381+
{
382+
matcher: { id: 'byName', options: 'compute' },
383+
properties: [{
384+
id: 'color',
385+
value: {
386+
fixedColor: 'blue',
387+
mode: 'fixed',
388+
},
389+
}],
390+
},
391+
{
392+
matcher: { id: 'byName', options: 'home storage' },
393+
properties: [{
394+
id: 'color',
395+
value: {
396+
fixedColor: 'yellow',
397+
mode: 'fixed',
398+
},
399+
}],
400+
},
401+
{
402+
matcher: { id: 'byName', options: 'object storage' },
403+
properties: [{
404+
id: 'color',
405+
value: {
406+
fixedColor: 'red',
407+
mode: 'fixed',
408+
},
409+
}],
410+
},
411+
{
412+
matcher: { id: 'byName', options: 'core' },
413+
properties: [{
414+
id: 'color',
415+
value: {
416+
fixedColor: 'green',
417+
mode: 'fixed',
418+
},
419+
}],
420+
},
421+
{
422+
matcher: { id: 'byName', options: 'networking' },
423+
properties: [{
424+
id: 'color',
425+
value: {
426+
fixedColor: 'orange',
427+
mode: 'fixed',
428+
},
429+
}],
430+
},
431+
])
331432
}

0 commit comments

Comments
 (0)