|
| 1 | +local g = import "./g.libsonnet"; |
| 2 | +local logslib = import "logs-lib/logs/main.libsonnet"; |
| 3 | +{ |
| 4 | + local root = self, |
| 5 | + new(this):: |
| 6 | + local prefix = this.config.dashboardNamePrefix; |
| 7 | + local links = this.grafana.links; |
| 8 | + local tags = this.config.dashboardTags; |
| 9 | + local uid = g.util.string.slugify(this.config.uid); |
| 10 | + local vars = this.grafana.variables; |
| 11 | + local annotations = this.grafana.annotations; |
| 12 | + local refresh = this.config.dashboardRefresh; |
| 13 | + local period = this.config.dashboardPeriod; |
| 14 | + local timezone = this.config.dashboardTimezone; |
| 15 | + local panels = this.grafana.panels; |
| 16 | + |
| 17 | + { |
| 18 | + "clickhouse-replica": |
| 19 | + g.dashboard.new(prefix + " replica") |
| 20 | + + g.dashboard.withPanels( |
| 21 | + g.util.grid.wrapPanels( |
| 22 | + [ |
| 23 | + panels.interserverConnectionsPanel { gridPos+: { h: 8, w: 12, x: 0, y: 0 } }, |
| 24 | + panels.replicaQueueSizePanel { gridPos+: { h: 8, w: 12, x: 12, y: 0 } }, |
| 25 | + panels.replicaOperationsPanel { gridPos+: { h: 8, w: 12, x: 0, y: 8 } }, |
| 26 | + panels.replicaReadOnlyPanel { gridPos+: { h: 8, w: 12, x: 12, y: 8 } }, |
| 27 | + panels.zooKeeperWatchesPanel { gridPos+: { h: 8, w: 12, x: 0, y: 16 } }, |
| 28 | + panels.zooKeeperSessionsPanel { gridPos+: { h: 8, w: 12, x: 12, y: 16 } }, |
| 29 | + panels.zooKeeperRequestsPanel { gridPos+: { h: 8, w: 24, x: 0, y: 24 } }, |
| 30 | + ] |
| 31 | + ) |
| 32 | + ) |
| 33 | + + root.applyCommon( |
| 34 | + vars.singleInstance, |
| 35 | + uid + "_clickhouse_replica", |
| 36 | + tags, |
| 37 | + links { clickhouseReplica+:: {} }, |
| 38 | + annotations, |
| 39 | + timezone, |
| 40 | + refresh, |
| 41 | + period |
| 42 | + ), |
| 43 | + |
| 44 | + "clickhouse-overview": |
| 45 | + g.dashboard.new(prefix + " overview") |
| 46 | + + g.dashboard.withPanels( |
| 47 | + g.util.grid.wrapPanels( |
| 48 | + [ |
| 49 | + panels.successfulQueriesPanel { gridPos+: { h: 8, w: 24, x: 0, y: 0 } }, |
| 50 | + panels.failedQueriesPanel { gridPos+: { h: 8, w: 12, x: 0, y: 8 } }, |
| 51 | + panels.rejectedInsertsPanel { gridPos+: { h: 8, w: 12, x: 12, y: 8 } }, |
| 52 | + panels.memoryUsagePanel { gridPos+: { h: 8, w: 12, x: 0, y: 16 } }, |
| 53 | + panels.memoryUsageGaugePanel { gridPos+: { h: 8, w: 12, x: 12, y: 16 } }, |
| 54 | + panels.activeConnectionsPanel { gridPos+: { h: 8, w: 24, x: 0, y: 24 } }, |
| 55 | + panels.networkReceivedPanel { gridPos+: { h: 8, w: 12, x: 0, y: 32 } }, |
| 56 | + panels.networkTransmittedPanel { gridPos+: { h: 8, w: 12, x: 12, y: 32 } }, |
| 57 | + ] |
| 58 | + ) |
| 59 | + ) |
| 60 | + + root.applyCommon( |
| 61 | + vars.singleInstance, |
| 62 | + uid + "_clickhouse_overview", |
| 63 | + tags, |
| 64 | + links { clickhouseOverview+:: {} }, |
| 65 | + annotations, |
| 66 | + timezone, |
| 67 | + refresh, |
| 68 | + period |
| 69 | + ), |
| 70 | + |
| 71 | + "clickhouse-latency": |
| 72 | + g.dashboard.new(prefix + " latency") |
| 73 | + + g.dashboard.withPanels( |
| 74 | + g.util.grid.wrapPanels( |
| 75 | + [ |
| 76 | + panels.diskReadLatencyPanel { gridPos+: { h: 8, w: 12, x: 0, y: 0 } }, |
| 77 | + panels.diskWriteLatencyPanel { gridPos+: { h: 8, w: 12, x: 12, y: 0 } }, |
| 78 | + panels.networkTransmitLatencyInboundPanel { gridPos+: { h: 8, w: 12, x: 0, y: 8 } }, |
| 79 | + panels.networkTransmitLatencyOutboundPanel { gridPos+: { h: 8, w: 12, x: 12, y: 8 } }, |
| 80 | + panels.zooKeeperWaitTimePanel { gridPos+: { h: 8, w: 24, x: 0, y: 16 } }, |
| 81 | + ] |
| 82 | + ) |
| 83 | + ) |
| 84 | + + root.applyCommon( |
| 85 | + vars.singleInstance, |
| 86 | + uid + "_clickhouse_latency", |
| 87 | + tags, |
| 88 | + links { clickhouseLatency+:: {} }, |
| 89 | + annotations, |
| 90 | + timezone, |
| 91 | + refresh, |
| 92 | + period |
| 93 | + ), |
| 94 | + |
| 95 | + } |
| 96 | + + |
| 97 | + if this.config.enableLokiLogs then |
| 98 | + { |
| 99 | + "clickhouse-logs": |
| 100 | + logslib.new( |
| 101 | + prefix + " logs", |
| 102 | + datasourceName=this.grafana.variables.datasources.loki.name, |
| 103 | + datasourceRegex=this.grafana.variables.datasources.loki.regex, |
| 104 | + filterSelector=this.config.filteringSelector, |
| 105 | + labels=this.config.groupLabels + this.config.extraLogLabels, |
| 106 | + formatParser=null, |
| 107 | + showLogsVolume=this.config.showLogsVolume, |
| 108 | + ) |
| 109 | + { |
| 110 | + dashboards+: |
| 111 | + { |
| 112 | + logs+: |
| 113 | + // reference to self, already generated variables, to keep them, but apply other common data in applyCommon |
| 114 | + root.applyCommon(super.logs.templating.list, uid=uid + "-logs", tags=tags, links=links { logs+:: {} }, annotations=annotations, timezone=timezone, refresh=refresh, period=period), |
| 115 | + }, |
| 116 | + panels+: |
| 117 | + { |
| 118 | + logs+: |
| 119 | + g.panel.logs.options.withEnableLogDetails(true) |
| 120 | + + g.panel.logs.options.withShowTime(false) |
| 121 | + + g.panel.logs.options.withWrapLogMessage(false), |
| 122 | + }, |
| 123 | + variables+: { |
| 124 | + // add prometheus datasource for annotations processing |
| 125 | + toArray+: [ |
| 126 | + this.grafana.variables.datasources.prometheus { hide: 2 }, |
| 127 | + ], |
| 128 | + }, |
| 129 | + }.dashboards.logs, |
| 130 | + } |
| 131 | + else {}, |
| 132 | + |
| 133 | + applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period): |
| 134 | + g.dashboard.withTags(tags) |
| 135 | + + g.dashboard.withUid(uid) |
| 136 | + + g.dashboard.withLinks(std.objectValues(links)) |
| 137 | + + g.dashboard.withTimezone(timezone) |
| 138 | + + g.dashboard.withRefresh(refresh) |
| 139 | + + g.dashboard.time.withFrom(period) |
| 140 | + + g.dashboard.withVariables(vars) |
| 141 | + + g.dashboard.withAnnotations(std.objectValues(annotations)), |
| 142 | +} |
0 commit comments