Skip to content

Commit 18f7387

Browse files
schmikeiv-zhuravlev
authored andcommitted
update clickhouse to latest mixin standards
1 parent c014522 commit 18f7387

24 files changed

+2190
-4516
lines changed

clickhouse-mixin/alerts/alerts.libsonnet renamed to clickhouse-mixin/alerts.libsonnet

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
2-
prometheusAlerts+:: {
3-
groups+: [
2+
new(this): {
3+
groups: [
44
{
55
name: 'ClickHouseAlerts',
66
rules: [
77
{
88
alert: 'ClickHouseReplicationQueueBackingUp',
99
expr: |||
1010
ClickHouseAsyncMetrics_ReplicasMaxQueueSize > %(alertsReplicasMaxQueueSize)s
11-
||| % $._config,
11+
||| % this.config,
1212
labels: {
1313
severity: 'warning',
1414
},
1515
annotations: {
1616
summary: 'ClickHouse replica max queue size backing up.',
1717
description: |||
1818
ClickHouse replication tasks are processing slower than expected on {{ $labels.instance }} causing replication queue size to back up at {{ $value }} exceeding the threshold value of %(alertsReplicasMaxQueueSize)s.
19-
||| % $._config,
19+
||| % this.config,
2020
},
2121
'for': '5m',
2222
keep_firing_for: '5m',

clickhouse-mixin/config.libsonnet

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
{
2-
_config+:: {
3-
enableMultiCluster: false,
4-
clickhouseSelector: if self.enableMultiCluster then 'job=~"$job", instance=~"$instance", cluster=~"$cluster"' else 'job=~"$job", instance=~"$instance"',
2+
enableMultiCluster: false,
3+
filteringSelector: 'job=~".*/clickhouse.*"',
4+
groupLabels: if self.enableMultiCluster then ["job", "cluster"] else ["job"],
5+
instanceLabels: ["instance"],
6+
dashboardTags: ["clickhouse-mixin"],
7+
uid: "clickhouse",
8+
dashboardNamePrefix: "ClickHouse",
59

6-
dashboardTags: ['clickhouse-mixin'],
7-
dashboardPeriod: 'now-30m',
8-
dashboardTimezone: 'default',
9-
dashboardRefresh: '1m',
10-
logLabels: if self.enableMultiCluster then ['job', 'instance', 'cluster', 'level']
11-
else ['job', 'instance', 'level'],
10+
// additional params
11+
dashboardPeriod: "now-30m",
12+
dashboardTimezone: "default",
13+
dashboardRefresh: "1m",
1214

13-
// for alerts
14-
alertsReplicasMaxQueueSize: '99',
15+
enableLokiLogs: true,
16+
logLabels: if self.enableMultiCluster then ["job", "instance", "cluster", "level"] else ["job", "instance", "level"],
17+
extraLogLabels: [], // Required by logs-lib
18+
logsVolumeGroupBy: "level",
19+
showLogsVolume: true,
1520

16-
filterSelector: 'job=~".*/clickhouse.*"',
17-
18-
enableLokiLogs: true,
19-
},
21+
// alerts params
22+
alertsReplicasMaxQueueSize: "99",
2023
}

clickhouse-mixin/dashboards.libsonnet

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
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+
}

clickhouse-mixin/dashboards/addlogs.libsonnet

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)