count_distinct aggFn on metric tiles ignores valueExpression, always counts distinct metric Values
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- clickhouse, sql, typescript
Direzione di ricerca
Inizia in packages/common-utils/src/core/renderChartConfig.ts, in translateMetricChartConfig, e verifica come vengono tradotti gli elementi di selezione gauge prima della generazione SQL. Riproduci la configurazione della metrica count_distinct riportata nell’issue, mantieni il suo valueExpression dell’attributo e verifica che la query generata conti i valori distinti dell’attributo invece di LastValue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Description
When using count_distinct as the aggFn on a metric tile, the valueExpression is ignored. The generated SQL always counts distinct values of the metric's float Value column rather than the specified attribute expression.
Steps to Reproduce
- Create a dashboard tile with
displayType: "number"and a metric select usingcount_distinctwith avalueExpressionpointing to an attribute:{ "displayType": "number", "source": "Metrics", "select": [ { "aggFn": "count_distinct", "valueExpression": "Attributes['name']", "metricName": "argocd_app_info", "metricType": "gauge" } ] } - Observe the number displayed — for an info metric (where
Valueis always1.0), the tile shows1or2instead of the actual count of distinct attribute values.
Expected Behavior
The tile should display the count of distinct values of Attributes['name'] across all time series for the metric — i.e., the number of distinct applications reported by argocd_app_info.
Direct ClickHouse query gives the correct answer:
SELECT uniqExact(Attributes['name'])
FROM default.otel_metrics_gauge
WHERE MetricName = 'argocd_app_info'
AND TimeUnix >= now() - INTERVAL 1 HOUR
-- returns 53
Actual Behavior
The generated SQL uses count(DISTINCT LastValue) where LastValue = last_value(Value) — the gauge's numeric value — not the attribute expression:
-- Generated by HyperDX
...
Bucketed AS (
SELECT
...,
last_value(Value) AS LastValue, -- <-- always the float metric value
any(Attributes) AS Attributes
FROM Source
GROUP BY AttributesHash, __hdx_time_bucket2
)
SELECT count(DISTINCT LastValue) -- <-- counts distinct 1.0, 0.0, etc.
FROM Bucketed
Result: 2 (distinct float values) instead of 53 (distinct app names).
Root Cause
In packages/common-utils/src/core/renderChartConfig.ts, translateMetricChartConfig unconditionally overwrites valueExpression with 'LastValue' for gauge metrics before passing the select config to SQL generation:
select: [
{
..._select,
valueExpression: 'LastValue', // overwrites user-provided Attributes['name']
aggCondition: '',
},
]
The original valueExpression from the user config is never used in metric query translation.
Additional Context
- The zod schema (
externalDashboardSelectItemSchemainpackages/api/src/utils/zod.ts) accepts and even requiresvalueExpressionfor non-countaggFns on metrics — so the intent to support this exists, but the query translator doesn't honour it. - The UI currently has no input for
valueExpressionon metric tiles, which makes sense given it's ignored — but fixing the translator would enable useful aggregations like counting distinct label values. - Confirmed present in v2.27.0. No prior issue or fix found.
Suggested Fix
For count_distinct (and potentially other aggFns where valueExpression refers to an attribute), use the user-provided expression instead of hardcoding 'LastValue':
// In translateMetricChartConfig for gauge metrics:
const effectiveValueExpression =
_select.aggFn === 'count_distinct' && _select.valueExpression
? _select.valueExpression
: 'LastValue';
select: [
{
..._select,
valueExpression: effectiveValueExpression,
aggCondition: '',
},
]
- Lingua principale
- TypeScript
- Stelle
- 10.1k
- Fork
- 527
- Merge medio
- 1g 20h
- PR unite (30g)
- 186
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ClickHouse/ClickStack
-
external
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ClickHouse/ClickStack#3761 ·
I maintainer di solito rispondono entro 1 giorno
-
Metric chart with aggFn increase and a multi-column group-by fails: toString() gets several argumentsForse già presa @CG-5228 l’ha presa 26 giorni fa. Apertaexternal
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
ClickHouse/ClickStack#3477 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Slack notifications for inline alerts fail when the chart-explorer link passes Slack's 3000-character block limitForse già presa @Tyagiquamar l’ha presa 28 giorni fa. Apertaalerting bug external
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
ClickHouse/ClickStack#3452 ·
I maintainer di solito rispondono entro 1 giorno
-
check-alerts worker: 13 error spans (mongodb.create, NamespaceExists) every minute because mongoose autoCreate is still onForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug external Needs Feedback
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ClickHouse/ClickStack#3308 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement Needs Feedback
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
ClickHouse/ClickStack#3687 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di ClickHouse/ClickStack
Issue simili
-
Add: GTrekkerApertacheck:passed streams:add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
area: ui Bug Payload OSS
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
payloadcms/payload#19839 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
fix(auth): add the email OTP verification step to Pollar loginForse già presa @akansnoro l’ha presa oggi. ApertaStellar Wave
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
safetrustcr/dApp-SafeTrust#584 · 10 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
The manager preset saves launch definitions without the required file and digest pairForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno