Files
grafana/apps/dashboard/pkg/migration/conversion/testdata/output/v2beta1.datasource-resolution.v1beta1.json
T
Haris Rozajac ab4ccef319 Dashboard Conversion: Set panel level datasource when converting from v2 to v1 (#115777)
* set panel level ds when converting from v2 to v1

* remove comment

* lint

* always set ds in sqr

* improve

* Apply suggestions from code review

Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>

---------

Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>
2026-01-05 07:37:57 -07:00

585 lines
15 KiB
JSON

{
"kind": "Dashboard",
"apiVersion": "dashboard.grafana.app/v1beta1",
"metadata": {
"name": "test-v2beta1-datasource-resolution"
},
"spec": {
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": false,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations \u0026 Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
},
{
"datasource": {
"type": "prometheus",
"uid": "existing-ref-uid"
},
"enable": true,
"hide": false,
"iconColor": "red",
"name": "Annotation with DS UID defined",
"target": {
"expr": "ALERTS{alertstate=\"firing\"}",
"interval": "1m",
"refId": "Anno",
"step": 60
},
"type": "prometheus"
},
{
"datasource": {
"type": "elasticsearch"
},
"enable": true,
"hide": false,
"iconColor": "yellow",
"name": "Annotations only with group defined",
"tagsField": "tags",
"target": {
"query": "tags:deployment",
"refId": "Anno",
"timeField": "@timestamp"
},
"textField": "message",
"timeEndField": "end_time",
"timeField": "@timestamp",
"type": "elasticsearch"
},
{
"enable": true,
"hide": false,
"iconColor": "green",
"name": "Annotation without group or UID defined ",
"target": {
"format": "table",
"rawSql": "SELECT time, title, text, tags FROM annotations WHERE $__timeFilter(time)",
"refId": "Anno"
}
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 2,
"liveNow": false,
"panels": [
{
"datasource": {
"type": "grafana-testdata-datasource",
"uid": "gdev-testdata"
},
"description": "This should resolve to the grafana-testdata-datasource datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
}
}
},
"gridPos": {
"h": 3,
"w": 8,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "12.1.0-pre",
"targets": [
{
"datasource": {
"type": "grafana-testdata-datasource",
"uid": "gdev-testdata"
},
"refId": "A",
"scenarioId": "random_walk",
"seriesCount": 3
}
],
"title": "Panel with group and name defined",
"type": "timeseries"
},
{
"datasource": {
"type": "elasticsearch"
},
"description": "This should resolve to the first elasticsearch datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
}
}
},
"gridPos": {
"h": 3,
"w": 8,
"x": 0,
"y": 3
},
"id": 2,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "12.1.0-pre",
"targets": [
{
"alias": "",
"bucketAggs": [],
"datasource": {
"type": "elasticsearch"
},
"metrics": [],
"query": "",
"refId": "A",
"timeField": "@timestamp"
}
],
"title": "Panel with group defined but no name",
"type": "timeseries"
},
{
"description": "This should resolve to the default datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
}
}
},
"gridPos": {
"h": 3,
"w": 8,
"x": 0,
"y": 6
},
"id": 3,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "12.1.0-pre",
"targets": [
{
"refId": "A",
"scenarioId": "random_walk",
"seriesCount": 3
}
],
"title": "Panel with no group defined",
"type": "timeseries"
},
{
"datasource": {
"type": "mixed",
"uid": "-- Mixed --"
},
"description": "This should resolve to a mixed datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
}
}
},
"gridPos": {
"h": 3,
"w": 8,
"x": 0,
"y": 9
},
"id": 4,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "12.1.0-pre",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "existing-ref-uid"
},
"query": "up",
"refId": "A"
},
{
"bucketAggs": [
{
"field": "@host",
"id": "2",
"type": "terms"
}
],
"datasource": {
"type": "elasticsearch"
},
"query": "*",
"refId": "B",
"size": 100
},
{
"refId": "C",
"scenarioId": "random_walk",
"seriesCount": 3
}
],
"title": "Panel mixed Datasource and Group defined",
"type": "timeseries"
}
],
"preload": false,
"refresh": "",
"schemaVersion": 42,
"templating": {
"list": [
{
"allowCustomValue": true,
"current": {
"text": "legacy_value",
"value": "legacy_string_content"
},
"datasource": {
"type": "prometheus",
"uid": "existing-ref-uid"
},
"description": "Variable with group and UID defined",
"hide": 0,
"includeAll": false,
"label": "Group and UID defined",
"multi": false,
"name": "group_and_uid_defined",
"options": [],
"query": "up",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"type": "query"
},
{
"allowCustomValue": true,
"current": {
"text": "legacy_value",
"value": "legacy_string_content"
},
"datasource": {
"type": "elasticsearch"
},
"description": "Variable with group defined but no name",
"hide": 0,
"includeAll": false,
"label": "Group defined but no name",
"multi": false,
"name": "group_defined_but_no_name",
"options": [],
"query": {
"bucketAggs": [
{
"field": "@host",
"id": "2",
"type": "terms"
}
],
"query": "*",
"size": 100
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"type": "query"
},
{
"allowCustomValue": true,
"current": {
"text": "legacy_value",
"value": "legacy_string_content"
},
"description": "Variable with no group defined",
"hide": 0,
"includeAll": false,
"label": "No group defined",
"multi": false,
"name": "no_group_defined",
"options": [],
"query": {
"scenarioId": "random_walk",
"seriesCount": 3
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"type": "query"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
]
},
"timezone": "browser",
"title": "Test: V2beta1 dashboard with datasource resolution"
},
"status": {
"conversion": {
"failed": false,
"storedVersion": "v2beta1"
}
}
}