Files
grafana/apps/dashboard/pkg/migration/conversion/testdata/input/v1beta1.panel-conversions.json
Ivan Ortega Alba e463781077 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>
2025-11-12 11:43:46 +01:00

340 lines
7.6 KiB
JSON

{
"kind": "Dashboard",
"apiVersion": "dashboard.grafana.app/v1beta1",
"metadata": {
"name": "panel-conversions-test",
"labels": {
"test": "panel-conversions"
}
},
"spec": {
"title": "Panel Conversions Test Dashboard",
"description": "Testing panel to elements conversion",
"tags": ["test", "panels"],
"editable": true,
"preload": false,
"panels": [
{
"cacheTimeout": "60s",
"datasource": {
"type": "prometheus",
"uid": "existing-ref-uid"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"drawStyle": "line",
"fillOpacity": 10,
"lineWidth": 1
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"interval": "1m",
"links": [
{
"targetBlank": true,
"title": "External Link",
"url": "https://example.com"
}
],
"maxDataPoints": 300,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single"
}
},
"pluginVersion": "10.0.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "existing-ref-uid"
},
"expr": "up",
"hide": false,
"interval": "30s",
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "existing-ref-uid"
},
"expr": "cpu_usage",
"hide": true,
"interval": "1m",
"refId": "B"
}
],
"title": "Regular Timeseries Panel",
"transformations": [
{
"id": "reduce",
"options": {
"reducers": ["mean"]
}
}
],
"transparent": true,
"type": "timeseries"
},
{
"gridPos": {
"h": 4,
"w": 6,
"x": 12,
"y": 0
},
"id": 2,
"libraryPanel": {
"name": "Shared Stats Panel",
"uid": "library-panel-uid-123"
},
"title": "Library Panel Reference"
},
{
"collapsed": false,
"datasource": {
"type": "prometheus",
"uid": "edprtf91hz01se"
},
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 8
},
"id": 3,
"panels": [],
"repeat": "server",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "edprtf91hz01se"
},
"refId": "A"
}
],
"title": "Row Panel",
"type": "row"
},
{
"autoMigrateFrom": "graph",
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 8,
"x": 0,
"y": 9
},
"id": 4,
"maxPerRow": 4,
"repeat": "region",
"repeatDirection": "h",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"refId": "A",
"scenarioId": "random_walk"
}
],
"title": "Panel in Row",
"type": "timeseries"
},
{
"datasource": {
"type": "elasticsearch",
"uid": "existing-target-uid"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "continuous-GrYlRd"
},
"custom": {
"orientation": "horizontal"
}
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 16,
"x": 8,
"y": 9
},
"hideTimeOverride": true,
"id": 7,
"links": [
{
"title": "Drill Down",
"url": "/d/detailed-view"
}
],
"maxDataPoints": 1000,
"options": {
"barWidth": 0.97,
"groupWidth": 0.7,
"orientation": "horizontal"
},
"pluginVersion": "9.5.0",
"queryCachingTTL": 300,
"targets": [
{
"bucketAggs": [
{
"field": "@timestamp",
"id": "2",
"type": "date_histogram"
}
],
"datasource": {
"type": "elasticsearch",
"uid": "existing-target-uid"
},
"query": "*",
"refId": "A"
}
],
"timeFrom": "1h",
"timeShift": "1h",
"title": "Complex Panel with All Features",
"transformations": [
{
"id": "groupBy",
"options": {
"fields": {
"status": {
"aggregations": ["count"],
"operation": "groupby"
}
}
}
},
{
"id": "sortBy",
"options": {
"sort": [
{
"desc": true,
"field": "count"
}
]
}
}
],
"type": "barchart"
},
{
"collapsed": true,
"datasource": {
"type": "prometheus",
"uid": "edprtf91hz01se"
},
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 15
},
"id": 5,
"panels": [
{
"datasource": {
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 16
},
"id": 6,
"options": {
"showHeader": true
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"format": "table",
"rawSql": "SELECT * FROM metrics",
"refId": "A"
}
],
"title": "Hidden Panel in Collapsed Row",
"type": "table"
}
],
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "existing-ref-uid"
},
"refId": "A"
}
],
"title": "Collapsed Row",
"type": "row"
}
],
"time": {
"from": "now-1h",
"to": "now"
},
"templating": {
"list": []
},
"annotations": {
"list": []
},
"links": []
}
}