Files
grafana/apps/dashboard/pkg/migration/conversion/testdata/input/v1beta1.annotation-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

217 lines
5.7 KiB
JSON

{
"kind": "Dashboard",
"apiVersion": "dashboard.grafana.app/v1beta1",
"metadata": {
"name": "annotation-conversions-test",
"labels": {
"test": "annotation-conversions"
}
},
"spec": {
"title": "Annotation Conversions Test Dashboard",
"description": "Testing annotation transformations",
"tags": ["test", "annotations"],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": false,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
},
{
"name": "Prometheus Annotations",
"datasource": {
"type": "prometheus",
"uid": "existing-ref-uid"
},
"enable": true,
"hide": false,
"iconColor": "red",
"target": {
"expr": "ALERTS{alertstate=\"firing\"}",
"refId": "Anno",
"interval": "1m",
"step": 60
},
"builtIn": 0,
"type": "prometheus"
},
{
"name": "TestData Annotations",
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"enable": true,
"hide": false,
"iconColor": "blue",
"target": {
"lines": 10,
"refId": "Anno",
"scenarioId": "annotations"
},
"builtIn": false,
"type": "testdata"
},
{
"name": "Elasticsearch Annotations",
"datasource": {
"type": "elasticsearch",
"uid": "existing-target-uid"
},
"enable": true,
"hide": false,
"iconColor": "yellow",
"target": {
"query": "tags:deployment",
"timeField": "@timestamp",
"refId": "Anno"
},
"textField": "message",
"tagsField": "tags",
"timeField": "@timestamp",
"timeEndField": "end_time",
"builtIn": 0,
"type": "elasticsearch"
},
{
"name": "SQL Annotations",
"datasource": {
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"enable": true,
"hide": false,
"iconColor": "green",
"target": {
"format": "table",
"rawSql": "SELECT time, title, text, tags FROM annotations WHERE $__timeFilter(time)",
"refId": "Anno"
},
"textColumn": "text",
"titleColumn": "title",
"tagsColumn": "tags",
"timeColumn": "time",
"builtIn": 0,
"type": "sql"
},
{
"name": "No Datasource Annotation",
"enable": true,
"hide": false,
"iconColor": "purple",
"target": {
"expr": "static_annotation_query",
"refId": "Anno"
},
"builtIn": 0,
"type": "manual"
},
{
"name": "Hidden Annotation",
"datasource": {
"type": "prometheus",
"uid": "existing-ref-uid"
},
"enable": false,
"hide": true,
"iconColor": "gray",
"target": {
"expr": "disabled_query",
"refId": "Anno"
},
"builtIn": 0,
"type": "prometheus"
},
{
"name": "Complex Filter Annotation",
"datasource": {
"type": "influxdb",
"uid": "influx-uid"
},
"enable": true,
"hide": false,
"iconColor": "#FF5722",
"target": {
"query": "from(bucket: \"events\") |> range(start: $__timeFrom, stop: $__timeTo) |> filter(fn: (r) => r._measurement == \"deployments\")",
"refId": "Anno"
},
"filter": {
"ids": [1, 2, 3],
"exclude": true
},
"mappings": {
"title": "service",
"text": "description",
"time": "timestamp",
"tags": "labels"
},
"builtIn": 0,
"type": "influxdb"
},
{
"name": "CloudWatch Annotations",
"datasource": {
"type": "cloudwatch",
"uid": "cloudwatch-uid"
},
"enable": true,
"hide": false,
"iconColor": "orange",
"target": {
"namespace": "AWS/EC2",
"metricName": "CPUUtilization",
"dimensions": {
"InstanceId": "i-1234567890abcdef"
},
"statistic": "Average",
"refId": "Anno"
},
"showIn": 0,
"builtIn": 0,
"type": "cloudwatch"
},
{
"name": "Disabled Built-in Annotation",
"builtIn": true,
"enable": false,
"hide": true,
"iconColor": "transparent",
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"target": {
"expr": "ALERTS{alertstate=\"firing\"}",
"refId": "Anno",
"interval": "1m",
"step": 60
},
"type": "prometheus"
}
]
},
"panels": [],
"templating": {
"list": []
},
"time": {
"from": "now-24h",
"to": "now"
},
"links": []
}
}