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:
+171
@@ -0,0 +1,171 @@
|
||||
{
|
||||
"kind": "Dashboard",
|
||||
"apiVersion": "dashboard.grafana.app/v1beta1",
|
||||
"metadata": {
|
||||
"name": "dashboard-properties-test",
|
||||
"labels": {
|
||||
"test": "dashboard-properties"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"title": "Dashboard Properties Test",
|
||||
"description": "Testing dashboard-level property transformations including time settings, cursor sync, and links",
|
||||
"tags": ["test", "properties", "metadata"],
|
||||
"editable": true,
|
||||
"preload": true,
|
||||
"liveNow": true,
|
||||
"graphTooltip": 2,
|
||||
"fiscalYearStartMonth": 4,
|
||||
"timezone": "America/New_York",
|
||||
"weekStart": "sunday",
|
||||
"refresh": "30s",
|
||||
"time": {
|
||||
"from": "now-12h",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {
|
||||
"collapse": false,
|
||||
"enable": true,
|
||||
"notice": false,
|
||||
"now": true,
|
||||
"refresh_intervals": ["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"],
|
||||
"status": "Stable",
|
||||
"time_options": ["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"],
|
||||
"type": "timepicker",
|
||||
"hidden": false,
|
||||
"nowDelay": "1m"
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
"asDropdown": false,
|
||||
"icon": "external link",
|
||||
"includeVars": true,
|
||||
"keepTime": true,
|
||||
"tags": ["monitoring", "alerts"],
|
||||
"targetBlank": true,
|
||||
"title": "External Monitoring System",
|
||||
"tooltip": "View in external system",
|
||||
"type": "link",
|
||||
"url": "https://monitoring.example.com/dashboard?from=${__from}&to=${__to}"
|
||||
},
|
||||
{
|
||||
"asDropdown": true,
|
||||
"icon": "dashboard",
|
||||
"includeVars": false,
|
||||
"keepTime": false,
|
||||
"tags": ["grafana", "internal"],
|
||||
"targetBlank": false,
|
||||
"title": "Related Dashboards",
|
||||
"tooltip": "Navigate to related dashboards",
|
||||
"type": "dashboards",
|
||||
"url": ""
|
||||
},
|
||||
{
|
||||
"asDropdown": false,
|
||||
"icon": "info",
|
||||
"includeVars": false,
|
||||
"keepTime": false,
|
||||
"tags": [],
|
||||
"targetBlank": true,
|
||||
"title": "Documentation",
|
||||
"tooltip": "View documentation",
|
||||
"type": "link",
|
||||
"url": "https://docs.example.com/dashboard-guide"
|
||||
},
|
||||
{
|
||||
"asDropdown": false,
|
||||
"icon": "tag",
|
||||
"includeVars": true,
|
||||
"keepTime": true,
|
||||
"tags": ["alerts"],
|
||||
"targetBlank": false,
|
||||
"title": "Tag-based Link",
|
||||
"tooltip": "Filtered by tags",
|
||||
"type": "tag",
|
||||
"url": "/dashboards/tag/alerts"
|
||||
}
|
||||
],
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Simple Panel",
|
||||
"type": "stat",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
}
|
||||
],
|
||||
"templating": {
|
||||
"list": [
|
||||
{
|
||||
"name": "simple_var",
|
||||
"type": "custom",
|
||||
"query": "value1,value2,value3",
|
||||
"current": {
|
||||
"text": "value1",
|
||||
"value": "value1"
|
||||
},
|
||||
"hide": 0,
|
||||
"skipUrlSync": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"name": "Simple Annotation",
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "blue",
|
||||
"target": {
|
||||
"refId": "Anno"
|
||||
},
|
||||
"builtIn": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"style": "dark",
|
||||
"version": 42,
|
||||
"schemaVersion": 39,
|
||||
"gnetId": 12345,
|
||||
"iteration": 1640995200000,
|
||||
"snapshot": {
|
||||
"originalUrl": "http://localhost:3000/d/test",
|
||||
"timestamp": "2023-01-01T00:00:00Z"
|
||||
},
|
||||
"meta": {
|
||||
"canEdit": true,
|
||||
"canSave": true,
|
||||
"canStar": true,
|
||||
"canAdmin": false,
|
||||
"slug": "dashboard-properties-test",
|
||||
"url": "/d/test/dashboard-properties-test",
|
||||
"expires": "2024-01-01T00:00:00Z",
|
||||
"created": "2023-01-01T00:00:00Z",
|
||||
"updated": "2023-06-01T00:00:00Z",
|
||||
"updatedBy": "admin",
|
||||
"createdBy": "admin",
|
||||
"version": 42,
|
||||
"hasAcl": false,
|
||||
"isFolder": false,
|
||||
"folderId": 0,
|
||||
"folderTitle": "General",
|
||||
"folderUrl": "",
|
||||
"provisioned": false,
|
||||
"provisionedExternalId": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user