Skip to content

Update ClickHouse mixin to better utilize libraries #1445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
prometheusAlerts+:: {
groups+: [
new(this): {
groups: [
{
name: 'ClickHouseAlerts',
rules: [
{
alert: 'ClickHouseReplicationQueueBackingUp',
expr: |||
ClickHouseAsyncMetrics_ReplicasMaxQueueSize > %(alertsReplicasMaxQueueSize)s
||| % $._config,
||| % this.config,
labels: {
severity: 'warning',
},
annotations: {
summary: 'ClickHouse replica max queue size backing up.',
description: |||
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.
||| % $._config,
||| % this.config,
},
'for': '5m',
keep_firing_for: '5m',
Expand Down
34 changes: 20 additions & 14 deletions clickhouse-mixin/config.libsonnet
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
{
_config+:: {
enableMultiCluster: false,
clickhouseSelector: if self.enableMultiCluster then 'job=~"$job", instance=~"$instance", cluster=~"$cluster"' else 'job=~"$job", instance=~"$instance"',
enableMultiCluster: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
enableMultiCluster: false,
enableMultiCluster: false,

overall, I think cluster could be considered a specific case of a member of groupLabel. Do we need any specific support for clusterLabel?

filteringSelector: 'job="integrations/clickhouse"',
groupLabels: if self.enableMultiCluster then ['job', 'cluster'] else ['job'],
logLabels: if self.enableMultiCluster then ['job', 'cluster', 'instance'] else ['job', 'instance'],
pureInstanceLabels: ['instance'],

dashboardTags: ['clickhouse-mixin'],
dashboardPeriod: 'now-30m',
dashboardTimezone: 'default',
dashboardRefresh: '1m',
logLabels: if self.enableMultiCluster then ['job', 'instance', 'cluster', 'level']
else ['job', 'instance', 'level'],
dashboardTags: [self.uid],
uid: 'clickhouse',
dashboardNamePrefix: 'ClickHouse',
dashboardPeriod: 'now-30m',
dashboardTimezone: 'default',
dashboardRefresh: '1m',

// for alerts
alertsReplicasMaxQueueSize: '99',
// Legend panel configuration
legendLabels: ['instance'],

filterSelector: 'job=~".*/clickhouse.*"',
// Logging configuration
enableLokiLogs: true,
extraLogLabels: ['level'], // Required by logs-lib
logsVolumeGroupBy: 'level',
showLogsVolume: true,

enableLokiLogs: true,
},
// Alerts configuration
alertsReplicasMaxQueueSize: '99',
}
142 changes: 142 additions & 0 deletions clickhouse-mixin/dashboards.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
local g = import './g.libsonnet';
local logslib = import 'logs-lib/logs/main.libsonnet';
{
local root = self,
new(this)::
local prefix = this.config.dashboardNamePrefix;
local links = this.grafana.links;
local tags = this.config.dashboardTags;
local uid = g.util.string.slugify(this.config.uid);
local vars = this.grafana.variables;
local annotations = this.grafana.annotations;
local refresh = this.config.dashboardRefresh;
local period = this.config.dashboardPeriod;
local timezone = this.config.dashboardTimezone;
local panels = this.grafana.panels;

{
'clickhouse-replica':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'clickhouse-replica':
'clickhouse-replica.json':

.json suffix should be used for dashboards.

g.dashboard.new(prefix + ' replica')
+ g.dashboard.withPanels(
g.util.grid.wrapPanels(
[
panels.interserverConnectionsPanel { gridPos+: { w: 12 } },
panels.replicaQueueSizePanel { gridPos+: { w: 12 } },
panels.replicaOperationsPanel { gridPos+: { w: 12 } },
panels.replicaReadOnlyPanel { gridPos+: { w: 12 } },
panels.zooKeeperWatchesPanel { gridPos+: { w: 12 } },
panels.zooKeeperSessionsPanel { gridPos+: { w: 12 } },
panels.zooKeeperRequestsPanel { gridPos+: { w: 24 } },
]
)
)
+ root.applyCommon(
vars.singleInstance,
uid + '_clickhouse_replica',
tags,
links { clickhouseReplica+:: {} },
annotations,
timezone,
refresh,
period
),

'clickhouse-overview':
g.dashboard.new(prefix + ' overview')
+ g.dashboard.withPanels(
g.util.grid.wrapPanels(
[
panels.successfulQueriesPanel { gridPos+: { w: 24 } },
panels.failedQueriesPanel { gridPos+: { w: 12 } },
panels.rejectedInsertsPanel { gridPos+: { w: 12 } },
panels.memoryUsagePanel { gridPos+: { w: 12 } },
panels.memoryUsageGaugePanel { gridPos+: { w: 12 } },
panels.activeConnectionsPanel { gridPos+: { w: 24 } },
panels.networkReceivedPanel { gridPos+: { w: 12 } },
panels.networkTransmittedPanel { gridPos+: { w: 12 } },
]
)
)
+ root.applyCommon(
vars.singleInstance,
uid + '_clickhouse_overview',
tags,
links { clickhouseOverview+:: {} },
annotations,
timezone,
refresh,
period
),

'clickhouse-latency':
g.dashboard.new(prefix + ' latency')
+ g.dashboard.withPanels(
g.util.grid.wrapPanels(
[
panels.diskReadLatencyPanel { gridPos+: { w: 12 } },
panels.diskWriteLatencyPanel { gridPos+: { w: 12 } },
panels.networkTransmitLatencyInboundPanel { gridPos+: { w: 12 } },
panels.networkTransmitLatencyOutboundPanel { gridPos+: { w: 12 } },
panels.zooKeeperWaitTimePanel { gridPos+: { w: 24 } },
]
)
)
+ root.applyCommon(
vars.singleInstance,
uid + '_clickhouse_latency',
tags,
links { clickhouseLatency+:: {} },
annotations,
timezone,
refresh,
period
),

}
+
if this.config.enableLokiLogs then
{
logs:
logslib.new(
prefix + ' logs',
datasourceName=this.grafana.variables.datasources.loki.name,
datasourceRegex=this.grafana.variables.datasources.loki.regex,
filterSelector=this.config.filteringSelector,
labels=this.config.logLabels + this.config.extraLogLabels,
formatParser=null,
showLogsVolume=this.config.showLogsVolume,
)
{
dashboards+:
{
logs+:
// reference to self, already generated variables, to keep them, but apply other common data in applyCommon
root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links { logs+:: {} }, annotations=annotations, timezone=timezone, refresh=refresh, period=period),
},
panels+:
{
logs+:
g.panel.logs.options.withEnableLogDetails(true)
+ g.panel.logs.options.withShowTime(false)
+ g.panel.logs.options.withWrapLogMessage(false),
},
variables+: {
// add prometheus datasource for annotations processing
toArray+: [
this.grafana.variables.datasources.prometheus { hide: 2 },
],
},
}.dashboards.logs,
}
else {},

applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period):
g.dashboard.withTags(tags)
+ g.dashboard.withUid(uid)
+ g.dashboard.withLinks(std.objectValues(links))
+ g.dashboard.withTimezone(timezone)
+ g.dashboard.withRefresh(refresh)
+ g.dashboard.time.withFrom(period)
+ g.dashboard.withVariables(vars)
+ g.dashboard.withAnnotations(std.objectValues(annotations)),
}
36 changes: 0 additions & 36 deletions clickhouse-mixin/dashboards/addlogs.libsonnet

This file was deleted.

Loading
Loading