StatChart metricLabel migration: conceptual issues with legendFormat mapping
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- typescript
- Ambito
- tooling
Direzione di ricerca
Inizia confrontando PR #281 con la migrazione padre in Perses' internal/api/plugin/migrate/grafana.go, in particolare la conversione dei pannelli intorno alla riga 85. Verifica come StatChart e TimeSeries usano targets, legendFormat e querySettings, quindi allinea il comportamento della migrazione e i fixtures in modo che i campi pertinenti vengano preservati e il mapping previsto sia testabile a runtime.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
PR #281 introduced by @AntoineThebaud changes to StatChart's Grafana migration to extract metricLabel from legendFormat based on textMode. This issue discusses the conceptual foundation of this approach and its implications.
In Grafana's time-series queries, legendFormat is a template string that controls how series names are rendered in legends and on panels.
- "{{instance}}" - Shows just the instance label
- "Server {{instance}} ({{region}})" - Combines multiple labels in a template
- "Prometheus {{job}}"- Static text with label interpolation
The legendFormat is applied at query time to format the series name based on available labels (if more than one). The series name becomes the visual representation of that time-series.
What is metricLabel in Perses?
In Perses StatChart, metricLabel is a field selector that:
- Selects a specific field/column by name (regex pattern)
- Extracts that field's value from the query result
- Displays that value instead of the calculated numeric result
This maps directly to Grafana's reduceOptions.fields configuration, which specifies which column or field to use for the stat value.
How It Works:
When a query returns data with multiple fields:
Fields: instance, status, version, uptime
Row 1: [server1, up, 1.5.0, 42d]
Row 2: [server2, down, 1.6.0, 15d]
Without metricLabel (or fields in Grafana):
Display the default calculated value (e.g., last value from time-series)
With metricLabel:
For server1 stat: Display "1.5.0" (the version field value)
For server2 stat: Display "1.6.0" (the version field value)
The metricLabel feature exists specifically because Grafana queries can return multiple fields, and sometimes you want to display a non-numeric field value (like version, status, name) as the stat's main value instead of the calculated metric value.
Series Name vs Display Value
legendFormat controls the series name (what appears in legends when showing multiple series)
metricLabel controls the display value (what numeric result is replaced with)
These two features could be used independently or together, but extracting one from the other assumes a 1:1 relationship that doesn't necessarily exist.
Examples
No legendFormat and no metricLabel (thin line on the top is actual series name from very long labels list):
Both legendFormat and metricLabel applied:
The panel.targets Dependency
I found interesting bug where stat chart migration and timeseries migration is relying on panel.targets which is being ommited in grafana.go (perses repo).
The current migration includes:
if #textMode == "name" && (*#panel.targets[0].legendFormat | null) != null {
metricLabel: strings.Trim(#panel.targets[0].legendFormat, "{}")
}
This depends on panel.targets being present in the migration data. However:
The parent migration script in Perses main repo (grafana.go line ) omits panel.targets when converting panels
This means the condition (*#panel.targets[0].legendFormat | null) will always evaluate to null
The legendFormat extraction never actually occurs in practice. This is especially hard to catch since test input fixture includes targets making it different with actual migration runtime.
Should panel.targets be included in the parent migration?
The same pattern appears in TimeSeries migration with querySettings, creating the same dependency issue. And never migrating querySettings.
Suggestions
Was the legendFormat-to-metricLabel mapping introduced because some dashboards relied on this pattern? What was the actual use case?
I would simplify metricLabel migration relying only on fields from grafana:
#metricLabel: *#panel.options.reduceOptions.fields | null
if #metricLabel != null && #metricLabel != "" {
metricLabel: #metricLabel
}
And I think we need to keep targets in migration script in order to fix timeseries querySettings migration.
- Lingua principale
- TypeScript
- Stelle
- 32
- Fork
- 87
- Merge medio
- 2g 43m
- PR unite (30g)
- 34
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna 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 perses/plugins
-
[BUG] clickhouse: getTimeSeriesData drops dimension columns, collapsing long-format results into one seriesForse già presa @aminadojava l’ha presa 16 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] clickhouse: FORMAT substring check, envelope fallback and swallowed errorsForse già presa @Yash121l l’ha presa 4 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
perses/plugins#842 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Module federation warnings "No required version specified"Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di perses/plugins
Issue simili
-
documentation good first issue
Difficoltà 2/5 Mezza giornata Idoneità per principianti 72/100
sujithputta02/Esapay#13 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
ehmpathy/rhachet-roles-bhuild#468 ·
I maintainer di solito rispondono entro 1 giorno
-
Share dialog: the address book's contact count reads "1 contacts" (no singular form in any language)Forse già presa @chibenwa l’ha presa oggi. Apertaai-driven-qa bug claude Cosmetic
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
linagora/twake-contacts-frontend#271 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
factory-active task-identify-harness-labels-done task-identify-issue-type-done
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
vercel/ai#23435 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Koenkk/zigbee2mqtt#33402 ·
I maintainer di solito rispondono entro 1 giorno