[Automatic Migrations] Siem migrations new endpoint scheme#219597
[Automatic Migrations] Siem migrations new endpoint scheme#219597logeekal merged 45 commits intoelastic:mainfrom
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
.../plugins/security_solution/common/siem_migrations/model/api/rules/rule_migration.schema.yaml
Outdated
Show resolved
Hide resolved
.../plugins/security_solution/common/siem_migrations/model/api/rules/rule_migration.schema.yaml
Show resolved
Hide resolved
x-pack/solutions/security/plugins/security_solution/public/siem_migrations/rules/api/index.ts
Outdated
Show resolved
Hide resolved
...ty/plugins/security_solution/public/siem_migrations/rules/service/rule_migrations_service.ts
Show resolved
Hide resolved
.../solutions/security/plugins/security_solution/server/lib/siem_migrations/rules/api/create.ts
Outdated
Show resolved
Hide resolved
.../solutions/security/plugins/security_solution/server/lib/siem_migrations/rules/api/delete.ts
Outdated
Show resolved
Hide resolved
...lutions/security/plugins/security_solution/server/lib/siem_migrations/rules/api/rules/add.ts
Show resolved
Hide resolved
kqualters-elastic
left a comment
There was a problem hiding this comment.
talked through some of this during our syncs, and desk tested this most recent iteration locally and with frontend changes based on this branch, everything looks good to me 👍
semd
left a comment
There was a problem hiding this comment.
Tested locally, index migrators create the expected documents. Regular rule migration workflow works as usual. LGTM.
Thanks Jatin! 🚀
|
Starting backport for target branches: 8.19 https://github.com/elastic/kibana/actions/runs/15190552779 |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
History
|
💔 All backports failed
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 |
## Summary Resolves elastic/security-team#12483 This PR changes REST API Endpoints scheme to align with elastic/security-team#12483. Below is the summary of changes done. ### API Scheme changes The REST API scheme has been changed to reflect elastic/security-team#12483. This is pretty much self explanatory as defined in below openapi schema yaml : - [x-pack/solutions/security/plugins/security_solution/common/siem_migrations/model/api/rules/rule_migration.schema.yaml](https://github.com/elastic/kibana/pull/219597/files#diff-3025af9eca156f3308474e2b42808da1531423457b7791daf6660db95a53b978) ### Introduction of Delete Migration API This PR also adds `DELETE` method on route `/rules/siem_migrations/{migration_id}` for deleting a migrations. Deleting a migration does below operations: - Stops a migration if it is running - Deletes the rules, resources related to migration and migration document itself. ### File Reorganizations Directly structure has been changed a little bit to reflect the endpoint. There is a sub-directory called `rules` which deals with only `rules` of the migration and the root directly only contains the endpoints related to the migration. #### Before ``` //siem_migrations/rules/api ├── create.ts ├── get.ts ├── start.ts ├── update.ts ├── ├── ├── ``` #### After ``` //siem_migrations/rules/api ├── create.ts ├── delete.ts ├── get.ts ├── rules │ ├── add.ts │ ├── get.ts │ └── update.ts ├── ├── ├── ``` ## Migration Strategy ### TL,DR; ```mermaid flowchart TD StartM[Start Migration] --> isMigExists{Does Migration Index Exists} isMigExists -->|Yes|FetchMDoc[Fetch Migration Docs] isMigExists -->|No|CreateMIndex[Create MigrationIndex] CreateMIndex --> FetchMDoc FetchMDoc --> FetchMRules[Fetch Migration Stats Rules index] FetchMRules --> FilterMigration{Filter Migration Docs not in Migration Index} FilterMigration --> |is Empty|END[END] FilterMigration --> |is Not Empty| CreateMDocs[Create Migration Docs] CreateMDocs --> END ``` At the time of merging this PR, the Migration indices can be in 3 states: ### There are migrations created after elastic#216164 and this means that there are `some` migrations existing in `.kibana-siem-migrations-migrations-<space_id>` and migrations created before above mentioned PR will only exist in `.kibana-siem-migrations-rules-<space_id>`. In this case `migrateRuleMigrationIndex` will create migration in below steps: 1. Look for **all** migration Documents in `.kibana-siem-migrations-migrations-<space_id>` 2. Get **all** Migrations stats from `.kibana-siem-migrations-rules-<space_id>` which includes below properties - migration_id : will help in reconciling the migration id in .kibana-siem-migrations-migrations-<space_id>` index - created_at : Date on which migration_id was created. - created_by: User who created the migrations. 3. A new document with above migration will be added to `.kibana-siem-migrations-migrations-<space_id>`. 4. Now both `.kibana-siem-migrations-migrations-<space_id>` and `.kibana-siem-migrations-rules-<space_id>` will be in sync. ### Alternatively, there are no migration created after elastic#216164. In that case, there is a possibility that `.kibana-siem-migrations-migrations-<space_id>`, will not even exist. In this case `migrateRuleMigrationIndex` will create migration in below steps: 1. Create the `.kibana-siem-migrations-migrations-<space_id>` index. 2. Do steps mentioned in above scenario. ### Once the migrations has been run successfully, both `.kibana-siem-migrations-migrations-<space_id>` index and `.kibana-siem-migrations-rules-<space_id>` will be in sync. 1. In this case, migration will not run, since it tries to filter the migrations by `id` which exist in `kibana-siem-migrations-rules-<space_id>` but do not exist in `kibana-siem-migrations-migrations-<space_id>` ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit bf642b0) # Conflicts: # x-pack/test/security_solution_cypress/cypress/urls/navigation.ts
|
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
## Summary Resolves elastic/security-team#12483 This PR changes REST API Endpoints scheme to align with elastic/security-team#12483. Below is the summary of changes done. ### API Scheme changes The REST API scheme has been changed to reflect elastic/security-team#12483. This is pretty much self explanatory as defined in below openapi schema yaml : - [x-pack/solutions/security/plugins/security_solution/common/siem_migrations/model/api/rules/rule_migration.schema.yaml](https://github.com/elastic/kibana/pull/219597/files#diff-3025af9eca156f3308474e2b42808da1531423457b7791daf6660db95a53b978) ### Introduction of Delete Migration API This PR also adds `DELETE` method on route `/rules/siem_migrations/{migration_id}` for deleting a migrations. Deleting a migration does below operations: - Stops a migration if it is running - Deletes the rules, resources related to migration and migration document itself. ### File Reorganizations Directly structure has been changed a little bit to reflect the endpoint. There is a sub-directory called `rules` which deals with only `rules` of the migration and the root directly only contains the endpoints related to the migration. #### Before ``` //siem_migrations/rules/api ├── create.ts ├── get.ts ├── start.ts ├── update.ts ├── ├── ├── ``` #### After ``` //siem_migrations/rules/api ├── create.ts ├── delete.ts ├── get.ts ├── rules │ ├── add.ts │ ├── get.ts │ └── update.ts ├── ├── ├── ``` ## Migration Strategy ### TL,DR; ```mermaid flowchart TD StartM[Start Migration] --> isMigExists{Does Migration Index Exists} isMigExists -->|Yes|FetchMDoc[Fetch Migration Docs] isMigExists -->|No|CreateMIndex[Create MigrationIndex] CreateMIndex --> FetchMDoc FetchMDoc --> FetchMRules[Fetch Migration Stats Rules index] FetchMRules --> FilterMigration{Filter Migration Docs not in Migration Index} FilterMigration --> |is Empty|END[END] FilterMigration --> |is Not Empty| CreateMDocs[Create Migration Docs] CreateMDocs --> END ``` At the time of merging this PR, the Migration indices can be in 3 states: ### There are migrations created after elastic#216164 and this means that there are `some` migrations existing in `.kibana-siem-migrations-migrations-<space_id>` and migrations created before above mentioned PR will only exist in `.kibana-siem-migrations-rules-<space_id>`. In this case `migrateRuleMigrationIndex` will create migration in below steps: 1. Look for **all** migration Documents in `.kibana-siem-migrations-migrations-<space_id>` 2. Get **all** Migrations stats from `.kibana-siem-migrations-rules-<space_id>` which includes below properties - migration_id : will help in reconciling the migration id in .kibana-siem-migrations-migrations-<space_id>` index - created_at : Date on which migration_id was created. - created_by: User who created the migrations. 3. A new document with above migration will be added to `.kibana-siem-migrations-migrations-<space_id>`. 4. Now both `.kibana-siem-migrations-migrations-<space_id>` and `.kibana-siem-migrations-rules-<space_id>` will be in sync. ### Alternatively, there are no migration created after elastic#216164. In that case, there is a possibility that `.kibana-siem-migrations-migrations-<space_id>`, will not even exist. In this case `migrateRuleMigrationIndex` will create migration in below steps: 1. Create the `.kibana-siem-migrations-migrations-<space_id>` index. 2. Do steps mentioned in above scenario. ### Once the migrations has been run successfully, both `.kibana-siem-migrations-migrations-<space_id>` index and `.kibana-siem-migrations-rules-<space_id>` will be in sync. 1. In this case, migration will not run, since it tries to filter the migrations by `id` which exist in `kibana-siem-migrations-rules-<space_id>` but do not exist in `kibana-siem-migrations-migrations-<space_id>` ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit bf642b0) # Conflicts: # x-pack/test/security_solution_cypress/cypress/urls/navigation.ts
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…221536) # Backport This will backport the following commits from `main` to `8.19`: - [[Automatic Migrations] Siem migrations new endpoint (#219597)](#219597) <!--- Backport version: 10.0.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Jatin Kathuria","email":"jatin.kathuria@elastic.co"},"sourceCommit":{"committedDate":"2025-05-22T15:23:17Z","message":"[Automatic Migrations] Siem migrations new endpoint (#219597)\n\n## Summary\n\nResolves https://github.com/elastic/security-team/issues/12483\n\nThis PR changes REST API Endpoints scheme to align with\nhttps://github.com/elastic/security-team/issues/12483. Below is the\nsummary of changes done.\n\n### API Scheme changes\n\nThe REST API scheme has been changed to reflect\nhttps://github.com/elastic/security-team/issues/12483. This is pretty\nmuch self explanatory as defined in below openapi schema yaml :\n\n-\n[x-pack/solutions/security/plugins/security_solution/common/siem_migrations/model/api/rules/rule_migration.schema.yaml](https://github.com/elastic/kibana/pull/219597/files#diff-3025af9eca156f3308474e2b42808da1531423457b7791daf6660db95a53b978)\n\n### Introduction of Delete Migration API\n\nThis PR also adds `DELETE` method on route\n`/rules/siem_migrations/{migration_id}` for deleting a migrations.\nDeleting a migration does below operations:\n\n- Stops a migration if it is running\n- Deletes the rules, resources related to migration and migration\ndocument itself.\n\n### File Reorganizations\n\nDirectly structure has been changed a little bit to reflect the\nendpoint. There is a sub-directory called `rules` which deals with only\n`rules` of the migration and the root directly only contains the\nendpoints related to the migration.\n\n#### Before\n\n```\n//siem_migrations/rules/api\n\n├── create.ts\n├── get.ts\n├── start.ts\n├── update.ts\n├── \n├── \n├── \n```\n\n#### After\n\n```\n//siem_migrations/rules/api\n\n\n├── create.ts\n├── delete.ts\n├── get.ts\n├── rules\n│ ├── add.ts\n│ ├── get.ts\n│ └── update.ts\n├── \n├── \n├── \n```\n\n## Migration Strategy\n\n### TL,DR; \n```mermaid\nflowchart TD\n StartM[Start Migration] --> isMigExists{Does Migration Index Exists}\n isMigExists -->|Yes|FetchMDoc[Fetch Migration Docs]\n isMigExists -->|No|CreateMIndex[Create MigrationIndex]\n CreateMIndex --> FetchMDoc\n FetchMDoc --> FetchMRules[Fetch Migration Stats Rules index]\n FetchMRules --> FilterMigration{Filter Migration Docs not in Migration Index}\n FilterMigration --> |is Empty|END[END]\n FilterMigration --> |is Not Empty| CreateMDocs[Create Migration Docs]\n CreateMDocs --> END\n```\n\n\n\nAt the time of merging this PR, the Migration indices can be in 3\nstates:\n\n### There are migrations created after\nhttps://github.com//pull/216164 and this means that there\nare `some` migrations existing in\n`.kibana-siem-migrations-migrations-<space_id>` and migrations created\nbefore above mentioned PR will only exist in\n`.kibana-siem-migrations-rules-<space_id>`.\n\nIn this case `migrateRuleMigrationIndex` will create migration in below\nsteps:\n\n1. Look for **all** migration Documents in\n`.kibana-siem-migrations-migrations-<space_id>`\n2. Get **all** Migrations stats from\n`.kibana-siem-migrations-rules-<space_id>` which includes below\nproperties\n- migration_id : will help in reconciling the migration id in\n.kibana-siem-migrations-migrations-<space_id>` index\n - created_at : Date on which migration_id was created.\n - created_by: User who created the migrations.\n3. A new document with above migration will be added to\n`.kibana-siem-migrations-migrations-<space_id>`.\n4. Now both `.kibana-siem-migrations-migrations-<space_id>` and\n`.kibana-siem-migrations-rules-<space_id>` will be in sync.\n\n### Alternatively, there are no migration created after\nhttps://github.com//pull/216164. In that case, there is a\npossibility that `.kibana-siem-migrations-migrations-<space_id>`, will\nnot even exist.\n\nIn this case `migrateRuleMigrationIndex` will create migration in below\nsteps:\n\n1. Create the `.kibana-siem-migrations-migrations-<space_id>` index.\n2. Do steps mentioned in above scenario.\n\n### Once the migrations has been run successfully, both\n`.kibana-siem-migrations-migrations-<space_id>` index and\n`.kibana-siem-migrations-rules-<space_id>` will be in sync.\n\n1. In this case, migration will not run, since it tries to filter the\nmigrations by `id` which exist in\n`kibana-siem-migrations-rules-<space_id>` but do not exist in\n`kibana-siem-migrations-migrations-<space_id>`\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n### Identify risks\n\nDoes this PR introduce any risks? For example, consider risks like hard\nto test bugs, performance regression, potential of data loss.\n\nDescribe the risk, its severity, and mitigation for each identified\nrisk. Invite stakeholders and evaluate how to proceed before merging.\n\n- [ ] [See some risk\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n- [ ] ...\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"bf642b00395079ef0e2f334b4fca65d2ff15d94c","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport missing","release_note:feature","backport:version","v9.1.0","v8.19.0"],"title":"[Automatic Migrations] Siem migrations new endpoint scheme","number":219597,"url":"https://github.com/elastic/kibana/pull/219597","mergeCommit":{"message":"[Automatic Migrations] Siem migrations new endpoint (#219597)\n\n## Summary\n\nResolves https://github.com/elastic/security-team/issues/12483\n\nThis PR changes REST API Endpoints scheme to align with\nhttps://github.com/elastic/security-team/issues/12483. Below is the\nsummary of changes done.\n\n### API Scheme changes\n\nThe REST API scheme has been changed to reflect\nhttps://github.com/elastic/security-team/issues/12483. This is pretty\nmuch self explanatory as defined in below openapi schema yaml :\n\n-\n[x-pack/solutions/security/plugins/security_solution/common/siem_migrations/model/api/rules/rule_migration.schema.yaml](https://github.com/elastic/kibana/pull/219597/files#diff-3025af9eca156f3308474e2b42808da1531423457b7791daf6660db95a53b978)\n\n### Introduction of Delete Migration API\n\nThis PR also adds `DELETE` method on route\n`/rules/siem_migrations/{migration_id}` for deleting a migrations.\nDeleting a migration does below operations:\n\n- Stops a migration if it is running\n- Deletes the rules, resources related to migration and migration\ndocument itself.\n\n### File Reorganizations\n\nDirectly structure has been changed a little bit to reflect the\nendpoint. There is a sub-directory called `rules` which deals with only\n`rules` of the migration and the root directly only contains the\nendpoints related to the migration.\n\n#### Before\n\n```\n//siem_migrations/rules/api\n\n├── create.ts\n├── get.ts\n├── start.ts\n├── update.ts\n├── \n├── \n├── \n```\n\n#### After\n\n```\n//siem_migrations/rules/api\n\n\n├── create.ts\n├── delete.ts\n├── get.ts\n├── rules\n│ ├── add.ts\n│ ├── get.ts\n│ └── update.ts\n├── \n├── \n├── \n```\n\n## Migration Strategy\n\n### TL,DR; \n```mermaid\nflowchart TD\n StartM[Start Migration] --> isMigExists{Does Migration Index Exists}\n isMigExists -->|Yes|FetchMDoc[Fetch Migration Docs]\n isMigExists -->|No|CreateMIndex[Create MigrationIndex]\n CreateMIndex --> FetchMDoc\n FetchMDoc --> FetchMRules[Fetch Migration Stats Rules index]\n FetchMRules --> FilterMigration{Filter Migration Docs not in Migration Index}\n FilterMigration --> |is Empty|END[END]\n FilterMigration --> |is Not Empty| CreateMDocs[Create Migration Docs]\n CreateMDocs --> END\n```\n\n\n\nAt the time of merging this PR, the Migration indices can be in 3\nstates:\n\n### There are migrations created after\nhttps://github.com//pull/216164 and this means that there\nare `some` migrations existing in\n`.kibana-siem-migrations-migrations-<space_id>` and migrations created\nbefore above mentioned PR will only exist in\n`.kibana-siem-migrations-rules-<space_id>`.\n\nIn this case `migrateRuleMigrationIndex` will create migration in below\nsteps:\n\n1. Look for **all** migration Documents in\n`.kibana-siem-migrations-migrations-<space_id>`\n2. Get **all** Migrations stats from\n`.kibana-siem-migrations-rules-<space_id>` which includes below\nproperties\n- migration_id : will help in reconciling the migration id in\n.kibana-siem-migrations-migrations-<space_id>` index\n - created_at : Date on which migration_id was created.\n - created_by: User who created the migrations.\n3. A new document with above migration will be added to\n`.kibana-siem-migrations-migrations-<space_id>`.\n4. Now both `.kibana-siem-migrations-migrations-<space_id>` and\n`.kibana-siem-migrations-rules-<space_id>` will be in sync.\n\n### Alternatively, there are no migration created after\nhttps://github.com//pull/216164. In that case, there is a\npossibility that `.kibana-siem-migrations-migrations-<space_id>`, will\nnot even exist.\n\nIn this case `migrateRuleMigrationIndex` will create migration in below\nsteps:\n\n1. Create the `.kibana-siem-migrations-migrations-<space_id>` index.\n2. Do steps mentioned in above scenario.\n\n### Once the migrations has been run successfully, both\n`.kibana-siem-migrations-migrations-<space_id>` index and\n`.kibana-siem-migrations-rules-<space_id>` will be in sync.\n\n1. In this case, migration will not run, since it tries to filter the\nmigrations by `id` which exist in\n`kibana-siem-migrations-rules-<space_id>` but do not exist in\n`kibana-siem-migrations-migrations-<space_id>`\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n### Identify risks\n\nDoes this PR introduce any risks? For example, consider risks like hard\nto test bugs, performance regression, potential of data loss.\n\nDescribe the risk, its severity, and mitigation for each identified\nrisk. Invite stakeholders and evaluate how to proceed before merging.\n\n- [ ] [See some risk\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n- [ ] ...\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"bf642b00395079ef0e2f334b4fca65d2ff15d94c"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219597","number":219597,"mergeCommit":{"message":"[Automatic Migrations] Siem migrations new endpoint (#219597)\n\n## Summary\n\nResolves https://github.com/elastic/security-team/issues/12483\n\nThis PR changes REST API Endpoints scheme to align with\nhttps://github.com/elastic/security-team/issues/12483. Below is the\nsummary of changes done.\n\n### API Scheme changes\n\nThe REST API scheme has been changed to reflect\nhttps://github.com/elastic/security-team/issues/12483. This is pretty\nmuch self explanatory as defined in below openapi schema yaml :\n\n-\n[x-pack/solutions/security/plugins/security_solution/common/siem_migrations/model/api/rules/rule_migration.schema.yaml](https://github.com/elastic/kibana/pull/219597/files#diff-3025af9eca156f3308474e2b42808da1531423457b7791daf6660db95a53b978)\n\n### Introduction of Delete Migration API\n\nThis PR also adds `DELETE` method on route\n`/rules/siem_migrations/{migration_id}` for deleting a migrations.\nDeleting a migration does below operations:\n\n- Stops a migration if it is running\n- Deletes the rules, resources related to migration and migration\ndocument itself.\n\n### File Reorganizations\n\nDirectly structure has been changed a little bit to reflect the\nendpoint. There is a sub-directory called `rules` which deals with only\n`rules` of the migration and the root directly only contains the\nendpoints related to the migration.\n\n#### Before\n\n```\n//siem_migrations/rules/api\n\n├── create.ts\n├── get.ts\n├── start.ts\n├── update.ts\n├── \n├── \n├── \n```\n\n#### After\n\n```\n//siem_migrations/rules/api\n\n\n├── create.ts\n├── delete.ts\n├── get.ts\n├── rules\n│ ├── add.ts\n│ ├── get.ts\n│ └── update.ts\n├── \n├── \n├── \n```\n\n## Migration Strategy\n\n### TL,DR; \n```mermaid\nflowchart TD\n StartM[Start Migration] --> isMigExists{Does Migration Index Exists}\n isMigExists -->|Yes|FetchMDoc[Fetch Migration Docs]\n isMigExists -->|No|CreateMIndex[Create MigrationIndex]\n CreateMIndex --> FetchMDoc\n FetchMDoc --> FetchMRules[Fetch Migration Stats Rules index]\n FetchMRules --> FilterMigration{Filter Migration Docs not in Migration Index}\n FilterMigration --> |is Empty|END[END]\n FilterMigration --> |is Not Empty| CreateMDocs[Create Migration Docs]\n CreateMDocs --> END\n```\n\n\n\nAt the time of merging this PR, the Migration indices can be in 3\nstates:\n\n### There are migrations created after\nhttps://github.com//pull/216164 and this means that there\nare `some` migrations existing in\n`.kibana-siem-migrations-migrations-<space_id>` and migrations created\nbefore above mentioned PR will only exist in\n`.kibana-siem-migrations-rules-<space_id>`.\n\nIn this case `migrateRuleMigrationIndex` will create migration in below\nsteps:\n\n1. Look for **all** migration Documents in\n`.kibana-siem-migrations-migrations-<space_id>`\n2. Get **all** Migrations stats from\n`.kibana-siem-migrations-rules-<space_id>` which includes below\nproperties\n- migration_id : will help in reconciling the migration id in\n.kibana-siem-migrations-migrations-<space_id>` index\n - created_at : Date on which migration_id was created.\n - created_by: User who created the migrations.\n3. A new document with above migration will be added to\n`.kibana-siem-migrations-migrations-<space_id>`.\n4. Now both `.kibana-siem-migrations-migrations-<space_id>` and\n`.kibana-siem-migrations-rules-<space_id>` will be in sync.\n\n### Alternatively, there are no migration created after\nhttps://github.com//pull/216164. In that case, there is a\npossibility that `.kibana-siem-migrations-migrations-<space_id>`, will\nnot even exist.\n\nIn this case `migrateRuleMigrationIndex` will create migration in below\nsteps:\n\n1. Create the `.kibana-siem-migrations-migrations-<space_id>` index.\n2. Do steps mentioned in above scenario.\n\n### Once the migrations has been run successfully, both\n`.kibana-siem-migrations-migrations-<space_id>` index and\n`.kibana-siem-migrations-rules-<space_id>` will be in sync.\n\n1. In this case, migration will not run, since it tries to filter the\nmigrations by `id` which exist in\n`kibana-siem-migrations-rules-<space_id>` but do not exist in\n`kibana-siem-migrations-migrations-<space_id>`\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n### Identify risks\n\nDoes this PR introduce any risks? For example, consider risks like hard\nto test bugs, performance regression, potential of data loss.\n\nDescribe the risk, its severity, and mitigation for each identified\nrisk. Invite stakeholders and evaluate how to proceed before merging.\n\n- [ ] [See some risk\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n- [ ] ...\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"bf642b00395079ef0e2f334b4fca65d2ff15d94c"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
## Summary Resolves elastic/security-team#12483 This PR changes REST API Endpoints scheme to align with elastic/security-team#12483. Below is the summary of changes done. ### API Scheme changes The REST API scheme has been changed to reflect elastic/security-team#12483. This is pretty much self explanatory as defined in below openapi schema yaml : - [x-pack/solutions/security/plugins/security_solution/common/siem_migrations/model/api/rules/rule_migration.schema.yaml](https://github.com/elastic/kibana/pull/219597/files#diff-3025af9eca156f3308474e2b42808da1531423457b7791daf6660db95a53b978) ### Introduction of Delete Migration API This PR also adds `DELETE` method on route `/rules/siem_migrations/{migration_id}` for deleting a migrations. Deleting a migration does below operations: - Stops a migration if it is running - Deletes the rules, resources related to migration and migration document itself. ### File Reorganizations Directly structure has been changed a little bit to reflect the endpoint. There is a sub-directory called `rules` which deals with only `rules` of the migration and the root directly only contains the endpoints related to the migration. #### Before ``` //siem_migrations/rules/api ├── create.ts ├── get.ts ├── start.ts ├── update.ts ├── ├── ├── ``` #### After ``` //siem_migrations/rules/api ├── create.ts ├── delete.ts ├── get.ts ├── rules │ ├── add.ts │ ├── get.ts │ └── update.ts ├── ├── ├── ``` ## Migration Strategy ### TL,DR; ```mermaid flowchart TD StartM[Start Migration] --> isMigExists{Does Migration Index Exists} isMigExists -->|Yes|FetchMDoc[Fetch Migration Docs] isMigExists -->|No|CreateMIndex[Create MigrationIndex] CreateMIndex --> FetchMDoc FetchMDoc --> FetchMRules[Fetch Migration Stats Rules index] FetchMRules --> FilterMigration{Filter Migration Docs not in Migration Index} FilterMigration --> |is Empty|END[END] FilterMigration --> |is Not Empty| CreateMDocs[Create Migration Docs] CreateMDocs --> END ``` At the time of merging this PR, the Migration indices can be in 3 states: ### There are migrations created after elastic#216164 and this means that there are `some` migrations existing in `.kibana-siem-migrations-migrations-<space_id>` and migrations created before above mentioned PR will only exist in `.kibana-siem-migrations-rules-<space_id>`. In this case `migrateRuleMigrationIndex` will create migration in below steps: 1. Look for **all** migration Documents in `.kibana-siem-migrations-migrations-<space_id>` 2. Get **all** Migrations stats from `.kibana-siem-migrations-rules-<space_id>` which includes below properties - migration_id : will help in reconciling the migration id in .kibana-siem-migrations-migrations-<space_id>` index - created_at : Date on which migration_id was created. - created_by: User who created the migrations. 3. A new document with above migration will be added to `.kibana-siem-migrations-migrations-<space_id>`. 4. Now both `.kibana-siem-migrations-migrations-<space_id>` and `.kibana-siem-migrations-rules-<space_id>` will be in sync. ### Alternatively, there are no migration created after elastic#216164. In that case, there is a possibility that `.kibana-siem-migrations-migrations-<space_id>`, will not even exist. In this case `migrateRuleMigrationIndex` will create migration in below steps: 1. Create the `.kibana-siem-migrations-migrations-<space_id>` index. 2. Do steps mentioned in above scenario. ### Once the migrations has been run successfully, both `.kibana-siem-migrations-migrations-<space_id>` index and `.kibana-siem-migrations-rules-<space_id>` will be in sync. 1. In this case, migration will not run, since it tries to filter the migrations by `id` which exist in `kibana-siem-migrations-rules-<space_id>` but do not exist in `kibana-siem-migrations-migrations-<space_id>` ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
|
Pinging @elastic/security-solution (Team: SecuritySolution) |
Summary
Resolves https://github.com/elastic/security-team/issues/12483
This PR changes REST API Endpoints scheme to align with https://github.com/elastic/security-team/issues/12483. Below is the summary of changes done.
API Scheme changes
The REST API scheme has been changed to reflect https://github.com/elastic/security-team/issues/12483. This is pretty much self explanatory as defined in below openapi schema yaml :
Introduction of Delete Migration API
This PR also adds
DELETEmethod on route/rules/siem_migrations/{migration_id}for deleting a migrations. Deleting a migration does below operations:File Reorganizations
Directly structure has been changed a little bit to reflect the endpoint. There is a sub-directory called
ruleswhich deals with onlyrulesof the migration and the root directly only contains the endpoints related to the migration.Before
After
Migration Strategy
TL,DR;
flowchart TD StartM[Start Migration] --> isMigExists{Does Migration Index Exists} isMigExists -->|Yes|FetchMDoc[Fetch Migration Docs] isMigExists -->|No|CreateMIndex[Create MigrationIndex] CreateMIndex --> FetchMDoc FetchMDoc --> FetchMRules[Fetch Migration Stats Rules index] FetchMRules --> FilterMigration{Filter Migration Docs not in Migration Index} FilterMigration --> |is Empty|END[END] FilterMigration --> |is Not Empty| CreateMDocs[Create Migration Docs] CreateMDocs --> ENDAt the time of merging this PR, the Migration indices can be in 3 states:
There are migrations created after #216164 and this means that there are
somemigrations existing in.kibana-siem-migrations-migrations-<space_id>and migrations created before above mentioned PR will only exist in.kibana-siem-migrations-rules-<space_id>.In this case
migrateRuleMigrationIndexwill create migration in below steps:.kibana-siem-migrations-migrations-<space_id>.kibana-siem-migrations-rules-<space_id>which includes below properties.kibana-siem-migrations-migrations-<space_id>..kibana-siem-migrations-migrations-<space_id>and.kibana-siem-migrations-rules-<space_id>will be in sync.Alternatively, there are no migration created after #216164. In that case, there is a possibility that
.kibana-siem-migrations-migrations-<space_id>, will not even exist.In this case
migrateRuleMigrationIndexwill create migration in below steps:.kibana-siem-migrations-migrations-<space_id>index.Once the migrations has been run successfully, both
.kibana-siem-migrations-migrations-<space_id>index and.kibana-siem-migrations-rules-<space_id>will be in sync.idwhich exist inkibana-siem-migrations-rules-<space_id>but do not exist inkibana-siem-migrations-migrations-<space_id>Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:*label is applied per the guidelinesIdentify risks
Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss.
Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging.