Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8dc5e0d
feat: add intelligent router for getAllKeyValues; use text index to
knudtty Jul 14, 2026
612bb2f
fix: remove key mv and map branches from recommended log and trace ro…
knudtty Jul 14, 2026
cfeda95
fix: rename functions for consistency
knudtty Jul 14, 2026
1c7dbf8
add tests
knudtty Jul 15, 2026
d91e060
feat: use useFetchFacets in autocomplete
knudtty Jul 15, 2026
9a42b40
Merge branch 'main' into aaron/filters-from-text-index
knudtty Jul 15, 2026
6edaf6d
fix lint and docker builds
knudtty Jul 15, 2026
bcfb574
pr feedback
knudtty Jul 15, 2026
4f8d9a5
fix: http 431 errors from too many query params solved by chunking
knudtty Jul 15, 2026
6453af2
fix tests
knudtty Jul 15, 2026
957a47b
fix behavior and tests
knudtty Jul 15, 2026
24b51b4
fix: pass maxValuesPerKey through metadata keyvalue queries
knudtty Jul 15, 2026
2c609a5
pr feedback
knudtty Jul 15, 2026
8623cd3
fix e2e tests
knudtty Jul 15, 2026
e740aea
enable limits
knudtty Jul 15, 2026
a62bda2
fix
knudtty Jul 15, 2026
4183842
fix tests
knudtty Jul 16, 2026
8bfc0ae
fix
knudtty Jul 16, 2026
5041d60
fix: use_multipart_params_auto set for clickhouse-js clients
knudtty Jul 16, 2026
cd71948
fix: hash large objects to reduce cache key size
knudtty Jul 16, 2026
a33924c
fix: keep same name to avoid issue of recreating an MV
knudtty Jul 16, 2026
abd9b08
add changeset
knudtty Jul 16, 2026
57a438d
pr feedback
knudtty Jul 17, 2026
d40bf98
add integration tests for getAllKeyValues
knudtty Jul 17, 2026
f2c0648
Merge branch 'main' into aaron/filters-from-text-index
knudtty Jul 17, 2026
95e5ec4
fix ci
knudtty Jul 17, 2026
3a29b30
Merge branch 'main' into aaron/filters-from-text-index
knudtty Jul 20, 2026
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
6 changes: 6 additions & 0 deletions .changeset/sharp-fishes-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@hyperdx/common-utils": minor
"@hyperdx/app": minor
---

feat: upgrade filters and autocomplete to intelligently route queries through the best rollup
51 changes: 1 addition & 50 deletions docker/otel-collector/schema/seed/00006_otel_logs_rollups.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- +goose Up

-- Map Attributes Key Value Rollup (all map columns in one table)
-- Key Value Rollup (many columns in one table)
CREATE TABLE IF NOT EXISTS ${DATABASE}.otel_logs_kv_rollup_15m
(
`Timestamp` DateTime,
Expand All @@ -17,58 +17,9 @@ ORDER BY (ColumnIdentifier, Key, Timestamp, Value)
TTL Timestamp + ${TABLES_TTL}
SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;

-- Key Only Rollup (derived from KV rollup)
CREATE TABLE IF NOT EXISTS ${DATABASE}.otel_logs_key_rollup_15m
(
`Timestamp` DateTime,
`ColumnIdentifier` LowCardinality(String),
`Key` LowCardinality(String),
`count` UInt64,
INDEX idx_count_minmax count TYPE minmax GRANULARITY 1,
INDEX idx_timestamp_minmax Timestamp TYPE minmax GRANULARITY 1
)
Comment on lines -21 to -29

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Totally no use for this any longer now that we have text index introspection, it's in the ingestion hot path, it's best to just deprecate this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we mark it as deprecated in the team settings / source configuration?

Image

ENGINE = SummingMergeTree
PARTITION BY toDate(Timestamp)
ORDER BY (ColumnIdentifier, Key, Timestamp)
TTL Timestamp + ${TABLES_TTL}
SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;

CREATE MATERIALIZED VIEW IF NOT EXISTS ${DATABASE}.otel_logs_key_rollup_15m_mv TO ${DATABASE}.otel_logs_key_rollup_15m
AS SELECT
Timestamp,
ColumnIdentifier,
Key,
sum(count) as count
FROM ${DATABASE}.otel_logs_kv_rollup_15m
GROUP BY ColumnIdentifier, Key, Timestamp;

-- Single MV: CTE with UNION ALL across all columns, then aggregate
CREATE MATERIALIZED VIEW IF NOT EXISTS ${DATABASE}.otel_logs_attr_kv_rollup_15m_mv TO ${DATABASE}.otel_logs_kv_rollup_15m
AS WITH elements AS (
SELECT
'ResourceAttributes' AS ColumnIdentifier,
toStartOfFifteenMinutes(Timestamp) AS Timestamp,
replaceRegexpAll(entry.1, '\\[\\d+\\]', '[*]') AS Key,
CAST(entry.2 AS String) AS Value
FROM ${DATABASE}.otel_logs
ARRAY JOIN ResourceAttributes AS entry
UNION ALL
SELECT
'LogAttributes' AS ColumnIdentifier,
toStartOfFifteenMinutes(Timestamp) AS Timestamp,
replaceRegexpAll(entry.1, '\\[\\d+\\]', '[*]') AS Key,
CAST(entry.2 AS String) AS Value
FROM ${DATABASE}.otel_logs
ARRAY JOIN LogAttributes AS entry
UNION ALL
SELECT
'ScopeAttributes' AS ColumnIdentifier,
toStartOfFifteenMinutes(Timestamp) AS Timestamp,
replaceRegexpAll(entry.1, '\\[\\d+\\]', '[*]') AS Key,
CAST(entry.2 AS String) AS Value
FROM ${DATABASE}.otel_logs
ARRAY JOIN ScopeAttributes AS entry
UNION ALL
Comment on lines -48 to -71

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These are handled by text index introspection now and are quite expensive, safe to remove

SELECT
'NativeColumn' AS ColumnIdentifier,
toStartOfFifteenMinutes(Timestamp) AS Timestamp,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- +goose Up

-- Key Value Rollup (all columns in one table)
-- Key Value Rollup (many columns in one table)
CREATE TABLE IF NOT EXISTS ${DATABASE}.otel_traces_kv_rollup_15m
(
`Timestamp` DateTime,
Expand All @@ -17,51 +17,9 @@ ORDER BY (ColumnIdentifier, Key, Timestamp, Value)
TTL Timestamp + ${TABLES_TTL}
SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;

-- Key Only Rollup (derived from KV rollup)
CREATE TABLE IF NOT EXISTS ${DATABASE}.otel_traces_key_rollup_15m
(
`Timestamp` DateTime,
`ColumnIdentifier` LowCardinality(String),
`Key` LowCardinality(String),
`count` UInt64,
INDEX idx_count_minmax count TYPE minmax GRANULARITY 1,
INDEX idx_timestamp_minmax Timestamp TYPE minmax GRANULARITY 1
)
ENGINE = SummingMergeTree
PARTITION BY toDate(Timestamp)
ORDER BY (ColumnIdentifier, Key, Timestamp)
TTL Timestamp + ${TABLES_TTL}
SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;

-- Key only rollup MV
CREATE MATERIALIZED VIEW IF NOT EXISTS ${DATABASE}.otel_traces_key_rollup_15m_mv TO ${DATABASE}.otel_traces_key_rollup_15m
AS SELECT
Timestamp,
ColumnIdentifier,
Key,
sum(count) AS count
FROM ${DATABASE}.otel_traces_kv_rollup_15m
GROUP BY ColumnIdentifier, Key, Timestamp;

-- Single MV: CTE with UNION ALL across all columns, then aggregate
CREATE MATERIALIZED VIEW IF NOT EXISTS ${DATABASE}.otel_traces_kv_rollup_15m_mv TO ${DATABASE}.otel_traces_kv_rollup_15m
AS WITH elements AS (
SELECT
'ResourceAttributes' AS ColumnIdentifier,
toStartOfFifteenMinutes(Timestamp) AS Timestamp,
replaceRegexpAll(entry.1, '\\[\\d+\\]', '[*]') AS Key,
CAST(entry.2 AS String) AS Value
FROM ${DATABASE}.otel_traces
ARRAY JOIN ResourceAttributes AS entry
UNION ALL
SELECT
'SpanAttributes' AS ColumnIdentifier,
toStartOfFifteenMinutes(Timestamp) AS Timestamp,
replaceRegexpAll(entry.1, '\\[\\d+\\]', '[*]') AS Key,
CAST(entry.2 AS String) AS Value
FROM ${DATABASE}.otel_traces
ARRAY JOIN SpanAttributes AS entry
UNION ALL
SELECT
'NativeColumn' AS ColumnIdentifier,
toStartOfFifteenMinutes(Timestamp) AS Timestamp,
Expand Down
2 changes: 2 additions & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"promised-handlebars": "^2.0.1",
"protobufjs": "^7.6.3",
"serialize-error": "^8.1.0",
"sqlstring": "^2.3.3",
"uuid": "^8.3.2",
"zod": "3.25",
"zod-express-middleware": "^1.4.0"
Expand All @@ -66,6 +67,7 @@
"@types/minimist": "^1.2.2",
"@types/ms": "^0.7.31",
"@types/passport-local": "^1.0.34",
"@types/sqlstring": "^2.3.0",
"@types/supertest": "^2.0.12",
"@types/swagger-jsdoc": "^6",
"@types/uuid": "^8.3.4",
Expand Down
13 changes: 9 additions & 4 deletions packages/api/src/mcp/tools/sources/describeSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { ClickhouseClient } from '@hyperdx/common-utils/dist/clickhouse/node';
import { getMetadata } from '@hyperdx/common-utils/dist/core/metadata';
import { type MetricTable, SourceKind } from '@hyperdx/common-utils/dist/types';
import SqlString from 'sqlstring';
import { z } from 'zod';

import { getConnectionById } from '@/controllers/connection';
Expand Down Expand Up @@ -114,7 +115,7 @@ async function sampleMetricNamesForKind({
timestampValueExpression,
signal,
});
const names = nameResults[0]?.value ?? [];
const names = nameResults[0]?.value.map(v => v.toString()) ?? [];
if (names.length === 0) return [];

// Best-effort enrichment with unit + description. One small query
Expand Down Expand Up @@ -451,7 +452,7 @@ async function describeSourceSchema(
});
for (const { key, value } of results) {
if (value.length > 0) {
lowCardinalityValues[key] = value;
lowCardinalityValues[key] = value.map(v => v.toString());
}
}
} catch {
Expand All @@ -473,7 +474,11 @@ async function describeSourceSchema(
const keyExprs: string[] = [];
for (const [colName, keys] of Object.entries(mapKeysResults)) {
for (const key of keys.slice(0, MAX_MAP_KEYS_TO_SAMPLE)) {
keyExprs.push(`${colName}['${key}']`);
// Map keys come from ClickHouse data (customer telemetry) so they can
// contain arbitrary characters, including single quotes. Escape as a
// SQL string literal — `SqlString.escape` returns a fully-quoted,
// safely-escaped value — before embedding in the key expression.
keyExprs.push(`${colName}[${SqlString.escape(key)}]`);
}
}

Expand All @@ -491,7 +496,7 @@ async function describeSourceSchema(
});
for (const { key, value } of results) {
if (value.length > 0) {
mapAttributeValues[key] = value;
mapAttributeValues[key] = value.map(v => v.toString());
}
}
} catch {
Expand Down
3 changes: 2 additions & 1 deletion packages/app/src/components/DBSearchPageFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ const DBSearchPageFiltersComponent = ({

const [showMoreFields, setShowMoreFields] = useState(false);
const {
data: facets,
data: fetchFacetsData,
isLoading: isFacetsLoading,
isFetching: isFacetsFetching,
error,
Expand All @@ -1186,6 +1186,7 @@ const DBSearchPageFiltersComponent = ({
filterState,
showMoreFields,
});
const facets = fetchFacetsData.keyValues;

useEffect(() => {
if (error) {
Expand Down
Loading
Loading