Skip to content

Commit 8def69e

Browse files
[BUGFIX] PrometheusTimeSeriesQuery: Grafana migration: don't match non-prom queries when type is set (#632)
Signed-off-by: AntoineThebaud <antoine.thebaud@yahoo.fr>
1 parent 50d2407 commit 8def69e

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

prometheus/schemas/prometheus-time-series-query/migrate/migrate.cue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
package migrate
1515

1616
#target: {
17-
// /!\ Best-effort conversion logic that may wrongly convert not-prometheus queries to PrometheusTimeSeriesQuery:
18-
// Ideally we should rely on datasource.type = "prometheus" to identify prometheus queries. But in some cases,
19-
// this information is not be available. Thus the condition relies on the presence of the "expr" field, that
20-
// likely indicates that this is a prometheus query.
2117
datasource?: {
22-
uid: string
18+
type?: "prometheus"
19+
uid: string
2320
}
21+
// /!\ Best-effort conversion logic that may wrongly convert not-prometheus queries to PrometheusTimeSeriesQuery:
22+
// Ideally we should only rely on datasource.type = "prometheus" to identify prometheus queries. But in some cases,
23+
// this information is not present. Thus, in addition to the check on the optional type above, the below condition
24+
// relies on the presence of the "expr" field, that likely indicates that this is a prometheus query.
2425
expr: string
2526
legendFormat?: string
2627
interval?: string

prometheus/schemas/prometheus-time-series-query/migrate/tests/legend-format/input.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"datasource": {
3+
"type": "prometheus",
34
"uid": "${datasource}"
45
},
56
"editorMode": "code",

0 commit comments

Comments
 (0)