Skip to content

Commit 7109132

Browse files
committed
feat(mixin): add "All" option to cluster variable in dashboards
Enable the cluster variable to support an "All" option in Grafana dashboards, allowing users to view metrics across all clusters or in environments where the cluster label may be missing. Changes: - Add includeAll with allValue=".*" to cluster variable definitions - Change all PromQL queries from exact matching (cluster="$cluster") to regex matching (cluster=~"$cluster") Affected dashboards: - Node Exporter / Nodes (Linux, Darwin, AIX) - USE Method / Node - USE Method / Cluster Signed-off-by: Willian Paixao <[email protected]>
1 parent b644734 commit 7109132

File tree

2 files changed

+78
-77
lines changed

2 files changed

+78
-77
lines changed

docs/node-mixin/dashboards/use.libsonnet

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ local diskSpaceUtilisation =
112112
)
113113
+ (if $._config.showMultiCluster then variable.query.generalOptions.showOnDashboard.withLabelAndValue() else variable.query.generalOptions.showOnDashboard.withNothing())
114114
+ variable.query.refresh.onTime()
115-
+ variable.query.selectionOptions.withIncludeAll(false)
115+
+ variable.query.selectionOptions.withIncludeAll(true, '.*')
116116
+ variable.query.withSort(asc=true),
117117

118118
grafanaDashboards+:: {
@@ -133,7 +133,7 @@ local diskSpaceUtilisation =
133133
+ variable.query.withDatasourceFromVariable(datasource)
134134
+ variable.query.queryTypes.withLabelValues(
135135
'instance',
136-
'node_exporter_build_info{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"}' % $._config,
136+
'node_exporter_build_info{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"}' % $._config,
137137
)
138138
+ variable.query.refresh.onTime()
139139
+ variable.query.withSort(asc=true),
@@ -142,29 +142,29 @@ local diskSpaceUtilisation =
142142
grafana.util.grid.makeGrid([
143143
row.new('CPU')
144144
+ row.withPanels([
145-
CPUUtilisation + tsQueryOptions.withTargets([prometheus.new('$datasource', 'instance:node_cpu_utilisation:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Utilisation')]),
146-
CPUSaturation + tsQueryOptions.withTargets([prometheus.new('$datasource', 'instance:node_load1_per_cpu:ratio{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Saturation')]),
145+
CPUUtilisation + tsQueryOptions.withTargets([prometheus.new('$datasource', 'instance:node_cpu_utilisation:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s=~"$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Utilisation')]),
146+
CPUSaturation + tsQueryOptions.withTargets([prometheus.new('$datasource', 'instance:node_load1_per_cpu:ratio{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s=~"$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Saturation')]),
147147
]),
148148
row.new('Memory')
149149
+ row.withPanels([
150-
memoryUtilisation + tsQueryOptions.withTargets([prometheus.new('$datasource', 'instance:node_memory_utilisation:ratio{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Utilisation')]),
151-
memorySaturation + tsQueryOptions.withTargets([prometheus.new('$datasource', 'instance:node_vmstat_pgmajfault:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Major page Faults')]),
150+
memoryUtilisation + tsQueryOptions.withTargets([prometheus.new('$datasource', 'instance:node_memory_utilisation:ratio{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s=~"$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Utilisation')]),
151+
memorySaturation + tsQueryOptions.withTargets([prometheus.new('$datasource', 'instance:node_vmstat_pgmajfault:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s=~"$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Major page Faults')]),
152152
]),
153153
row.new('Network')
154154
+ row.withPanels([
155155
networkUtilisation + tsQueryOptions.withTargets([
156-
prometheus.new('$datasource', 'instance:node_network_receive_bytes_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Receive'),
157-
prometheus.new('$datasource', 'instance:node_network_transmit_bytes_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Transmit'),
156+
prometheus.new('$datasource', 'instance:node_network_receive_bytes_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s=~"$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Receive'),
157+
prometheus.new('$datasource', 'instance:node_network_transmit_bytes_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s=~"$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Transmit'),
158158
]),
159159
networkSaturation + tsQueryOptions.withTargets([
160-
prometheus.new('$datasource', 'instance:node_network_receive_drop_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Receive'),
161-
prometheus.new('$datasource', 'instance:node_network_transmit_drop_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Transmit'),
160+
prometheus.new('$datasource', 'instance:node_network_receive_drop_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s=~"$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Receive'),
161+
prometheus.new('$datasource', 'instance:node_network_transmit_drop_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s=~"$cluster"} != 0' % $._config) + prometheus.withLegendFormat('Transmit'),
162162
]),
163163
]),
164164
row.new('Disk IO')
165165
+ row.withPanels([
166-
diskIOUtilisation + tsQueryOptions.withTargets([prometheus.new('$datasource', 'instance_device:node_disk_io_time_seconds:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} != 0' % $._config) + prometheus.withLegendFormat('{{device}}')]),
167-
diskIOSaturation + tsQueryOptions.withTargets([prometheus.new('$datasource', 'instance_device:node_disk_io_time_weighted_seconds:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} != 0' % $._config) + prometheus.withLegendFormat('{{device}}')]),
166+
diskIOUtilisation + tsQueryOptions.withTargets([prometheus.new('$datasource', 'instance_device:node_disk_io_time_seconds:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s=~"$cluster"} != 0' % $._config) + prometheus.withLegendFormat('{{device}}')]),
167+
diskIOSaturation + tsQueryOptions.withTargets([prometheus.new('$datasource', 'instance_device:node_disk_io_time_weighted_seconds:rate%(rateInterval)s{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s=~"$cluster"} != 0' % $._config) + prometheus.withLegendFormat('{{device}}')]),
168168
]),
169169
], panelWidth=12, panelHeight=7)
170170
+ grafana.util.grid.makeGrid([
@@ -176,9 +176,9 @@ local diskSpaceUtilisation =
176176
|||
177177
sort_desc(1 -
178178
(
179-
max without (mountpoint, fstype) (node_filesystem_avail_bytes{%(nodeExporterSelector)s, fstype!="", instance="$instance", %(clusterLabel)s="$cluster"})
179+
max without (mountpoint, fstype) (node_filesystem_avail_bytes{%(nodeExporterSelector)s, fstype!="", instance="$instance", %(clusterLabel)s=~"$cluster"})
180180
/
181-
max without (mountpoint, fstype) (node_filesystem_size_bytes{%(nodeExporterSelector)s, fstype!="", instance="$instance", %(clusterLabel)s="$cluster"})
181+
max without (mountpoint, fstype) (node_filesystem_size_bytes{%(nodeExporterSelector)s, fstype!="", instance="$instance", %(clusterLabel)s=~"$cluster"})
182182
) != 0
183183
)
184184
||| % $._config
@@ -210,11 +210,11 @@ local diskSpaceUtilisation =
210210
'$datasource',
211211
|||
212212
((
213-
instance:node_cpu_utilisation:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"}
213+
instance:node_cpu_utilisation:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"}
214214
*
215-
instance:node_num_cpu:sum{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"}
215+
instance:node_num_cpu:sum{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"}
216216
) != 0 )
217-
/ scalar(sum(instance:node_num_cpu:sum{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"}))
217+
/ scalar(sum(instance:node_num_cpu:sum{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"}))
218218
||| % $._config
219219
) + prometheus.withLegendFormat('{{ instance }}'),
220220
]),
@@ -223,8 +223,8 @@ local diskSpaceUtilisation =
223223
'$datasource',
224224
|||
225225
(
226-
instance:node_load1_per_cpu:ratio{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"}
227-
/ scalar(count(instance:node_load1_per_cpu:ratio{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"}))
226+
instance:node_load1_per_cpu:ratio{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"}
227+
/ scalar(count(instance:node_load1_per_cpu:ratio{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"}))
228228
) != 0
229229
||| % $._config
230230
) + prometheus.withLegendFormat('{{ instance }}'),
@@ -237,16 +237,16 @@ local diskSpaceUtilisation =
237237
'$datasource',
238238
|||
239239
(
240-
instance:node_memory_utilisation:ratio{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"}
241-
/ scalar(count(instance:node_memory_utilisation:ratio{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"}))
240+
instance:node_memory_utilisation:ratio{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"}
241+
/ scalar(count(instance:node_memory_utilisation:ratio{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"}))
242242
) != 0
243243
||| % $._config
244244
) + prometheus.withLegendFormat('{{ instance }}'),
245245
]),
246246
memorySaturation + tsQueryOptions.withTargets([
247247
prometheus.new(
248248
'$datasource',
249-
'instance:node_vmstat_pgmajfault:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"}' % $._config
249+
'instance:node_vmstat_pgmajfault:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"}' % $._config
250250
) + prometheus.withLegendFormat('{{ instance }}'),
251251
]),
252252
]),
@@ -255,21 +255,21 @@ local diskSpaceUtilisation =
255255
networkUtilisation + tsQueryOptions.withTargets([
256256
prometheus.new(
257257
'$datasource',
258-
'instance:node_network_receive_bytes_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"} != 0' % $._config
258+
'instance:node_network_receive_bytes_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"} != 0' % $._config
259259
) + prometheus.withLegendFormat('{{ instance }} Receive'),
260260
prometheus.new(
261261
'$datasource',
262-
'instance:node_network_transmit_bytes_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"} != 0' % $._config
262+
'instance:node_network_transmit_bytes_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"} != 0' % $._config
263263
) + prometheus.withLegendFormat('{{ instance }} Transmit'),
264264
]),
265265
networkSaturation + tsQueryOptions.withTargets([
266266
prometheus.new(
267267
'$datasource',
268-
'instance:node_network_receive_drop_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"} != 0' % $._config
268+
'instance:node_network_receive_drop_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"} != 0' % $._config
269269
) + prometheus.withLegendFormat('{{ instance }} Receive'),
270270
prometheus.new(
271271
'$datasource',
272-
'instance:node_network_transmit_drop_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"} != 0' % $._config
272+
'instance:node_network_transmit_drop_excluding_lo:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"} != 0' % $._config
273273
) + prometheus.withLegendFormat('{{ instance }} Transmit'),
274274
]),
275275
]),
@@ -279,16 +279,16 @@ local diskSpaceUtilisation =
279279
prometheus.new(
280280
'$datasource',
281281
|||
282-
instance_device:node_disk_io_time_seconds:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"}
283-
/ scalar(count(instance_device:node_disk_io_time_seconds:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"}))
282+
instance_device:node_disk_io_time_seconds:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"}
283+
/ scalar(count(instance_device:node_disk_io_time_seconds:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"}))
284284
||| % $._config
285285
) + prometheus.withLegendFormat('{{ instance }} {{device}}'),
286286
]),
287287
diskIOSaturation + tsQueryOptions.withTargets([prometheus.new(
288288
'$datasource',
289289
|||
290-
instance_device:node_disk_io_time_weighted_seconds:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"}
291-
/ scalar(count(instance_device:node_disk_io_time_weighted_seconds:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster"}))
290+
instance_device:node_disk_io_time_weighted_seconds:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"}
291+
/ scalar(count(instance_device:node_disk_io_time_weighted_seconds:rate%(rateInterval)s{%(nodeExporterSelector)s, %(clusterLabel)s=~"$cluster"}))
292292
||| % $._config
293293
) + prometheus.withLegendFormat('{{ instance }} {{device}}')]),
294294
]),
@@ -302,12 +302,12 @@ local diskSpaceUtilisation =
302302
|||
303303
sum without (device) (
304304
max without (fstype, mountpoint) ((
305-
node_filesystem_size_bytes{%(nodeExporterSelector)s, %(fsSelector)s, %(fsMountpointSelector)s, %(clusterLabel)s="$cluster"}
305+
node_filesystem_size_bytes{%(nodeExporterSelector)s, %(fsSelector)s, %(fsMountpointSelector)s, %(clusterLabel)s=~"$cluster"}
306306
-
307-
node_filesystem_avail_bytes{%(nodeExporterSelector)s, %(fsSelector)s, %(fsMountpointSelector)s, %(clusterLabel)s="$cluster"}
307+
node_filesystem_avail_bytes{%(nodeExporterSelector)s, %(fsSelector)s, %(fsMountpointSelector)s, %(clusterLabel)s=~"$cluster"}
308308
) != 0)
309309
)
310-
/ scalar(sum(max without (fstype, mountpoint) (node_filesystem_size_bytes{%(nodeExporterSelector)s, %(fsSelector)s, %(fsMountpointSelector)s, %(clusterLabel)s="$cluster"})))
310+
/ scalar(sum(max without (fstype, mountpoint) (node_filesystem_size_bytes{%(nodeExporterSelector)s, %(fsSelector)s, %(fsMountpointSelector)s, %(clusterLabel)s=~"$cluster"})))
311311
||| % $._config
312312
) + prometheus.withLegendFormat('{{ instance }}'),
313313
]),

0 commit comments

Comments
 (0)