StatChart metricLabel migration: conceptual issues with legendFormat mapping
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
- Área
- tooling
Línea de trabajo
Comienza comparando PR #281 con la migración principal en Perses' internal/api/plugin/migrate/grafana.go, especialmente la conversión de paneles alrededor de la línea 85. Verifica cómo StatChart y TimeSeries consumen targets, legendFormat y querySettings, y luego alinea el comportamiento de la migración y los fixtures para que se conserven los campos relevantes y el mapeo previsto se pueda probar en tiempo de ejecución.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 32
- Forks
- 86
- Merge medio
- 2 d 15 h
- PR fusionados (30 d)
- 43
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de perses/plugins
-
[BUG] clickhouse: getTimeSeriesData drops dimension columns, collapsing long-format results into one seriesPosiblemente ocupada @aminadojava la tomó hace 9 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 58/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Module federation warnings "No required version specified"Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
Perses does not propagate proxy headers to all api callsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 1 día
Todos los issues de perses/plugins
Issues similares
-
bug priority:low ready-for-dev
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Automattic/data-liberation-agent#685 ·
Los mantenedores suelen responder en 1 día
-
Business
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
txn2/mcp-data-platform#2063 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 77/100
Crosstalk-Solutions/project-nomad#1427 ·
Los mantenedores suelen responder en 2 días