@@ -3,14 +3,16 @@ local grafana = (import 'grafonnet/grafana.libsonnet');
3
3
local dashboard = grafana.dashboard;
4
4
local template = grafana.template;
5
5
local dashboardUid = 'clickhouse-latency' ;
6
- local matcher = 'job=~"$job", instance=~"$instance"' ;
6
+ local promDatasourceName = 'prometheus_datasource' ;
7
+ local getMatcher(cfg) = '%(clickhouseSelector)s' % cfg;
7
8
8
- local diskReadLatencyPanel =
9
+ local promDatasource = {
10
+ uid: '${%s}' % promDatasourceName,
11
+ };
12
+
13
+ local diskReadLatencyPanel(matcher) =
9
14
{
10
- datasource: {
11
- type: 'prometheus' ,
12
- uid: '${prometheus_datasource}' ,
13
- },
15
+ datasource: promDatasource,
14
16
description: 'Time spent waiting for read syscall' ,
15
17
fieldConfig: {
16
18
defaults: {
@@ -79,10 +81,7 @@ local diskReadLatencyPanel =
79
81
},
80
82
targets: [
81
83
{
82
- datasource: {
83
- type: 'prometheus' ,
84
- uid: '${prometheus_datasource}' ,
85
- },
84
+ datasource: promDatasource,
86
85
editorMode: 'builder' ,
87
86
expr: 'increase(ClickHouseProfileEvents_DiskReadElapsedMicroseconds{' + matcher + '}[$__rate_interval])' ,
88
87
legendFormat: 'Disk read elapsed' ,
@@ -94,12 +93,9 @@ local diskReadLatencyPanel =
94
93
type: 'timeseries' ,
95
94
};
96
95
97
- local diskWriteLatencyPanel =
96
+ local diskWriteLatencyPanel(matcher) =
98
97
{
99
- datasource: {
100
- type: 'prometheus' ,
101
- uid: '${prometheus_datasource}' ,
102
- },
98
+ datasource: promDatasource,
103
99
description: 'Time spent waiting for write syscall' ,
104
100
fieldConfig: {
105
101
defaults: {
@@ -168,10 +164,7 @@ local diskWriteLatencyPanel =
168
164
},
169
165
targets: [
170
166
{
171
- datasource: {
172
- type: 'prometheus' ,
173
- uid: '${prometheus_datasource}' ,
174
- },
167
+ datasource: promDatasource,
175
168
editorMode: 'builder' ,
176
169
expr: 'increase(ClickHouseProfileEvents_DiskWriteElapsedMicroseconds{' + matcher + '}[$__rate_interval])' ,
177
170
legendFormat: 'Disk write elapsed' ,
@@ -183,12 +176,9 @@ local diskWriteLatencyPanel =
183
176
type: 'timeseries' ,
184
177
};
185
178
186
- local networkTransmitLatencyPanel =
179
+ local networkTransmitLatencyPanel(matcher) =
187
180
{
188
- datasource: {
189
- type: 'prometheus' ,
190
- uid: '${prometheus_datasource}' ,
191
- },
181
+ datasource: promDatasource,
192
182
description: 'Latency of inbound network traffic' ,
193
183
fieldConfig: {
194
184
defaults: {
@@ -257,10 +247,7 @@ local networkTransmitLatencyPanel =
257
247
},
258
248
targets: [
259
249
{
260
- datasource: {
261
- type: 'prometheus' ,
262
- uid: '${prometheus_datasource}' ,
263
- },
250
+ datasource: promDatasource,
264
251
editorMode: 'builder' ,
265
252
expr: 'increase(ClickHouseProfileEvents_NetworkReceiveElapsedMicroseconds{' + matcher + '}[$__rate_interval])' ,
266
253
legendFormat: 'Network receive elapsed' ,
@@ -272,12 +259,9 @@ local networkTransmitLatencyPanel =
272
259
type: 'timeseries' ,
273
260
};
274
261
275
- local networkTransmitLatencyPanel =
262
+ local networkTransmitLatencyPanel(matcher) =
276
263
{
277
- datasource: {
278
- type: 'prometheus' ,
279
- uid: '${prometheus_datasource}' ,
280
- },
264
+ datasource: promDatasource,
281
265
description: 'Latency of outbound network traffic' ,
282
266
fieldConfig: {
283
267
defaults: {
@@ -346,10 +330,7 @@ local networkTransmitLatencyPanel =
346
330
},
347
331
targets: [
348
332
{
349
- datasource: {
350
- type: 'prometheus' ,
351
- uid: '${prometheus_datasource}' ,
352
- },
333
+ datasource: promDatasource,
353
334
editorMode: 'builder' ,
354
335
expr: 'increase(ClickHouseProfileEvents_NetworkSendElapsedMicroseconds{' + matcher + '}[$__rate_interval])' ,
355
336
legendFormat: 'Network send elapsed' ,
@@ -361,12 +342,9 @@ local networkTransmitLatencyPanel =
361
342
type: 'timeseries' ,
362
343
};
363
344
364
- local zooKeeperWaitTimePanel =
345
+ local zooKeeperWaitTimePanel(matcher) =
365
346
{
366
- datasource: {
367
- type: 'prometheus' ,
368
- uid: '${prometheus_datasource}' ,
369
- },
347
+ datasource: promDatasource,
370
348
description: 'Time spent waiting for ZooKeeper request to process' ,
371
349
fieldConfig: {
372
350
defaults: {
@@ -435,10 +413,7 @@ local zooKeeperWaitTimePanel =
435
413
},
436
414
targets: [
437
415
{
438
- datasource: {
439
- type: 'prometheus' ,
440
- uid: '${prometheus_datasource}' ,
441
- },
416
+ datasource: promDatasource,
442
417
editorMode: 'builder' ,
443
418
expr: 'increase(ClickHouseProfileEvents_ZooKeeperWaitMicroseconds{' + matcher + '}[$__rate_interval])' ,
444
419
legendFormat: 'ZooKeeper wait' ,
@@ -471,19 +446,17 @@ local zooKeeperWaitTimePanel =
471
446
tags=($._config.dashboardTags),
472
447
)).addTemplates(
473
448
[
474
- {
475
- hide: 0 ,
476
- label: 'Data source' ,
477
- name: 'prometheus_datasource' ,
478
- query: 'prometheus' ,
479
- refresh: 1 ,
480
- regex: '' ,
481
- type: 'datasource' ,
482
- },
449
+ template.datasource(
450
+ promDatasourceName,
451
+ 'prometheus' ,
452
+ null ,
453
+ label='Data source' ,
454
+ refresh='load'
455
+ ),
483
456
template.new(
484
457
name='job' ,
485
458
label='job' ,
486
- datasource='$prometheus_datasource' ,
459
+ datasource=promDatasource ,
487
460
query='label_values(ClickHouseProfileEvents_DiskReadElapsedMicroseconds,job)' ,
488
461
current='' ,
489
462
refresh=2 ,
@@ -495,29 +468,41 @@ local zooKeeperWaitTimePanel =
495
468
template.new(
496
469
name='instance' ,
497
470
label='instance' ,
498
- datasource='$prometheus_datasource' ,
471
+ datasource=promDatasource ,
499
472
query='label_values(ClickHouseProfileEvents_DiskReadElapsedMicroseconds{job=~"$job"}, instance)' ,
500
473
current='' ,
501
474
refresh=2 ,
502
475
includeAll=false ,
503
476
sort=1
504
477
),
478
+ template.new(
479
+ 'cluster' ,
480
+ promDatasource,
481
+ 'label_values(ClickHouseProfileEvents_DiskReadElapsedMicroseconds{job=~"$job"}, cluster)' ,
482
+ label='Cluster' ,
483
+ refresh=2 ,
484
+ includeAll=true ,
485
+ multi=true ,
486
+ allValues='' ,
487
+ hide=if $._config.enableMultiCluster then '' else 'variable' ,
488
+ sort=0
489
+ ),
505
490
]
506
491
)
507
492
.addPanels(
508
493
std.flattenArrays ([
509
494
[
510
- diskReadLatencyPanel { gridPos: { h: 8 , w: 12 , x: 0 , y: 0 } },
511
- diskWriteLatencyPanel { gridPos: { h: 8 , w: 12 , x: 12 , y: 0 } },
495
+ diskReadLatencyPanel(getMatcher($._config)) { gridPos: { h: 8 , w: 12 , x: 0 , y: 0 } },
496
+ diskWriteLatencyPanel(getMatcher($._config)) { gridPos: { h: 8 , w: 12 , x: 12 , y: 0 } },
512
497
],
513
498
//next row
514
499
[
515
- networkTransmitLatencyPanel { gridPos: { h: 8 , w: 12 , x: 0 , y: 8 } },
516
- networkTransmitLatencyPanel { gridPos: { h: 8 , w: 12 , x: 12 , y: 8 } },
500
+ networkTransmitLatencyPanel(getMatcher($._config)) { gridPos: { h: 8 , w: 12 , x: 0 , y: 8 } },
501
+ networkTransmitLatencyPanel(getMatcher($._config)) { gridPos: { h: 8 , w: 12 , x: 12 , y: 8 } },
517
502
],
518
503
//next row
519
504
[
520
- zooKeeperWaitTimePanel { gridPos: { h: 8 , w: 24 , x: 0 , y: 16 } },
505
+ zooKeeperWaitTimePanel(getMatcher($._config)) { gridPos: { h: 8 , w: 24 , x: 0 , y: 16 } },
521
506
],
522
507
])
523
508
),
0 commit comments