Support for dynamic dashboard layout - #10247
Conversation
|
Hi Alan Zhang (@alanbzhang), |
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support in the amg extension for Grafana “dynamic dashboards” (dashboard.grafana.app v2 schema) by routing v2 dashboards through the dashboard apiserver instead of the legacy /api/dashboards/* endpoints, and updating related workflows (backup/restore/migrate/sync) plus tests accordingly.
Changes:
- Introduces
dashboard_v2.pyhelpers for v2 detection, discovery, CRUD, and datasource/library-panel handling. - Updates core commands (create/import/show/backup/restore/migrate/sync) to preserve and operate on v2 dashboards without lossy down-conversion.
- Expands scenario and unit tests to cover v2 dashboard behavior; bumps extension version to 3.1.0 with HISTORY entry.
Reviewed changes
Copilot reviewed 13 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/amg/setup.py | Bumps extension version to 3.1.0. |
| src/amg/HISTORY.rst | Adds 3.1.0 release notes entry for dynamic dashboards support. |
| src/amg/azext_amg/tests/latest/test_definitions.py | Adds a v2 dashboard fixture used by scenario tests. |
| src/amg/azext_amg/tests/latest/test_amg_scenario.py | Fixes list assertions and adds an E2E v2 dashboard scenario. |
| src/amg/azext_amg/tests/latest/test_amg_migrate_scenario.py | Fixes list assertions to scope by resource group. |
| src/amg/azext_amg/tests/latest/test_amg_dashboard_v2.py | Adds unit tests for v2 detection/version resolution/read/write helpers. |
| src/amg/azext_amg/sync.py | Adds v2-aware sync behavior (folder/title handling, provisioned detection, datasource/library panel remapping). |
| src/amg/azext_amg/restore.py | Adds v2-aware restore path via dashboard apiserver and v2 datasource remapping. |
| src/amg/azext_amg/migrate.py | Adds v2-aware migrate behavior (identity/folder/library-panel handling). |
| src/amg/azext_amg/dashboard_v2.py | New module implementing v2 apiserver discovery, v2 reads/creates, and v2-specific helpers. |
| src/amg/azext_amg/custom.py | Routes v2 create/import/show through the apiserver; adjusts role assignment principal_id handling. |
| src/amg/azext_amg/backup.py | Uses a unified dashboard identity helper for both classic and v2 dashboards. |
| src/amg/azext_amg/backup_core.py | Stores true v2 dashboard resources in backups when applicable (resolving v2 version once per backup). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| endpoint, headers = _get_grafana_request_context(cmd, resource_group_name, grafana_name, subscription, | ||
| api_key_or_token=api_key_or_token) | ||
| v2_dashboard = read_v2_dashboard(endpoint, headers, uid) | ||
| if v2_dashboard is not None: | ||
| return v2_dashboard |
| if is_v2: | ||
| # v2 (dynamic dashboards) resource: folder lives in an annotation, title in spec. | ||
| _, dashboard_title = dashboard_identity(source_dashboard) | ||
| folder_uid = dashboard_folder_uid(source_dashboard) | ||
| folder_title = _get_folder_title(source_endpoint, http_headers, folder_uid) |
| folder_title = dashboard_folder_uid(dashboard) if is_v2 else dashboard['meta']['folderTitle'] | ||
| update_summary_dict(exists_before, | ||
| folder_title, | ||
| dashboard['dashboard']['title'], | ||
| dashboard_title, |
|
Alan Zhang (@alanbzhang) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
amg |
🤖 PR Validation — ️✔️ All clear
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install azdevrequired)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.jsonautomatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json.