[FEATURE] ClickHouse: use non-numeric columns of a time series query as series labels - #860
Closed
jonatas-lima wants to merge 1 commit into
Closed
jonatas-lima wants to merge 1 commit into
jonatas-lima wants to merge 1 commit into
Conversation
…as series labels Non-numeric columns used to be dropped, so a query grouped by a dimension collapsed every group into one series. They now become series labels, one series per label combination and value column. Queries without label columns return exactly what they returned before. Signed-off-by: Jonatas Ferreira <62180037+jonatas-lima@users.noreply.github.com>
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The ClickHouse time series query builds one series per non-
timecolumn, named after the column. A text column becomes an all-null series and is filtered out, so there is no way to break a metric down by a dimension:SELECT time, repository, count() AS jobs ... GROUP BY time, repositorycollapses every repository into a single series namedjobs.SELECT repository, coverageshows only the numbers (timestampNaN);repositoryis not visible.Rule
Columns other than
timewhose non-empty values are all non-numeric text are label columns. Every other column is a value column (current behaviour, including numeric strings and all-null columns). One series is emitted per label combination and value column, withlabelsset to the label values andnamein Prometheus notation, e.g.jobs{repository="network-api"}(labels sorted, as ingetUniqueKeyForPrometheusResult). Rows without atimecolumn keep the existingNaNtimestamp but carrylabels, so the Table panel (which spreadsts.labelsinto columns) shows one row per label combination.Backwards compatibility
With no label columns the output is unchanged: same names, same order, no
labelsfield. A test pins this. Queries that previously returned a text column that was silently dropped will now see it as a label, which is the point of the change. The shared stub in the existing test returned an unusedservice: 'api'column; I removed it so the pre-existing assertions still describe a label-free query.Tests
Run in
clickhouse(Node v24.14.0):npm run test -w clickhouse(17 passed),npm run lint -w clickhouse(no errors, existing warnings only),npm run type-check -w clickhouse,npm run format:check. New tests were written first and failed before the implementation. Not run: Playwright e2e,maketargets, and a manual check in a live Perses UI.Docs:
docs/clickhouse/model.mddocuments label columns.Screenshots
N/A (no UI change).
Checklist
[<catalog_entry>] <commit message>naming convention using one of the followingcatalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.🤖 Generated with Claude Code