Skip to content

[FEATURE] ClickHouse: support traces, profiles, variables, annotations and ClickStack alerts - #968

Draft
Gladorme wants to merge 2 commits into
perses:mainfrom
Gladorme:t3/clickhouse-full-support
Draft

Gladorme wants to merge 2 commits into
perses:mainfrom
Gladorme:t3/clickhouse-full-support

Conversation

@Gladorme

Copy link
Copy Markdown
Member

Description

Full ClickHouse support, as requested in perses/perses#4202. The plugin is rebuilt on a shared query layer and now covers every signal that the ClickHouse exporter of the OpenTelemetry Collector and ClickStack store: metrics, logs, traces and profiles, plus variables, annotations and the alerts of ClickStack.

Fixes #841
Fixes #842
Fixes #843

Plugins

Kind What it does
ClickHouseDatasource updated Optional default database. Queries are sent with POST as read-only (readonly=2), with ISO date/times, quoted 64-bit integers and a limit of 100 000 rows. It adapts to users that can not change settings. The connection test calls GET /ping.
ClickHouseTimeSeriesQuery updated Label columns split the rows into series (#843), and a result without a time column is a table (#841). Reads the OpenTelemetry metric tables as they are, explicit and exponential histograms, and exemplars, stored with the data points or returned by an exemplarQuery. New optional seriesNameFormat, exemplarQuery and minStep.
ClickHouseLogQuery updated Levels, OpenTelemetry events, and the volume of the logs for the log explorer.
ClickHouseTraceQuery new A trace by its ID, or a search: a query selecting the matching spans of the OpenTelemetry traces table.
ClickHouseProfileQuery new Flame graph and timeline of a query returning one row per sample, for instance from otel_profiles.
ClickHouseSQLVariable new The values of a list variable.
ClickHouseSQLAnnotation new Annotations: one row per point or time span.
ClickHouseExplorer new Explorer with Graph, Table, Traces and Profiles tabs. Logs use the existing log explorer.
ClickStackDatasource, ClickStackAlertsQuery new The alerts of ClickStack (HyperDX), for the alert table.

Every query gets macros compatible with the ClickHouse datasource of Grafana ($__timeFilter, $__timeInterval, $__interval_s, $__conditionalAll…) and the dashboard variables, with a sqlstring format that writes values as ClickHouse string literals. The errors of ClickHouse are shown instead of an empty panel (#842).

Each kind has its CUE schema with test fixtures, its Go SDK builder and its documentation, including a new "Writing queries" page with the column conventions and recipes checked on real data.

Compatibility

  • The specs of the existing kinds stay valid: only optional fields are added.
  • Datasources whose proxy only allows GET on the root path keep working: their queries are still sent with GET.
  • A final FORMAT clause is ignored, and database still defaults to default.
  • TypeScript: createClickHouseClient().query() now returns { columns, rows, timeZone, truncated, statistics } and no longer takes start and end.

For the reviewer

  • e2e image. .github/dev/docker-compose.ci.yml moves Perses from main-2026-02-26-739dc289 to main-2026-11-26-4d10594e. The previous image can not load the current plugins: their schemas need CUE v0.17.1 where it has v0.15.4, and it does not know the Annotation plugin kind. It then refuses to provision the datasource and the dashboard of the new ClickHouse spec.
  • Overlap with [FEATURE] ClickHouse: add trace query plugin #813, which adds a ClickHouse trace query. This pull request contains one too (trace by ID and search): the two have to be reconciled.
  • Limitations. Profile queries can not use dashboard variables until Perses gives them to profile queries ([BREAKINGCHANGE] Align <signal>-queries.ts logic shared#397). The alerts were tested against a self-hosted ClickStack 2.47.0, not against the managed one.

Validation

Against the OpenTelemetry Demo, with its collector writing to ClickStack 2.47.0 and, through the ClickHouse exporter, to a second database that includes eBPF profiles. Dashboards, editors, connection tests, the explorer and the log explorer were checked in a browser on Perses main-2026-11-26-4d10594e. The client was also run against ClickHouse users with readonly = 0, 1 and 2 and with constrained settings: writes are refused and results stay bounded.

Command Result
npm run lint passed (ClickHouse: 1 warning, 4 on main)
npm run format:check passed
npm run type-check passed
npm run test passed (ClickHouse: 145 tests)
make lint-plugins passed
make test-schemas-plugins passed (ClickHouse: 42 tests)
make checkformat-cue passed
make golangci-lint passed
make test passed
make checklicense passed
make checkdocs passed
npx playwright test --workers=1 src/tests in e2e, against a local Perses main-2026-11-26-4d10594e started like the CI job with the built archives 5 passed

Screenshots

The OpenTelemetry Demo read from ClickHouse and ClickStack: time series with exemplars and annotations, a table, a heat map of OpenTelemetry histograms, the alerts of ClickStack, traces and logs.

Dashboard of the OpenTelemetry Demo read from ClickHouse and ClickStack

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

…s and ClickStack alerts

Rebuild the ClickHouse plugin on a shared query layer and extend it to the
other signals stored in ClickHouse.

- Datasource: optional default database, queries sent with POST as
  read-only with bounded and unambiguous results, GET kept for the proxies
  that only allow it, health check.
- Time series query: label columns split the rows into series, results
  without a time column are tables, OpenTelemetry histograms, exemplars,
  series name format and min step.
- Log query: OpenTelemetry events and levels, volume of the logs.
- New plugins: trace query, profile query, SQL variable, SQL annotation,
  explorer, ClickStack datasource and ClickStack alerts query.
- Macros compatible with the ClickHouse datasource of Grafana and variable
  interpolation in every query.
- CUE schemas, Go SDK and documentation for every kind, unit tests and an
  end-to-end spec.

The Perses image of the e2e job is bumped: the previous one can not load
the schemas of the current plugins.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <gladorme@users.noreply.github.com>
@Gladorme
Gladorme requested review from a team, AntoineThebaud and Nexucis as code owners November 26, 2026 16:49
@Gladorme
Gladorme requested review from shahrokni and removed request for a team November 26, 2026 16:49
@Gladorme
Gladorme marked this pull request as draft November 26, 2026 16:49
- Readonly guard: only a ClickHouse 164/452 refusal confirmed by a readonly probe drops it, per credentials and for 5 minutes.
- Send wait_end_of_query with the other settings so that its refusal is retried without it.
- Detect truncation at exactly the row limit by asking for one more row.
- Leave variables and macros in comments alone, and macros with arguments in strings.
- Strip a FORMAT clause followed by a comment; ignore comments in the SELECT list.
- Widen the date condition of $__dateTimeFilter by a day on each side.
- Cap the grid of a single old point; keep every row of a table as its own series.
- Show the series with a warning when their exemplars can not be read.
- Refuse datasource variables in profile queries, with an editor alert.
- Summarize traces from all their spans, without the 1-hour window.
- Count a NULL log level as unknown in the volume query.
- Tell in the datasource editor when the proxy does not allow the connection test.
- Remove the oxlint suppression of the client.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <gladorme@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant