From e086c29f4ee32997e6fc8c2d41422461d41326a2 Mon Sep 17 00:00:00 2001 From: AntoineThebaud Date: Thu, 16 Apr 2026 23:17:07 +0200 Subject: [PATCH] [BUGFIX] PrometheusTimeSeriesQuery: Grafana migration: don't match non-prom queries when `type` is set Signed-off-by: AntoineThebaud --- .../prometheus-time-series-query/migrate/migrate.cue | 11 ++++++----- .../migrate/tests/legend-format/input.json | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/prometheus/schemas/prometheus-time-series-query/migrate/migrate.cue b/prometheus/schemas/prometheus-time-series-query/migrate/migrate.cue index 701f008a0..68a7e2229 100644 --- a/prometheus/schemas/prometheus-time-series-query/migrate/migrate.cue +++ b/prometheus/schemas/prometheus-time-series-query/migrate/migrate.cue @@ -14,13 +14,14 @@ package migrate #target: { - // /!\ Best-effort conversion logic that may wrongly convert not-prometheus queries to PrometheusTimeSeriesQuery: - // Ideally we should rely on datasource.type = "prometheus" to identify prometheus queries. But in some cases, - // this information is not be available. Thus the condition relies on the presence of the "expr" field, that - // likely indicates that this is a prometheus query. datasource?: { - uid: string + type?: "prometheus" + uid: string } + // /!\ Best-effort conversion logic that may wrongly convert not-prometheus queries to PrometheusTimeSeriesQuery: + // Ideally we should only rely on datasource.type = "prometheus" to identify prometheus queries. But in some cases, + // this information is not present. Thus, in addition to the check on the optional type above, the below condition + // relies on the presence of the "expr" field, that likely indicates that this is a prometheus query. expr: string legendFormat?: string interval?: string diff --git a/prometheus/schemas/prometheus-time-series-query/migrate/tests/legend-format/input.json b/prometheus/schemas/prometheus-time-series-query/migrate/tests/legend-format/input.json index 6eb0dcdca..1cb215da9 100644 --- a/prometheus/schemas/prometheus-time-series-query/migrate/tests/legend-format/input.json +++ b/prometheus/schemas/prometheus-time-series-query/migrate/tests/legend-format/input.json @@ -1,5 +1,6 @@ { "datasource": { + "type": "prometheus", "uid": "${datasource}" }, "editorMode": "code",