-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Dashboard: Schema V2 - Auto-transform V2 dashboards in V1Resource export mode #105997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -12,6 +12,7 @@ export enum ExportMode { | |||
Classic = 'classic', | |||
V1Resource = 'v1-resource', | |||
V2Resource = 'v2-resource', | |||
V2TransformedToV1 = 'v2-transformed-to-v1', |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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.
There was a problem hiding this 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.
…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
…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
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