Schema: convert dashboards from v1beta1 to v2beta1 (#109037)

- Implement full conversion pipeline from v1beta1 → v2beta1
- Ensure frontend–backend parity for all dashboard serialization paths
- Add automatic data loss detection for conversions (panels, queries, annotations, links, variables)
- Extract atomic conversion functions for v0 → v1beta1 → v2alpha1 → v2beta1
- Introduce conversion metrics and detailed logging for loss tracking
- Normalize datasource resolution, defaults, and annotation processing
- Improve panel layout serialization and y-coordinate normalization
- Fix inconsistencies in nested panels and collapsed row behavior
- Refine variable handling:
  - Filter refId from variable query specs
  - Default variable refresh to 'never' (matches frontend)
  - Fix constant and interval variable handling for missing queries
- Unify schema defaults (enable, hide, iconColor, editable, liveNow)
- Fix pluginId usage (UID vs type) and datasource references
- Fix metrics.go bug swallowing errors (return nil → return err)
- Add tests for version-specific conversion error handling
- Add data loss detection tests using source/target version comparison
- Clean up lint issues, legacy code, and redundant files
- Update OpenAPI snapshots and migrated dashboards
- Improve backend migrator to reuse datasource provider and match frontend logic

Co-authored-by: Haris Rozajac <haris.rozajac12@gmail.com>
Co-authored-by: Oscar Kilhed <oscar.kilhed@grafana.com>
Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
This commit is contained in:
Ivan Ortega Alba
2025-11-12 11:43:46 +01:00
committed by GitHub
co-authored by Haris Rozajac Oscar Kilhed Stephanie Hingtgen
parent 09942c08db
commit e463781077
273 changed files with 75003 additions and 588 deletions
@@ -2147,4 +2147,4 @@
"title": "Panel tests - Gauge (new)",
"uid": "panel-tests-gauge-new",
"weekStart": ""
}
}
@@ -384,4 +384,4 @@
"title": "Heatmap X axis",
"uid": "5Y0jv6pVz",
"weekStart": ""
}
}
@@ -10,7 +10,7 @@
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"name": "Annotations \u0026 Alerts",
"target": {
"limit": 100,
"matchAny": false,
@@ -1071,32 +1071,27 @@
"type": "status-history"
},
{
"id": 15,
"type": "status-history",
"title": "no data",
"gridPos": {
"x": 18,
"y": 18,
"h": 9,
"w": 6
"datasource": {
"type": "grafana-testdata-datasource"
},
"fieldConfig": {
"defaults": {
"custom": {
"lineWidth": 0,
"fillOpacity": 70,
"spanNulls": false,
"insertNulls": false,
"hideFrom": {
"tooltip": false,
"viz": false,
"legend": false
},
"axisPlacement": "auto"
},
"color": {
"mode": "palette-classic"
},
"custom": {
"axisPlacement": "auto",
"fillOpacity": 70,
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineWidth": 0,
"spanNulls": false
},
"fieldMinMax": false,
"mappings": [],
"thresholds": {
"mode": "absolute",
@@ -1105,44 +1100,54 @@
"color": "green"
}
]
},
"fieldMinMax": false
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 6,
"x": 18,
"y": 18
},
"id": 15,
"options": {
"alignValue": "center",
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"mergeValues": true,
"rowHeight": 0.9,
"showValue": "auto",
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "12.3.0-pre",
"targets": [
{
"scenarioId": "random_walk",
"refId": "A",
"scenarioId": "random_walk",
"seriesCount": 0
}
],
"datasource": {
"type": "grafana-testdata-datasource"
},
"options": {
"mergeValues": true,
"showValue": "auto",
"alignValue": "center",
"rowHeight": 0.9,
"legend": {
"showLegend": true,
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single",
"sort": "none",
"hideZeros": false
}
}
"title": "no data",
"type": "status-history"
}
],
"preload": false,
"refresh": "",
"schemaVersion": 42,
"tags": ["gdev", "panel-tests", "state-timeline", "graph-ng"],
"tags": [
"gdev",
"panel-tests",
"state-timeline",
"graph-ng"
],
"templating": {
"list": []
},
@@ -1152,7 +1157,7 @@
},
"timepicker": {},
"timezone": "utc",
"title": "StatusHistory - Thresholds & Mappings",
"title": "StatusHistory - Thresholds \u0026 Mappings",
"uid": "a2f4ad9e-3b44-4624-8067-35f31be5d309",
"weekStart": ""
}
}
@@ -183,6 +183,24 @@
},
"fieldConfig": {
"defaults": {
"actions": [
{
"fetch": {
"body": "{}",
"headers": [
[
"Content-Type",
"application/json"
]
],
"method": "GET",
"queryParams": [],
"url": "/api/health"
},
"title": "Get instance health",
"type": "fetch"
}
],
"color": {
"fixedColor": "blue",
"mode": "shades"
@@ -195,6 +213,13 @@
},
"inspect": false
},
"links": [
{
"targetBlank": true,
"title": "Google Grafana",
"url": "https://google.com/search?q=grafana"
}
],
"mappings": [],
"thresholds": {
"mode": "absolute",
@@ -208,27 +233,7 @@
"value": 80
}
]
},
"actions": [
{
"fetch": {
"body": "{}",
"headers": [["Content-Type", "application/json"]],
"method": "GET",
"queryParams": [],
"url": "/api/health"
},
"title": "Get instance health",
"type": "fetch"
}
],
"links": [
{
"targetBlank": true,
"title": "Google Grafana",
"url": "https://google.com/search?q=grafana"
}
]
}
},
"overrides": []
},
@@ -612,4 +617,4 @@
"title": "Panel Tests - Table - Sparklines",
"uid": "d6373b49-1957-4f00-9218-ee2120d3ecd9",
"weekStart": ""
}
}
@@ -1071,32 +1071,27 @@
"type": "state-timeline"
},
{
"id": 15,
"type": "state-timeline",
"title": "no data",
"gridPos": {
"x": 18,
"y": 18,
"h": 9,
"w": 6
"datasource": {
"type": "grafana-testdata-datasource"
},
"fieldConfig": {
"defaults": {
"custom": {
"lineWidth": 0,
"fillOpacity": 70,
"spanNulls": false,
"insertNulls": false,
"hideFrom": {
"tooltip": false,
"viz": false,
"legend": false
},
"axisPlacement": "auto"
},
"color": {
"mode": "palette-classic"
},
"custom": {
"axisPlacement": "auto",
"fillOpacity": 70,
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineWidth": 0,
"spanNulls": false
},
"fieldMinMax": false,
"mappings": [],
"thresholds": {
"mode": "absolute",
@@ -1105,38 +1100,43 @@
"color": "green"
}
]
},
"fieldMinMax": false
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 6,
"x": 18,
"y": 18
},
"id": 15,
"options": {
"alignValue": "center",
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"mergeValues": true,
"rowHeight": 0.9,
"showValue": "auto",
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "12.3.0-pre",
"targets": [
{
"scenarioId": "random_walk",
"refId": "A",
"scenarioId": "random_walk",
"seriesCount": 0
}
],
"datasource": {
"type": "grafana-testdata-datasource"
},
"options": {
"mergeValues": true,
"showValue": "auto",
"alignValue": "center",
"rowHeight": 0.9,
"legend": {
"showLegend": true,
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single",
"sort": "none",
"hideZeros": false
}
}
"title": "no data",
"type": "state-timeline"
}
],
"preload": false,
@@ -1160,4 +1160,4 @@
"title": "StateTimeline - Thresholds \u0026 Mappings",
"uid": "Kce7z9TVz",
"weekStart": ""
}
}