sonar-clone-dashboards
Clones the dashboard corresponding to the guid passed in the input record. The name of the cloned dashboard has a Copy of prefix added. If you specify the clone-widget option, the tabs and widgets included in the dashboard are cloned along with it.
Command properties
| Property | Description |
|---|---|
| Command type | Processing query |
| Required permission | Administrator |
| License usage | N/A |
| Parallel execution | Not supported |
| Distributed execution | Runs on Data Node (mapper) |
Syntax
Options
[run=BOOL]- Specify
tto actually clone the dashboard. If not specified, nothing is actually cloned, and you can preview only the shape of the clone result record (default:f). [clone-widget=BOOL]- Specify
tto also clone the widgets included in every tab of the dashboard (default:f).
Input fields
| Field | Type | Required | Description |
|---|---|---|---|
| guid | string | Required | The GUID of the dashboard to clone |
Output fields
Returns all fields of the input record with the following fields added.
| Field | Type | Description |
|---|---|---|
| clone_guid | string | The GUID of the dashboard to be newly created. Because this is a random value generated fresh each time the command is called, the value previewed without run can differ from the value actually issued when cloning with run=t. Not included in records where _error was recorded due to a missing guid field, a nonexistent target, or a clone failure during run=t |
| clone_name | string | The name of the dashboard to be newly created (with the Copy of prefix). Like clone_guid, not included in records where _error was recorded |
| status | string | The processing result, included only when run with run=t. success or failure |
| _error | string | The error message if the clone failed |
Error codes
Parsing errors
| Error code | Message | Description |
|---|---|---|
| 300170 | No permission to list dashboards | Run by an account without administrator permission |
Runtime errors
N/A
Description
For each input record, the sonar-clone-dashboards command looks up the target dashboard by the guid field value, then prepares a clone with a new GUID and a name prefixed with Copy of. If the run option is not specified, nothing is actually cloned, and you can check only the shape of the clone result record. Because clone_guid is a random value generated fresh each time the command is called, the value you check at this point differs from the GUID that is actually issued when cloning with run=t. In practice, clone_name is the only value you can preview reliably. You must specify run=t to actually create the dashboard, and the processing result is then recorded in the status field.
If you specify clone-widget=t, the widgets belonging to each tab of the source dashboard are also cloned, and the widget references stored in the tab layout are updated to point to the new widget GUIDs. If you do not specify this option, the tabs of the cloned dashboard still reference the original widgets.
If an error occurs during the step that clones the tabs and widgets while running with
run=t, there is no separate rollback, so the dashboard and only some of the tabs may end up being created.
If the guid field is missing, guid field is required is recorded in the _error field; if the target dashboard cannot be found, dashboard not found is recorded, and the record is not cloned in either case. If the guid value is not in valid UUID format, query execution is aborted with an exception, so you must always provide a value in the same format as the guid output field of the sonar-dashboards command.
Examples
-
Find a dashboard by name and preview the clone
sonar-dashboards | search name == "Security Operations Overview" | fields guid | sonar-clone-dashboardsBecause the
runoption is not specified, nothing is actually cloned, and you can preview only the name of the dashboard to be cloned. Becauseclone_guidis a value generated fresh each time the command is called, the GUID in this result cannot be used for the actual clone. -
Clone a dashboard with a specific GUID, including its widgets
json "[{'guid': '550e8400-e29b-41d4-a716-446655440000'}]" | sonar-clone-dashboards run=t clone-widget=tActually clones the dashboard with the specified GUID, along with the widgets in all of its tabs.
Change history
The sonar-clone-dashboards command is available in the Sonar 4.0 series starting with 4.0.2609.0, where the command previously provided by the Experimental app was built into Sonar core. On versions without the built-in command, install the Experimental app to use it.