[Synthetics] Support projects multi spaces !!#227674
[Synthetics] Support projects multi spaces !!#227674shahzad31 merged 19 commits intoelastic:mainfrom
Conversation
…ibana into project-multi-spaces
x-pack/solutions/observability/test/api_integration/apis/synthetics/add_monitor_project.ts
Outdated
Show resolved
Hide resolved
x-pack/solutions/observability/test/api_integration/apis/synthetics/add_monitor_project.ts
Outdated
Show resolved
Hide resolved
x-pack/solutions/observability/test/api_integration/apis/synthetics/add_monitor_project.ts
Outdated
Show resolved
Hide resolved
...rvability/test/api_integration_deployment_agnostic/apis/synthetics/create_monitor_project.ts
Outdated
Show resolved
Hide resolved
...st/api_integration_deployment_agnostic/apis/synthetics/create_monitor_project_multi_space.ts
Outdated
Show resolved
Hide resolved
...ck/solutions/observability/test/api_integration_deployment_agnostic/apis/synthetics/index.ts
Outdated
Show resolved
Hide resolved
...bility/plugins/synthetics/server/routes/monitor_cruds/project_monitor/add_monitor_project.ts
Outdated
Show resolved
Hide resolved
| const { attributes, id, previousMonitor } = monitor; | ||
| const prevSpaces = (previousMonitor.namespaces || []).sort(); | ||
| const spaces = (attributes.spaces || []).sort(); | ||
| if (!isEqual(prevSpaces, spaces) && !isEmpty(spaces)) { |
There was a problem hiding this comment.
I don't think we should recreate the monitor everytime that spaces changes. We should do it only if a single space monitor is converted to a multi space one.
|
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
| const checkSavedObjectsPrivileges = | ||
| server.security.authz.checkSavedObjectsPrivilegesWithRequest(request); | ||
|
|
||
| const { hasAllRequested } = await checkSavedObjectsPrivileges( |
There was a problem hiding this comment.
What will this return if we have a non-existing space in the spacesList?
Flaky Test Runner Stats🟠 Some tests failed. - kibana-flaky-test-suite-runner#8732[❌] x-pack/solutions/observability/test/api_integration/apis/synthetics/config.ts: 0/25 tests passed. |
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#8733[✅] x-pack/solutions/observability/test/api_integration/apis/synthetics/config.ts: 25/25 tests passed. |
💚 Build Succeeded
Metrics [docs]Async chunks
History
cc @cesco-f |
|
Starting backport for target branches: 8.19, 9.1 |
## Summary Follow up to elastic#221568 This PR allows specifying spaces param in project monitors. Following use-cases have been supported User will be able to supports `spaces: ["defautl", "test"] ` Proper API tests have been added to provide additional coverage for the use-case. ### Validations - [ ] The route to which project api is being called should always be part of spaces if defined. - [ ] Non existent space will throw error - [ ] User must have permission to all specified spaces for CRUDS - [ ] User can also specify * to create monitors in all spaces ### PR Testing You can use following project monitors PR to test this PR elastic/synthetics#1052 First create few project monitors before this branch and then switch and specify multi spaces as part of the options and verify in UI that editing , adding and deletion works as expected on push command. (cherry picked from commit 39d87d0)
💔 Some backports could not be created
Note: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
# Backport This will backport the following commits from `main` to `9.1`: - [[Synthetics] Support projects multi spaces !! (#227674)](#227674) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2025-07-21T07:52:26Z","message":"[Synthetics] Support projects multi spaces !! (#227674)\n\n## Summary\n\nFollow up to https://github.com/elastic/kibana/pull/221568\n\nThis PR allows specifying spaces param in project monitors. \n\nFollowing use-cases have been supported\n\nUser will be able to supports \n\n`spaces: [\"defautl\", \"test\"]\n`\n\nProper API tests have been added to provide additional coverage for the\nuse-case.\n\n### Validations\n\n- [ ] The route to which project api is being called should always be\npart of spaces if defined.\n- [ ] Non existent space will throw error \n- [ ] User must have permission to all specified spaces for CRUDS\n- [ ] User can also specify * to create monitors in all spaces\n\n\n### PR Testing\nYou can use following project monitors PR to test this PR\nhttps://github.com/elastic/synthetics/pull/1052\n\n\nFirst create few project monitors before this branch and then switch and\nspecify multi spaces as part of the options and verify in UI that\nediting , adding and deletion works as expected on push command.","sha":"39d87d0f908f0d1bbe7e1a29c588f3d8ea045da1","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:feature","Team:obs-ux-management","backport:version","v9.1.0","v8.19.0","author:obs-ux-management","v9.2.0"],"title":"[Synthetics] Support projects multi spaces !!","number":227674,"url":"https://github.com/elastic/kibana/pull/227674","mergeCommit":{"message":"[Synthetics] Support projects multi spaces !! (#227674)\n\n## Summary\n\nFollow up to https://github.com/elastic/kibana/pull/221568\n\nThis PR allows specifying spaces param in project monitors. \n\nFollowing use-cases have been supported\n\nUser will be able to supports \n\n`spaces: [\"defautl\", \"test\"]\n`\n\nProper API tests have been added to provide additional coverage for the\nuse-case.\n\n### Validations\n\n- [ ] The route to which project api is being called should always be\npart of spaces if defined.\n- [ ] Non existent space will throw error \n- [ ] User must have permission to all specified spaces for CRUDS\n- [ ] User can also specify * to create monitors in all spaces\n\n\n### PR Testing\nYou can use following project monitors PR to test this PR\nhttps://github.com/elastic/synthetics/pull/1052\n\n\nFirst create few project monitors before this branch and then switch and\nspecify multi spaces as part of the options and verify in UI that\nediting , adding and deletion works as expected on push command.","sha":"39d87d0f908f0d1bbe7e1a29c588f3d8ea045da1"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/227674","number":227674,"mergeCommit":{"message":"[Synthetics] Support projects multi spaces !! (#227674)\n\n## Summary\n\nFollow up to https://github.com/elastic/kibana/pull/221568\n\nThis PR allows specifying spaces param in project monitors. \n\nFollowing use-cases have been supported\n\nUser will be able to supports \n\n`spaces: [\"defautl\", \"test\"]\n`\n\nProper API tests have been added to provide additional coverage for the\nuse-case.\n\n### Validations\n\n- [ ] The route to which project api is being called should always be\npart of spaces if defined.\n- [ ] Non existent space will throw error \n- [ ] User must have permission to all specified spaces for CRUDS\n- [ ] User can also specify * to create monitors in all spaces\n\n\n### PR Testing\nYou can use following project monitors PR to test this PR\nhttps://github.com/elastic/synthetics/pull/1052\n\n\nFirst create few project monitors before this branch and then switch and\nspecify multi spaces as part of the options and verify in UI that\nediting , adding and deletion works as expected on push command.","sha":"39d87d0f908f0d1bbe7e1a29c588f3d8ea045da1"}}]}] BACKPORT--> Co-authored-by: Shahzad <shahzad31comp@gmail.com>
# Backport This will backport the following commits from `main` to `8.19`: - [[Synthetics] Support projects multi spaces !! (#227674)](#227674) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2025-07-21T07:52:26Z","message":"[Synthetics] Support projects multi spaces !! (#227674)\n\n## Summary\n\nFollow up to https://github.com/elastic/kibana/pull/221568\n\nThis PR allows specifying spaces param in project monitors. \n\nFollowing use-cases have been supported\n\nUser will be able to supports \n\n`spaces: [\"defautl\", \"test\"]\n`\n\nProper API tests have been added to provide additional coverage for the\nuse-case.\n\n### Validations\n\n- [ ] The route to which project api is being called should always be\npart of spaces if defined.\n- [ ] Non existent space will throw error \n- [ ] User must have permission to all specified spaces for CRUDS\n- [ ] User can also specify * to create monitors in all spaces\n\n\n### PR Testing\nYou can use following project monitors PR to test this PR\nhttps://github.com/elastic/synthetics/pull/1052\n\n\nFirst create few project monitors before this branch and then switch and\nspecify multi spaces as part of the options and verify in UI that\nediting , adding and deletion works as expected on push command.","sha":"39d87d0f908f0d1bbe7e1a29c588f3d8ea045da1","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:feature","Team:obs-ux-management","backport:version","v9.1.0","v8.19.0","author:obs-ux-management","v9.2.0"],"title":"[Synthetics] Support projects multi spaces !!","number":227674,"url":"https://github.com/elastic/kibana/pull/227674","mergeCommit":{"message":"[Synthetics] Support projects multi spaces !! (#227674)\n\n## Summary\n\nFollow up to https://github.com/elastic/kibana/pull/221568\n\nThis PR allows specifying spaces param in project monitors. \n\nFollowing use-cases have been supported\n\nUser will be able to supports \n\n`spaces: [\"defautl\", \"test\"]\n`\n\nProper API tests have been added to provide additional coverage for the\nuse-case.\n\n### Validations\n\n- [ ] The route to which project api is being called should always be\npart of spaces if defined.\n- [ ] Non existent space will throw error \n- [ ] User must have permission to all specified spaces for CRUDS\n- [ ] User can also specify * to create monitors in all spaces\n\n\n### PR Testing\nYou can use following project monitors PR to test this PR\nhttps://github.com/elastic/synthetics/pull/1052\n\n\nFirst create few project monitors before this branch and then switch and\nspecify multi spaces as part of the options and verify in UI that\nediting , adding and deletion works as expected on push command.","sha":"39d87d0f908f0d1bbe7e1a29c588f3d8ea045da1"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/228725","number":228725,"state":"OPEN"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/227674","number":227674,"mergeCommit":{"message":"[Synthetics] Support projects multi spaces !! (#227674)\n\n## Summary\n\nFollow up to https://github.com/elastic/kibana/pull/221568\n\nThis PR allows specifying spaces param in project monitors. \n\nFollowing use-cases have been supported\n\nUser will be able to supports \n\n`spaces: [\"defautl\", \"test\"]\n`\n\nProper API tests have been added to provide additional coverage for the\nuse-case.\n\n### Validations\n\n- [ ] The route to which project api is being called should always be\npart of spaces if defined.\n- [ ] Non existent space will throw error \n- [ ] User must have permission to all specified spaces for CRUDS\n- [ ] User can also specify * to create monitors in all spaces\n\n\n### PR Testing\nYou can use following project monitors PR to test this PR\nhttps://github.com/elastic/synthetics/pull/1052\n\n\nFirst create few project monitors before this branch and then switch and\nspecify multi spaces as part of the options and verify in UI that\nediting , adding and deletion works as expected on push command.","sha":"39d87d0f908f0d1bbe7e1a29c588f3d8ea045da1"}}]}] BACKPORT--> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
## Summary Follow up to elastic#221568 This PR allows specifying spaces param in project monitors. Following use-cases have been supported User will be able to supports `spaces: ["defautl", "test"] ` Proper API tests have been added to provide additional coverage for the use-case. ### Validations - [ ] The route to which project api is being called should always be part of spaces if defined. - [ ] Non existent space will throw error - [ ] User must have permission to all specified spaces for CRUDS - [ ] User can also specify * to create monitors in all spaces ### PR Testing You can use following project monitors PR to test this PR elastic/synthetics#1052 First create few project monitors before this branch and then switch and specify multi spaces as part of the options and verify in UI that editing , adding and deletion works as expected on push command.
## Summary Follow up to elastic#221568 This PR allows specifying spaces param in project monitors. Following use-cases have been supported User will be able to supports `spaces: ["defautl", "test"] ` Proper API tests have been added to provide additional coverage for the use-case. ### Validations - [ ] The route to which project api is being called should always be part of spaces if defined. - [ ] Non existent space will throw error - [ ] User must have permission to all specified spaces for CRUDS - [ ] User can also specify * to create monitors in all spaces ### PR Testing You can use following project monitors PR to test this PR elastic/synthetics#1052 First create few project monitors before this branch and then switch and specify multi spaces as part of the options and verify in UI that editing , adding and deletion works as expected on push command.
## Summary Follow up to elastic#221568 This PR allows specifying spaces param in project monitors. Following use-cases have been supported User will be able to supports `spaces: ["defautl", "test"] ` Proper API tests have been added to provide additional coverage for the use-case. ### Validations - [ ] The route to which project api is being called should always be part of spaces if defined. - [ ] Non existent space will throw error - [ ] User must have permission to all specified spaces for CRUDS - [ ] User can also specify * to create monitors in all spaces ### PR Testing You can use following project monitors PR to test this PR elastic/synthetics#1052 First create few project monitors before this branch and then switch and specify multi spaces as part of the options and verify in UI that editing , adding and deletion works as expected on push command.
Summary
Follow up to #221568
This PR allows specifying spaces param in project monitors.
Following use-cases have been supported
User will be able to supports
spaces: ["defautl", "test"]Proper API tests have been added to provide additional coverage for the use-case.
Validations
PR Testing
You can use following project monitors PR to test this PR elastic/synthetics#1052
First create few project monitors before this branch and then switch and specify multi spaces as part of the options and verify in UI that editing , adding and deletion works as expected on push command.