e463781077
- 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>
514 lines
14 KiB
JSON
514 lines
14 KiB
JSON
{
|
|
"kind": "Dashboard",
|
|
"apiVersion": "dashboard.grafana.app/v2beta1",
|
|
"metadata": {
|
|
"name": "panel-conversions-test",
|
|
"labels": {
|
|
"test": "panel-conversions"
|
|
}
|
|
},
|
|
"spec": {
|
|
"annotations": [],
|
|
"cursorSync": "Off",
|
|
"description": "Testing panel to elements conversion",
|
|
"editable": true,
|
|
"elements": {
|
|
"panel-1": {
|
|
"kind": "Panel",
|
|
"spec": {
|
|
"id": 1,
|
|
"title": "Regular Timeseries Panel",
|
|
"description": "",
|
|
"links": [
|
|
{
|
|
"title": "External Link",
|
|
"url": "https://example.com",
|
|
"targetBlank": true
|
|
}
|
|
],
|
|
"data": {
|
|
"kind": "QueryGroup",
|
|
"spec": {
|
|
"queries": [
|
|
{
|
|
"kind": "PanelQuery",
|
|
"spec": {
|
|
"query": {
|
|
"kind": "DataQuery",
|
|
"group": "prometheus",
|
|
"version": "v0",
|
|
"datasource": {
|
|
"name": "existing-ref-uid"
|
|
},
|
|
"spec": {
|
|
"expr": "up",
|
|
"interval": "30s"
|
|
}
|
|
},
|
|
"refId": "A",
|
|
"hidden": false
|
|
}
|
|
},
|
|
{
|
|
"kind": "PanelQuery",
|
|
"spec": {
|
|
"query": {
|
|
"kind": "DataQuery",
|
|
"group": "prometheus",
|
|
"version": "v0",
|
|
"datasource": {
|
|
"name": "existing-ref-uid"
|
|
},
|
|
"spec": {
|
|
"expr": "cpu_usage",
|
|
"interval": "1m"
|
|
}
|
|
},
|
|
"refId": "B",
|
|
"hidden": true
|
|
}
|
|
}
|
|
],
|
|
"transformations": [
|
|
{
|
|
"kind": "reduce",
|
|
"spec": {
|
|
"id": "reduce",
|
|
"options": {
|
|
"reducers": [
|
|
"mean"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"queryOptions": {
|
|
"maxDataPoints": 300,
|
|
"interval": "1m",
|
|
"cacheTimeout": "60s"
|
|
}
|
|
}
|
|
},
|
|
"vizConfig": {
|
|
"kind": "VizConfig",
|
|
"group": "timeseries",
|
|
"version": "10.0.0",
|
|
"spec": {
|
|
"options": {
|
|
"legend": {
|
|
"calcs": [],
|
|
"displayMode": "list",
|
|
"placement": "bottom",
|
|
"showLegend": true
|
|
},
|
|
"tooltip": {
|
|
"mode": "single"
|
|
}
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"value": null,
|
|
"color": "green"
|
|
},
|
|
{
|
|
"value": 80,
|
|
"color": "red"
|
|
}
|
|
]
|
|
},
|
|
"color": {
|
|
"mode": "palette-classic"
|
|
},
|
|
"custom": {
|
|
"drawStyle": "line",
|
|
"fillOpacity": 10,
|
|
"lineWidth": 1
|
|
}
|
|
},
|
|
"overrides": []
|
|
}
|
|
}
|
|
},
|
|
"transparent": true
|
|
}
|
|
},
|
|
"panel-2": {
|
|
"kind": "LibraryPanel",
|
|
"spec": {
|
|
"id": 2,
|
|
"title": "Library Panel Reference",
|
|
"libraryPanel": {
|
|
"name": "Shared Stats Panel",
|
|
"uid": "library-panel-uid-123"
|
|
}
|
|
}
|
|
},
|
|
"panel-4": {
|
|
"kind": "Panel",
|
|
"spec": {
|
|
"id": 4,
|
|
"title": "Panel in Row",
|
|
"description": "",
|
|
"links": [],
|
|
"data": {
|
|
"kind": "QueryGroup",
|
|
"spec": {
|
|
"queries": [
|
|
{
|
|
"kind": "PanelQuery",
|
|
"spec": {
|
|
"query": {
|
|
"kind": "DataQuery",
|
|
"group": "prometheus",
|
|
"version": "v0",
|
|
"datasource": {
|
|
"name": "default-ds-uid"
|
|
},
|
|
"spec": {
|
|
"scenarioId": "random_walk"
|
|
}
|
|
},
|
|
"refId": "A",
|
|
"hidden": false
|
|
}
|
|
}
|
|
],
|
|
"transformations": [],
|
|
"queryOptions": {}
|
|
}
|
|
},
|
|
"vizConfig": {
|
|
"kind": "VizConfig",
|
|
"group": "timeseries",
|
|
"version": "",
|
|
"spec": {
|
|
"options": {},
|
|
"fieldConfig": {
|
|
"defaults": {},
|
|
"overrides": []
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"panel-6": {
|
|
"kind": "Panel",
|
|
"spec": {
|
|
"id": 6,
|
|
"title": "Hidden Panel in Collapsed Row",
|
|
"description": "",
|
|
"links": [],
|
|
"data": {
|
|
"kind": "QueryGroup",
|
|
"spec": {
|
|
"queries": [
|
|
{
|
|
"kind": "PanelQuery",
|
|
"spec": {
|
|
"query": {
|
|
"kind": "DataQuery",
|
|
"group": "loki",
|
|
"version": "v0",
|
|
"datasource": {
|
|
"name": "non-default-test-ds-uid"
|
|
},
|
|
"spec": {
|
|
"format": "table",
|
|
"rawSql": "SELECT * FROM metrics"
|
|
}
|
|
},
|
|
"refId": "A",
|
|
"hidden": false
|
|
}
|
|
}
|
|
],
|
|
"transformations": [],
|
|
"queryOptions": {}
|
|
}
|
|
},
|
|
"vizConfig": {
|
|
"kind": "VizConfig",
|
|
"group": "table",
|
|
"version": "",
|
|
"spec": {
|
|
"options": {
|
|
"showHeader": true
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {},
|
|
"overrides": []
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"panel-7": {
|
|
"kind": "Panel",
|
|
"spec": {
|
|
"id": 7,
|
|
"title": "Complex Panel with All Features",
|
|
"description": "",
|
|
"links": [
|
|
{
|
|
"title": "Drill Down",
|
|
"url": "/d/detailed-view"
|
|
}
|
|
],
|
|
"data": {
|
|
"kind": "QueryGroup",
|
|
"spec": {
|
|
"queries": [
|
|
{
|
|
"kind": "PanelQuery",
|
|
"spec": {
|
|
"query": {
|
|
"kind": "DataQuery",
|
|
"group": "elasticsearch",
|
|
"version": "v0",
|
|
"datasource": {
|
|
"name": "existing-target-uid"
|
|
},
|
|
"spec": {
|
|
"bucketAggs": [
|
|
{
|
|
"field": "@timestamp",
|
|
"id": "2",
|
|
"type": "date_histogram"
|
|
}
|
|
],
|
|
"query": "*"
|
|
}
|
|
},
|
|
"refId": "A",
|
|
"hidden": false
|
|
}
|
|
}
|
|
],
|
|
"transformations": [
|
|
{
|
|
"kind": "groupBy",
|
|
"spec": {
|
|
"id": "groupBy",
|
|
"options": {
|
|
"fields": {
|
|
"status": {
|
|
"aggregations": [
|
|
"count"
|
|
],
|
|
"operation": "groupby"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"kind": "sortBy",
|
|
"spec": {
|
|
"id": "sortBy",
|
|
"options": {
|
|
"sort": [
|
|
{
|
|
"desc": true,
|
|
"field": "count"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"queryOptions": {
|
|
"timeFrom": "1h",
|
|
"maxDataPoints": 1000,
|
|
"timeShift": "1h",
|
|
"queryCachingTTL": 300,
|
|
"hideTimeOverride": true
|
|
}
|
|
}
|
|
},
|
|
"vizConfig": {
|
|
"kind": "VizConfig",
|
|
"group": "barchart",
|
|
"version": "9.5.0",
|
|
"spec": {
|
|
"options": {
|
|
"barWidth": 0.97,
|
|
"groupWidth": 0.7,
|
|
"orientation": "horizontal"
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"color": {
|
|
"mode": "continuous-GrYlRd"
|
|
},
|
|
"custom": {
|
|
"orientation": "horizontal"
|
|
}
|
|
},
|
|
"overrides": []
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"layout": {
|
|
"kind": "RowsLayout",
|
|
"spec": {
|
|
"rows": [
|
|
{
|
|
"kind": "RowsLayoutRow",
|
|
"spec": {
|
|
"title": "",
|
|
"collapse": false,
|
|
"hideHeader": true,
|
|
"layout": {
|
|
"kind": "GridLayout",
|
|
"spec": {
|
|
"items": [
|
|
{
|
|
"kind": "GridLayoutItem",
|
|
"spec": {
|
|
"x": 0,
|
|
"y": 0,
|
|
"width": 12,
|
|
"height": 8,
|
|
"element": {
|
|
"kind": "ElementReference",
|
|
"name": "panel-1"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"kind": "GridLayoutItem",
|
|
"spec": {
|
|
"x": 12,
|
|
"y": 0,
|
|
"width": 6,
|
|
"height": 4,
|
|
"element": {
|
|
"kind": "ElementReference",
|
|
"name": "panel-2"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"kind": "RowsLayoutRow",
|
|
"spec": {
|
|
"title": "Row Panel",
|
|
"collapse": false,
|
|
"repeat": {
|
|
"mode": "variable",
|
|
"value": "server"
|
|
},
|
|
"layout": {
|
|
"kind": "GridLayout",
|
|
"spec": {
|
|
"items": [
|
|
{
|
|
"kind": "GridLayoutItem",
|
|
"spec": {
|
|
"x": 0,
|
|
"y": 0,
|
|
"width": 8,
|
|
"height": 6,
|
|
"element": {
|
|
"kind": "ElementReference",
|
|
"name": "panel-4"
|
|
},
|
|
"repeat": {
|
|
"mode": "variable",
|
|
"value": "region",
|
|
"direction": "h",
|
|
"maxPerRow": 4
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"kind": "GridLayoutItem",
|
|
"spec": {
|
|
"x": 8,
|
|
"y": 0,
|
|
"width": 16,
|
|
"height": 6,
|
|
"element": {
|
|
"kind": "ElementReference",
|
|
"name": "panel-7"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"kind": "RowsLayoutRow",
|
|
"spec": {
|
|
"title": "Collapsed Row",
|
|
"collapse": true,
|
|
"layout": {
|
|
"kind": "GridLayout",
|
|
"spec": {
|
|
"items": [
|
|
{
|
|
"kind": "GridLayoutItem",
|
|
"spec": {
|
|
"x": 0,
|
|
"y": 0,
|
|
"width": 12,
|
|
"height": 8,
|
|
"element": {
|
|
"kind": "ElementReference",
|
|
"name": "panel-6"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"links": [],
|
|
"liveNow": false,
|
|
"preload": false,
|
|
"tags": [
|
|
"test",
|
|
"panels"
|
|
],
|
|
"timeSettings": {
|
|
"timezone": "browser",
|
|
"from": "now-1h",
|
|
"to": "now",
|
|
"autoRefresh": "",
|
|
"autoRefreshIntervals": [
|
|
"5s",
|
|
"10s",
|
|
"30s",
|
|
"1m",
|
|
"5m",
|
|
"15m",
|
|
"30m",
|
|
"1h",
|
|
"2h",
|
|
"1d"
|
|
],
|
|
"hideTimepicker": false,
|
|
"fiscalYearStartMonth": 0
|
|
},
|
|
"title": "Panel Conversions Test Dashboard",
|
|
"variables": []
|
|
},
|
|
"status": {}
|
|
} |