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

Conversation

schmikei
Copy link
Contributor

@schmikei schmikei commented May 27, 2025

  • Utilizing common-lib, logs-lib and grafonnet for most of the mixin generation
  • Following inspiration for more recently updated mixins like Vsphere

We need to retake some screenshots I believe for this update as now logs are utilizing the logs-lib and will be on a separate dashboard now instead of baked into the overview.

Clickhouse Overview
image

Clickhouse Latency
image

Clickhouse replica
image

Logs
image

Copy link
Contributor

@v-zhuravlev v-zhuravlev left a comment

Choose a reason for hiding this comment

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

Thanks for contributing! Small comment below while still a draft.

Comment on lines 23 to 29
panels.interserverConnectionsPanel { gridPos+: { h: 8, w: 12, x: 0, y: 0 } },
panels.replicaQueueSizePanel { gridPos+: { h: 8, w: 12, x: 12, y: 0 } },
panels.replicaOperationsPanel { gridPos+: { h: 8, w: 12, x: 0, y: 8 } },
panels.replicaReadOnlyPanel { gridPos+: { h: 8, w: 12, x: 12, y: 8 } },
panels.zooKeeperWatchesPanel { gridPos+: { h: 8, w: 12, x: 0, y: 16 } },
panels.zooKeeperSessionsPanel { gridPos+: { h: 8, w: 12, x: 12, y: 16 } },
panels.zooKeeperRequestsPanel { gridPos+: { h: 8, w: 24, x: 0, y: 24 } },
Copy link
Contributor

Choose a reason for hiding this comment

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

x,y coordinates pair is redundant if wrapPanels is used. It will be calculated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sweet thank you for the tip! 🚀

@schmikei schmikei marked this pull request as ready for review June 10, 2025 20:21
@schmikei schmikei requested a review from a team as a code owner June 10, 2025 20:21
@schmikei schmikei changed the title WIP: Update ClickHouse mixin to better utilize libraries Update ClickHouse mixin to better utilize libraries Jun 10, 2025
Copy link
Contributor

@v-zhuravlev v-zhuravlev left a comment

Choose a reason for hiding this comment

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

Thanks! Some comments inline.

Comment on lines +4 to +5
new(panels): {
row_1:
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like rows are not used to build dashboards.

'rate(ClickHouseProfileEvents_RejectedInserts{%s}[$__rate_interval])' % selector
)
+ g.panel.timeSeries.queryOptions.withInterval('30s')
+ prometheusQuery.withLegendFormat('%s - Rejected Inserts' % utils.labelsToPanelLegend(config.legendLabels)),
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
+ prometheusQuery.withLegendFormat('%s - Rejected Inserts' % utils.labelsToPanelLegend(config.legendLabels)),
+ prometheusQuery.withLegendFormat('%s - Rejected Inserts' % utils.labelsToPanelLegend(config.legendLabels)),

here and multiple places.
Please use Sentence case.

ClickHouseProfileEvents_DiskReadElapsedMicroseconds:
prometheusQuery.new(
'${' + vars.datasources.prometheus.name + '}',
'increase(ClickHouseProfileEvents_DiskReadElapsedMicroseconds{%s}[$__rate_interval])' % selector
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
'increase(ClickHouseProfileEvents_DiskReadElapsedMicroseconds{%s}[$__rate_interval])' % selector
'increase(ClickHouseProfileEvents_DiskReadElapsedMicroseconds{%s}[$__rate_interval])' % selector

to get accurate increments, Increase() should be used with [$__interval:] -offset $__interval.
rate() is best used with $__rate_interval, but it gives per second ratio.

Copy link
Contributor

Choose a reason for hiding this comment

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

this whole file could be ommited. Its contents could generated with commonlib.variables.new()

"remote": "https://github.com/grafana/jsonnet-libs.git",
"subdir": "grafana-cloud-integration-utils"
"remote": "https://github.com/grafana/grafonnet.git",
"subdir": "gen/grafonnet-v10.0.0"
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
"subdir": "gen/grafonnet-v10.0.0"
"subdir": "gen/grafonnet-v11.0.0"

best to use v11.

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.

_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?

Comment on lines +4 to +6
local utils = commonlib.utils {
labelsToPanelLegend(labels): std.join(' - ', ['{{%s}}' % [label] for label in labels]),
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this function is present in commonlib.utils now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to transform targets to signals?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants