1
1
#!/usr/bin/env -S jsonnet -J ../vendor
2
- local grafonnet = import 'github.com/grafana/ grafonnet/gen/grafonnet-v10.4.0 /main.libsonnet' ;
2
+ local grafonnet = import 'grafonnet/main.libsonnet' ;
3
3
local dashboard = grafonnet.dashboard;
4
4
local ts = grafonnet.panel.timeSeries;
5
5
local var = grafonnet.dashboard.variable;
6
6
7
+ local common = import './common.libsonnet' ;
8
+
9
+
7
10
local totalDailyCosts =
8
11
ts.new('Total daily costs' )
9
12
+ ts.panelOptions.withDescription(
@@ -30,17 +33,28 @@ local totalDailyCosts =
30
33
+ ts.standardOptions.withUnit('currencyUSD' )
31
34
+ ts.queryOptions.withTargets([
32
35
{
33
- datasource: { type: 'yesoreyeram-infinity-datasource' , uid: 'fdsrfvebctptsf' },
36
+ datasource: {
37
+ type: 'yesoreyeram-infinity-datasource' ,
38
+ uid: '${infinity_datasource}' ,
39
+ },
34
40
url: "http://aws-ce-grafana-backend.support.svc.cluster.local/total-costs?from=${__from:date}&to=${__to:date}" ,
35
41
format: "table" ,
36
42
refId: "A" ,
37
43
columns: [
38
44
{selector: "cost" , text: "Cost" , type: "number" , unit: "currencyUSD" },
39
45
{selector: "date" , text: "Date" , type: "timestamp" }
40
- ]
46
+ ],
47
+ parser: "backend" ,
48
+ type: "json" ,
49
+ source: "url" ,
50
+ url_options: {
51
+ "method" : "GET" ,
52
+ "data" : "" ,
53
+ },
41
54
}
42
55
]);
43
56
57
+
44
58
local totalDailyCostsPerHub =
45
59
ts.new('Total daily costs per hub' )
46
60
+ ts.panelOptions.withDescription(
@@ -75,7 +89,10 @@ local totalDailyCostsPerHub =
75
89
+ ts.standardOptions.withUnit('currencyUSD' )
76
90
+ ts.queryOptions.withTargets([
77
91
{
78
- datasource: { type: 'yesoreyeram-infinity-datasource' , uid: 'fdsrfvebctptsf' },
92
+ datasource: {
93
+ type: 'yesoreyeram-infinity-datasource' ,
94
+ uid: '${infinity_datasource}' ,
95
+ },
79
96
url: "http://aws-ce-grafana-backend.support.svc.cluster.local/total-costs-per-hub?from=${__from:date}&to=${__to:date}" ,
80
97
format: "timeseries" ,
81
98
refId: "A" ,
@@ -84,20 +101,16 @@ local totalDailyCostsPerHub =
84
101
{selector: "name" , text: "Name" , type: "string" },
85
102
{selector: "cost" , text: "Cost" , type: "number" }
86
103
],
104
+ parser: "backend" ,
105
+ type: "json" ,
106
+ source: "url" ,
107
+ url_options: {
108
+ "method" : "GET" ,
109
+ "data" : "" ,
110
+ },
87
111
}
88
112
]);
89
113
90
- local hubQueryVar =
91
- var.query.new('hub' )
92
- + var.query.queryTypes.withLabelValues(
93
- 'Hub' ,
94
- )
95
- + var.query.withDatasource(
96
- type= 'yesoreyeram-infinity-datasource' , uid='fdsrfvebctptsf'
97
-
98
- )
99
- + var.query.selectionOptions.withIncludeAll();
100
-
101
114
102
115
local totalDailyCostsPerComponent =
103
116
ts.new('Total daily costs per component' )
@@ -133,7 +146,10 @@ local totalDailyCostsPerComponent =
133
146
+ ts.standardOptions.withUnit('currencyUSD' )
134
147
+ ts.queryOptions.withTargets([
135
148
{
136
- datasource: { type: 'yesoreyeram-infinity-datasource' , uid: 'fdsrfvebctptsf' },
149
+ datasource: {
150
+ type: 'yesoreyeram-infinity-datasource' ,
151
+ uid: '${infinity_datasource}' ,
152
+ },
137
153
url: "http://aws-ce-grafana-backend.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}" ,
138
154
format: "timeseries" ,
139
155
refId: "A" ,
@@ -142,17 +158,26 @@ local totalDailyCostsPerComponent =
142
158
{selector: "name" , text: "Name" , type: "string" },
143
159
{selector: "cost" , text: "Cost" , type: "number" }
144
160
],
161
+ parser: "backend" ,
162
+ type: "json" ,
163
+ source: "url" ,
164
+ url_options: {
165
+ "method" : "GET" ,
166
+ "data" : "" ,
167
+ },
145
168
}
146
169
]);
147
170
148
171
149
- local totalDailyCostsPerComponentandHub =
172
+ local totalDailyCostsPerComponentAndHub =
150
173
ts.new('Total daily costs per component, for ${hub}' )
151
174
+ ts.panelOptions.withDescription(
152
175
|||
153
176
Total daily costs per component, for ${hub}
154
177
|||
155
178
)
179
+ + ts.panelOptions.withRepeat('hub' )
180
+ + ts.panelOptions.withMaxPerRow(2 )
156
181
+ ts.options.withTooltip({ mode: 'single' , sort: "none" })
157
182
+ ts.options.withLegend({
158
183
"calcs" : [
@@ -180,7 +205,10 @@ local totalDailyCostsPerComponentandHub =
180
205
+ ts.standardOptions.withUnit('currencyUSD' )
181
206
+ ts.queryOptions.withTargets([
182
207
{
183
- datasource: { type: 'yesoreyeram-infinity-datasource' , uid: 'fdsrfvebctptsf' },
208
+ datasource: {
209
+ type: 'yesoreyeram-infinity-datasource' ,
210
+ uid: '${infinity_datasource}' ,
211
+ },
184
212
url: "http://aws-ce-grafana-backend.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}&hub=${hub}" ,
185
213
format: "timeseries" ,
186
214
refId: "A" ,
@@ -189,22 +217,32 @@ local totalDailyCostsPerComponentandHub =
189
217
{selector: "name" , text: "Name" , type: "string" },
190
218
{selector: "cost" , text: "Cost" , type: "number" }
191
219
],
220
+ parser: "backend" ,
221
+ type: "json" ,
222
+ source: "url" ,
223
+ url_options: {
224
+ "method" : "GET" ,
225
+ "data" : "" ,
226
+ },
192
227
}
193
228
]);
194
229
195
230
196
231
dashboard.new('Cloud cost attribution' )
197
- + dashboard.withUid('edw06h7udjwg0b ' )
232
+ + dashboard.withUid('cloud-cost-attribution ' )
198
233
+ dashboard.withEditable(true )
199
234
+ dashboard.time.withFrom('now-30d' )
200
- + dashboard.withVariables(hubQueryVar)
235
+ + dashboard.withVariables([
236
+ common.variables.hub,
237
+ common.variables.infinity_datasource,
238
+ ])
201
239
+ dashboard.withPanels(
202
240
grafonnet.util.grid.makeGrid(
203
241
[
204
242
totalDailyCosts,
205
243
totalDailyCostsPerHub,
206
244
totalDailyCostsPerComponent,
207
- totalDailyCostsPerComponentandHub
245
+ totalDailyCostsPerComponentAndHub
208
246
],
209
247
panelWidth=24 ,
210
248
panelHeight=12 ,
0 commit comments