Skip to content

Conversation

axelavargas
Copy link
Member

@axelavargas axelavargas commented May 26, 2025

Considering schema v2 is in experimental stage, and we still don't have completed backend migrations to move from v2 to v1, I am proposing an intermediate step when someone by mistake saved a v1 dashboards into v2.

This is to address situations like: https://raintank-corp.slack.com/archives/C03MCTKAJA0/p1747903900260849

v2ToV1ExportingUI.mp4

Important:

Dashboards in v2 with GridLayoutKind layouts are supported by the auto transform implementation.

The remaining layouts require a fallback; check this documentation to get the full list of layouts: schema v2 layout

@axelavargas axelavargas self-assigned this May 26, 2025
@github-project-automation github-project-automation bot moved this to 🗂️ Needs Triage / Escalation in Dashboards Triage May 26, 2025
@axelavargas axelavargas moved this from 🗂️ Needs Triage / Escalation to 👩‍💻 Development in Dashboards Triage May 26, 2025
@@ -12,6 +12,7 @@ export enum ExportMode {
Classic = 'classic',
V1Resource = 'v1-resource',
V2Resource = 'v2-resource',
V2TransformedToV1 = 'v2-transformed-to-v1',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it a new target? can we target v1-resource?

and then it would need to be transformed if the source is v2 (identical to selecting v2 when the source is v1)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Ryan is right. If we only have the option V1 selected, we would just need to check if the serialized dashboard is V2 to either transform it to V1 or leave it as is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I fixed it by making the "v1 resource" option automatically convert from v2

Copy link
Contributor

@ivanortegaalba ivanortegaalba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me from the product perspective. We should offer the V1 exportable option if the dashboard was saved as v2. At least while both APIs exists or the feature is experimental.

@axelavargas axelavargas changed the title Dashboards - Schema V2 - Experiment v2 to v1 through exporting Dashboards - Schema V2 - V2 to v1 through exporting in the UI Jun 9, 2025
@axelavargas axelavargas marked this pull request as ready for review June 9, 2025 15:55
@axelavargas axelavargas requested a review from a team as a code owner June 9, 2025 15:55
@axelavargas axelavargas requested review from CollinFingar and lucychen-grafana and removed request for a team June 9, 2025 15:55
@github-actions github-actions bot added this to the 12.1.x milestone Jun 9, 2025
@axelavargas axelavargas changed the title Dashboards - Schema V2 - V2 to v1 through exporting in the UI Dashboard: Schema V2 - Auto-transform V2 dashboards in V1Resource export mode Jun 9, 2025
Copy link
Contributor

@ivanortegaalba ivanortegaalba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it and it works like a charm.

There is something that this PR surfaces: The transform to V2 it is not the same that a V1 dashboard being saved as V2. Why? Because all the defaults added in the backend.

This is not problematic for this use case, and this is something that was there before this change.

Here is a summary of the changes:

JSON Path Dashboard saved as V1 Dashboard saved as v2 exporting v1 Change Type
spec.id 386 Does not exist Removed
spec.description Does not exist "" Added
spec.timepicker {} (Empty Object) Populated with refresh_intervals Modified
spec.panels[0] Datasource is a top-level key. Datasource is nested inside targets. Structural Change
spec.panels[0] Missing links & transformations. Contains empty links & transformations arrays. Added
spec.templating.list[0] Contained description key. Missing description, added skipUrlSync & hide. Structural Change

None of them are critical. The most significant one is the DS at the panel level.

@axelavargas axelavargas merged commit 6af09ed into main Jun 11, 2025
101 of 104 checks passed
@axelavargas axelavargas deleted the axelav/experimental-recovery-to-v1 branch June 11, 2025 09:28
@github-project-automation github-project-automation bot moved this from 👩‍💻 Development to 🚀 Done in Dashboards Triage Jun 11, 2025
m88deng pushed a commit to m88deng/grafana that referenced this pull request Jun 30, 2025
…ort mode (grafana#105997)

* experiment v2 to v1 in exporting

* refactor code to export to v1 resource

* Add unit test and fix linting

* fix typescript

* fix linting

* handle error gracefully when is not possible to convert to v1
YannickAlex07 pushed a commit to YannickAlex07/grafana that referenced this pull request Jul 11, 2025
…ort mode (grafana#105997)

* experiment v2 to v1 in exporting

* refactor code to export to v1 resource

* Add unit test and fix linting

* fix typescript

* fix linting

* handle error gracefully when is not possible to convert to v1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🚀 Done
Development

Successfully merging this pull request may close these issues.

3 participants