[8.17] [Entity Analytics] API changes for right placement of deleting the old component template (#199734) (#212378)

# Backport

This will backport the following commits from `main` to `8.17`:
- [[Entity Analytics] API changes for right placement of deleting the
old component template
(#199734)](https://github.com/elastic/kibana/pull/199734)

<!--- Backport version: 9.6.4 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Abhishek
Bhatia","email":"117628830+abhishekbhatia1710@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-11-18T15:07:13Z","message":"[Entity
Analytics] API changes for right placement of deleting the old component
template (#199734)\n\n## Summary\r\n\r\n- Delete the old component
template after the index template has\r\nreferenced to the new component
template\r\n- Test cases for the same flow\r\n\r\n\r\n```JSON\r\n# Let's
assume this is 8.15.3\r\n# Create the component template when Risk Score
engine is initialised\r\n# Create the index template which references
the created component template\r\n\r\nPUT
/_component_template/.risk-score-mappings\r\n{\r\n \"template\": {\r\n
\"settings\": {\r\n \"number_of_shards\": 1\r\n },\r\n \"mappings\":
{\r\n \"properties\": {\r\n \"timestamp\": {\r\n \"type\": \"date\"\r\n
},\r\n \"user\": {\r\n \"properties\": {\r\n \"id\": {\r\n \"type\":
\"keyword\"\r\n },\r\n \"name\": {\r\n \"type\": \"text\"\r\n }\r\n
}\r\n }\r\n }\r\n }\r\n },\r\n \"version\": 1\r\n}\r\n\r\nPUT
/_index_template/.risk-score.risk-score-default-index-template\r\n{\r\n
\"index_patterns\":
[\".risk-score.risk-score-default-index-template\"],\r\n \"template\":
{\r\n \"settings\": {\r\n \"number_of_replicas\": 1\r\n }\r\n },\r\n
\"composed_of\": [\".risk-score-mappings\"],\r\n \"priority\": 100,\r\n
\"version\": 1,\r\n \"_meta\": {\r\n \"description\": \"Index template
for indices with the pattern my_index-*\"\r\n }\r\n}\r\n\r\n# The
deployment is updated to 8.16\r\n# User tries to enable the Entity store
which init's the Risk Score engine (again!!) \r\n# Fails, but creates
the component template and cannot update the index template to reference
the new component template due to the error\r\n\r\nPUT
/_component_template/.risk-score-mappings-default\r\n{\r\n \"template\":
{\r\n \"settings\": {\r\n \"number_of_shards\": 1\r\n },\r\n
\"mappings\": {\r\n \"properties\": {\r\n \"timestamp\": {\r\n \"type\":
\"date\"\r\n },\r\n \"user\": {\r\n \"properties\": {\r\n \"id\": {\r\n
\"type\": \"keyword\"\r\n },\r\n \"name\": {\r\n \"type\": \"text\"\r\n
}\r\n }\r\n }\r\n }\r\n }\r\n },\r\n \"version\": 1\r\n}\r\n\r\nGET
/_component_template?filter_path=component_templates.name&name=.risk-score-mappings*\r\n\r\n\r\nDELETE
/_component_template/.risk-score-mappings\r\n\r\n# Fails \r\n\r\n#
changed flow\r\nPUT
/_index_template/.risk-score.risk-score-default-index-template\r\n{\r\n
\"index_patterns\":
[\".risk-score.risk-score-default-index-template\"],\r\n \"template\":
{\r\n \"settings\": {\r\n \"number_of_replicas\": 1\r\n }\r\n },\r\n
\"composed_of\": [\".risk-score-mappings-default\"],\r\n \"priority\":
100,\r\n \"version\": 1,\r\n \"_meta\": {\r\n \"description\": \"Index
template for indices with the pattern my_index-*\"\r\n
}\r\n}\r\n\r\nDELETE /_component_template/.risk-score-mappings\r\n\r\n#
Succeeds\r\n\r\n#########\r\n```\r\n\r\n\r\n### Checklist\r\n\r\nDelete
any items that are not applicable to this PR.\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n\r\n\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\r\n-
[ ] This will appear in the **Release Notes** and follow
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"771c139269ac0eac27274e0858be2fbcf87b31e3","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","v9.0.0","QA:Validated","Team:Entity
Analytics","backport:version","v8.17.0","v8.16.1","v8.18.0"],"title":"[Entity
Analytics] API changes for right placement of deleting the old component
template","number":199734,"url":"https://github.com/elastic/kibana/pull/199734","mergeCommit":{"message":"[Entity
Analytics] API changes for right placement of deleting the old component
template (#199734)\n\n## Summary\r\n\r\n- Delete the old component
template after the index template has\r\nreferenced to the new component
template\r\n- Test cases for the same flow\r\n\r\n\r\n```JSON\r\n# Let's
assume this is 8.15.3\r\n# Create the component template when Risk Score
engine is initialised\r\n# Create the index template which references
the created component template\r\n\r\nPUT
/_component_template/.risk-score-mappings\r\n{\r\n \"template\": {\r\n
\"settings\": {\r\n \"number_of_shards\": 1\r\n },\r\n \"mappings\":
{\r\n \"properties\": {\r\n \"timestamp\": {\r\n \"type\": \"date\"\r\n
},\r\n \"user\": {\r\n \"properties\": {\r\n \"id\": {\r\n \"type\":
\"keyword\"\r\n },\r\n \"name\": {\r\n \"type\": \"text\"\r\n }\r\n
}\r\n }\r\n }\r\n }\r\n },\r\n \"version\": 1\r\n}\r\n\r\nPUT
/_index_template/.risk-score.risk-score-default-index-template\r\n{\r\n
\"index_patterns\":
[\".risk-score.risk-score-default-index-template\"],\r\n \"template\":
{\r\n \"settings\": {\r\n \"number_of_replicas\": 1\r\n }\r\n },\r\n
\"composed_of\": [\".risk-score-mappings\"],\r\n \"priority\": 100,\r\n
\"version\": 1,\r\n \"_meta\": {\r\n \"description\": \"Index template
for indices with the pattern my_index-*\"\r\n }\r\n}\r\n\r\n# The
deployment is updated to 8.16\r\n# User tries to enable the Entity store
which init's the Risk Score engine (again!!) \r\n# Fails, but creates
the component template and cannot update the index template to reference
the new component template due to the error\r\n\r\nPUT
/_component_template/.risk-score-mappings-default\r\n{\r\n \"template\":
{\r\n \"settings\": {\r\n \"number_of_shards\": 1\r\n },\r\n
\"mappings\": {\r\n \"properties\": {\r\n \"timestamp\": {\r\n \"type\":
\"date\"\r\n },\r\n \"user\": {\r\n \"properties\": {\r\n \"id\": {\r\n
\"type\": \"keyword\"\r\n },\r\n \"name\": {\r\n \"type\": \"text\"\r\n
}\r\n }\r\n }\r\n }\r\n }\r\n },\r\n \"version\": 1\r\n}\r\n\r\nGET
/_component_template?filter_path=component_templates.name&name=.risk-score-mappings*\r\n\r\n\r\nDELETE
/_component_template/.risk-score-mappings\r\n\r\n# Fails \r\n\r\n#
changed flow\r\nPUT
/_index_template/.risk-score.risk-score-default-index-template\r\n{\r\n
\"index_patterns\":
[\".risk-score.risk-score-default-index-template\"],\r\n \"template\":
{\r\n \"settings\": {\r\n \"number_of_replicas\": 1\r\n }\r\n },\r\n
\"composed_of\": [\".risk-score-mappings-default\"],\r\n \"priority\":
100,\r\n \"version\": 1,\r\n \"_meta\": {\r\n \"description\": \"Index
template for indices with the pattern my_index-*\"\r\n
}\r\n}\r\n\r\nDELETE /_component_template/.risk-score-mappings\r\n\r\n#
Succeeds\r\n\r\n#########\r\n```\r\n\r\n\r\n### Checklist\r\n\r\nDelete
any items that are not applicable to this PR.\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n\r\n\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\r\n-
[ ] This will appear in the **Release Notes** and follow
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"771c139269ac0eac27274e0858be2fbcf87b31e3"}},"sourceBranch":"main","suggestedTargetBranches":["8.18"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/199734","number":199734,"mergeCommit":{"message":"[Entity
Analytics] API changes for right placement of deleting the old component
template (#199734)\n\n## Summary\r\n\r\n- Delete the old component
template after the index template has\r\nreferenced to the new component
template\r\n- Test cases for the same flow\r\n\r\n\r\n```JSON\r\n# Let's
assume this is 8.15.3\r\n# Create the component template when Risk Score
engine is initialised\r\n# Create the index template which references
the created component template\r\n\r\nPUT
/_component_template/.risk-score-mappings\r\n{\r\n \"template\": {\r\n
\"settings\": {\r\n \"number_of_shards\": 1\r\n },\r\n \"mappings\":
{\r\n \"properties\": {\r\n \"timestamp\": {\r\n \"type\": \"date\"\r\n
},\r\n \"user\": {\r\n \"properties\": {\r\n \"id\": {\r\n \"type\":
\"keyword\"\r\n },\r\n \"name\": {\r\n \"type\": \"text\"\r\n }\r\n
}\r\n }\r\n }\r\n }\r\n },\r\n \"version\": 1\r\n}\r\n\r\nPUT
/_index_template/.risk-score.risk-score-default-index-template\r\n{\r\n
\"index_patterns\":
[\".risk-score.risk-score-default-index-template\"],\r\n \"template\":
{\r\n \"settings\": {\r\n \"number_of_replicas\": 1\r\n }\r\n },\r\n
\"composed_of\": [\".risk-score-mappings\"],\r\n \"priority\": 100,\r\n
\"version\": 1,\r\n \"_meta\": {\r\n \"description\": \"Index template
for indices with the pattern my_index-*\"\r\n }\r\n}\r\n\r\n# The
deployment is updated to 8.16\r\n# User tries to enable the Entity store
which init's the Risk Score engine (again!!) \r\n# Fails, but creates
the component template and cannot update the index template to reference
the new component template due to the error\r\n\r\nPUT
/_component_template/.risk-score-mappings-default\r\n{\r\n \"template\":
{\r\n \"settings\": {\r\n \"number_of_shards\": 1\r\n },\r\n
\"mappings\": {\r\n \"properties\": {\r\n \"timestamp\": {\r\n \"type\":
\"date\"\r\n },\r\n \"user\": {\r\n \"properties\": {\r\n \"id\": {\r\n
\"type\": \"keyword\"\r\n },\r\n \"name\": {\r\n \"type\": \"text\"\r\n
}\r\n }\r\n }\r\n }\r\n }\r\n },\r\n \"version\": 1\r\n}\r\n\r\nGET
/_component_template?filter_path=component_templates.name&name=.risk-score-mappings*\r\n\r\n\r\nDELETE
/_component_template/.risk-score-mappings\r\n\r\n# Fails \r\n\r\n#
changed flow\r\nPUT
/_index_template/.risk-score.risk-score-default-index-template\r\n{\r\n
\"index_patterns\":
[\".risk-score.risk-score-default-index-template\"],\r\n \"template\":
{\r\n \"settings\": {\r\n \"number_of_replicas\": 1\r\n }\r\n },\r\n
\"composed_of\": [\".risk-score-mappings-default\"],\r\n \"priority\":
100,\r\n \"version\": 1,\r\n \"_meta\": {\r\n \"description\": \"Index
template for indices with the pattern my_index-*\"\r\n
}\r\n}\r\n\r\nDELETE /_component_template/.risk-score-mappings\r\n\r\n#
Succeeds\r\n\r\n#########\r\n```\r\n\r\n\r\n### Checklist\r\n\r\nDelete
any items that are not applicable to this PR.\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n\r\n\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\r\n-
[ ] This will appear in the **Release Notes** and follow
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"771c139269ac0eac27274e0858be2fbcf87b31e3"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/200673","number":200673,"state":"MERGED","mergeCommit":{"sha":"24cbc3ee37cca9610bb8848c7361deeb4dc63ac4","message":"[8.x]
[Entity Analytics] API changes for right placement of deleting the old
component template (#199734) (#200673)\n\n# Backport\n\nThis will
backport the following commits from `main` to `8.x`:\n- [[Entity
Analytics] API changes for right placement of deleting the\nold
component
template\n(#199734)](https://github.com/elastic/kibana/pull/199734)\n\n<!---
Backport version: 8.9.8 -->\n\n### Questions ?\nPlease refer to the
[Backport
tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT
[{\"author\":{\"name\":\"Abhishek\nBhatia\",\"email\":\"117628830+abhishekbhatia1710@users.noreply.github.com\"},\"sourceCommit\":{\"committedDate\":\"2024-11-18T15:07:13Z\",\"message\":\"[Entity\nAnalytics]
API changes for right placement of deleting the old component\ntemplate
(#199734)\\n\\n## Summary\\r\\n\\r\\n- Delete the old
component\ntemplate after the index template has\\r\\nreferenced to the
new component\ntemplate\\r\\n- Test cases for the same
flow\\r\\n\\r\\n\\r\\n```JSON\\r\\n# Let's\nassume this is 8.15.3\\r\\n#
Create the component template when Risk Score\nengine is
initialised\\r\\n# Create the index template which references\nthe
created component
template\\r\\n\\r\\nPUT\n/_component_template/.risk-score-mappings\\r\\n{\\r\\n
\\\"template\\\": {\\r\\n\n\\\"settings\\\": {\\r\\n
\\\"number_of_shards\\\": 1\\r\\n },\\r\\n \\\"mappings\\\":\n{\\r\\n
\\\"properties\\\": {\\r\\n \\\"timestamp\\\": {\\r\\n \\\"type\\\":
\\\"date\\\"\\r\\n\n},\\r\\n \\\"user\\\": {\\r\\n \\\"properties\\\":
{\\r\\n \\\"id\\\": {\\r\\n \\\"type\\\":\n\\\"keyword\\\"\\r\\n
},\\r\\n \\\"name\\\": {\\r\\n \\\"type\\\": \\\"text\\\"\\r\\n
}\\r\\n\n}\\r\\n }\\r\\n }\\r\\n }\\r\\n },\\r\\n \\\"version\\\":
1\\r\\n}\\r\\n\\r\\nPUT\n/_index_template/.risk-score.risk-score-default-index-template\\r\\n{\\r\\n\n\\\"index_patterns\\\":\n[\\\".risk-score.risk-score-default-index-template\\\"],\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_replicas\\\": 1\\r\\n }\\r\\n
},\\r\\n\n\\\"composed_of\\\": [\\\".risk-score-mappings\\\"],\\r\\n
\\\"priority\\\": 100,\\r\\n\n\\\"version\\\": 1,\\r\\n \\\"_meta\\\":
{\\r\\n \\\"description\\\": \\\"Index template\nfor indices with the
pattern my_index-*\\\"\\r\\n }\\r\\n}\\r\\n\\r\\n# The\ndeployment is
updated to 8.16\\r\\n# User tries to enable the Entity store\nwhich
init's the Risk Score engine (again!!) \\r\\n# Fails, but creates\nthe
component template and cannot update the index template to
reference\nthe new component template due to the
error\\r\\n\\r\\nPUT\n/_component_template/.risk-score-mappings-default\\r\\n{\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_shards\\\": 1\\r\\n },\\r\\n\n\\\"mappings\\\": {\\r\\n
\\\"properties\\\": {\\r\\n \\\"timestamp\\\": {\\r\\n
\\\"type\\\":\n\\\"date\\\"\\r\\n },\\r\\n \\\"user\\\": {\\r\\n
\\\"properties\\\": {\\r\\n \\\"id\\\": {\\r\\n\n\\\"type\\\":
\\\"keyword\\\"\\r\\n },\\r\\n \\\"name\\\": {\\r\\n \\\"type\\\":
\\\"text\\\"\\r\\n\n}\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n },\\r\\n
\\\"version\\\":
1\\r\\n}\\r\\n\\r\\nGET\n/_component_template?filter_path=component_templates.name&name=.risk-score-mappings*\\r\\n\\r\\n\\r\\nDELETE\n/_component_template/.risk-score-mappings\\r\\n\\r\\n#
Fails \\r\\n\\r\\n#\nchanged
flow\\r\\nPUT\n/_index_template/.risk-score.risk-score-default-index-template\\r\\n{\\r\\n\n\\\"index_patterns\\\":\n[\\\".risk-score.risk-score-default-index-template\\\"],\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_replicas\\\": 1\\r\\n }\\r\\n
},\\r\\n\n\\\"composed_of\\\":
[\\\".risk-score-mappings-default\\\"],\\r\\n
\\\"priority\\\":\n100,\\r\\n \\\"version\\\": 1,\\r\\n \\\"_meta\\\":
{\\r\\n \\\"description\\\": \\\"Index\ntemplate for indices with the
pattern my_index-*\\\"\\r\\n\n}\\r\\n}\\r\\n\\r\\nDELETE
/_component_template/.risk-score-mappings\\r\\n\\r\\n#\nSucceeds\\r\\n\\r\\n#########\\r\\n```\\r\\n\\r\\n\\r\\n###
Checklist\\r\\n\\r\\nDelete\nany items that are not applicable to this
PR.\\r\\n\\r\\n- [ ] [Unit
or\nfunctional\\r\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\r\\nwere\nupdated
or added to match the most common scenarios\\r\\n- [ ]
[Flaky\nTest\\r\\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)\nwas\\r\\nused
on any tests changed\\r\\n\\r\\n\\r\\n\\r\\n###
For\nmaintainers\\r\\n\\r\\n- [ ] This was checked for breaking API
changes
and\nwas\n[labeled\\r\\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\\r\\n-\n[
] This will appear in the **Release Notes** and
follow\nthe\\r\\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\",\"sha\":\"771c139269ac0eac27274e0858be2fbcf87b31e3\",\"branchLabelMapping\":{\"^v9.0.0$\":\"main\",\"^v8.17.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"bug\",\"release_note:fix\",\"v9.0.0\",\"Team:Entity\nAnalytics\",\"backport:version\",\"v8.17.0\",\"v8.16.1\"],\"number\":199734,\"url\":\"https://github.com/elastic/kibana/pull/199734\",\"mergeCommit\":{\"message\":\"[Entity\nAnalytics]
API changes for right placement of deleting the old component\ntemplate
(#199734)\\n\\n## Summary\\r\\n\\r\\n- Delete the old
component\ntemplate after the index template has\\r\\nreferenced to the
new component\ntemplate\\r\\n- Test cases for the same
flow\\r\\n\\r\\n\\r\\n```JSON\\r\\n# Let's\nassume this is 8.15.3\\r\\n#
Create the component template when Risk Score\nengine is
initialised\\r\\n# Create the index template which references\nthe
created component
template\\r\\n\\r\\nPUT\n/_component_template/.risk-score-mappings\\r\\n{\\r\\n
\\\"template\\\": {\\r\\n\n\\\"settings\\\": {\\r\\n
\\\"number_of_shards\\\": 1\\r\\n },\\r\\n \\\"mappings\\\":\n{\\r\\n
\\\"properties\\\": {\\r\\n \\\"timestamp\\\": {\\r\\n \\\"type\\\":
\\\"date\\\"\\r\\n\n},\\r\\n \\\"user\\\": {\\r\\n \\\"properties\\\":
{\\r\\n \\\"id\\\": {\\r\\n \\\"type\\\":\n\\\"keyword\\\"\\r\\n
},\\r\\n \\\"name\\\": {\\r\\n \\\"type\\\": \\\"text\\\"\\r\\n
}\\r\\n\n}\\r\\n }\\r\\n }\\r\\n }\\r\\n },\\r\\n \\\"version\\\":
1\\r\\n}\\r\\n\\r\\nPUT\n/_index_template/.risk-score.risk-score-default-index-template\\r\\n{\\r\\n\n\\\"index_patterns\\\":\n[\\\".risk-score.risk-score-default-index-template\\\"],\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_replicas\\\": 1\\r\\n }\\r\\n
},\\r\\n\n\\\"composed_of\\\": [\\\".risk-score-mappings\\\"],\\r\\n
\\\"priority\\\": 100,\\r\\n\n\\\"version\\\": 1,\\r\\n \\\"_meta\\\":
{\\r\\n \\\"description\\\": \\\"Index template\nfor indices with the
pattern my_index-*\\\"\\r\\n }\\r\\n}\\r\\n\\r\\n# The\ndeployment is
updated to 8.16\\r\\n# User tries to enable the Entity store\nwhich
init's the Risk Score engine (again!!) \\r\\n# Fails, but creates\nthe
component template and cannot update the index template to
reference\nthe new component template due to the
error\\r\\n\\r\\nPUT\n/_component_template/.risk-score-mappings-default\\r\\n{\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_shards\\\": 1\\r\\n },\\r\\n\n\\\"mappings\\\": {\\r\\n
\\\"properties\\\": {\\r\\n \\\"timestamp\\\": {\\r\\n
\\\"type\\\":\n\\\"date\\\"\\r\\n },\\r\\n \\\"user\\\": {\\r\\n
\\\"properties\\\": {\\r\\n \\\"id\\\": {\\r\\n\n\\\"type\\\":
\\\"keyword\\\"\\r\\n },\\r\\n \\\"name\\\": {\\r\\n \\\"type\\\":
\\\"text\\\"\\r\\n\n}\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n },\\r\\n
\\\"version\\\":
1\\r\\n}\\r\\n\\r\\nGET\n/_component_template?filter_path=component_templates.name&name=.risk-score-mappings*\\r\\n\\r\\n\\r\\nDELETE\n/_component_template/.risk-score-mappings\\r\\n\\r\\n#
Fails \\r\\n\\r\\n#\nchanged
flow\\r\\nPUT\n/_index_template/.risk-score.risk-score-default-index-template\\r\\n{\\r\\n\n\\\"index_patterns\\\":\n[\\\".risk-score.risk-score-default-index-template\\\"],\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_replicas\\\": 1\\r\\n }\\r\\n
},\\r\\n\n\\\"composed_of\\\":
[\\\".risk-score-mappings-default\\\"],\\r\\n
\\\"priority\\\":\n100,\\r\\n \\\"version\\\": 1,\\r\\n \\\"_meta\\\":
{\\r\\n \\\"description\\\": \\\"Index\ntemplate for indices with the
pattern my_index-*\\\"\\r\\n\n}\\r\\n}\\r\\n\\r\\nDELETE
/_component_template/.risk-score-mappings\\r\\n\\r\\n#\nSucceeds\\r\\n\\r\\n#########\\r\\n```\\r\\n\\r\\n\\r\\n###
Checklist\\r\\n\\r\\nDelete\nany items that are not applicable to this
PR.\\r\\n\\r\\n- [ ] [Unit
or\nfunctional\\r\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\r\\nwere\nupdated
or added to match the most common scenarios\\r\\n- [ ]
[Flaky\nTest\\r\\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)\nwas\\r\\nused
on any tests changed\\r\\n\\r\\n\\r\\n\\r\\n###
For\nmaintainers\\r\\n\\r\\n- [ ] This was checked for breaking API
changes
and\nwas\n[labeled\\r\\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\\r\\n-\n[
] This will appear in the **Release Notes** and
follow\nthe\\r\\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\",\"sha\":\"771c139269ac0eac27274e0858be2fbcf87b31e3\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[\"8.x\"],\"targetPullRequestStates\":[{\"branch\":\"main\",\"label\":\"v9.0.0\",\"labelRegex\":\"^v9.0.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/199734\",\"number\":199734,\"mergeCommit\":{\"message\":\"[Entity\nAnalytics]
API changes for right placement of deleting the old component\ntemplate
(#199734)\\n\\n## Summary\\r\\n\\r\\n- Delete the old
component\ntemplate after the index template has\\r\\nreferenced to the
new component\ntemplate\\r\\n- Test cases for the same
flow\\r\\n\\r\\n\\r\\n```JSON\\r\\n# Let's\nassume this is 8.15.3\\r\\n#
Create the component template when Risk Score\nengine is
initialised\\r\\n# Create the index template which references\nthe
created component
template\\r\\n\\r\\nPUT\n/_component_template/.risk-score-mappings\\r\\n{\\r\\n
\\\"template\\\": {\\r\\n\n\\\"settings\\\": {\\r\\n
\\\"number_of_shards\\\": 1\\r\\n },\\r\\n \\\"mappings\\\":\n{\\r\\n
\\\"properties\\\": {\\r\\n \\\"timestamp\\\": {\\r\\n \\\"type\\\":
\\\"date\\\"\\r\\n\n},\\r\\n \\\"user\\\": {\\r\\n \\\"properties\\\":
{\\r\\n \\\"id\\\": {\\r\\n \\\"type\\\":\n\\\"keyword\\\"\\r\\n
},\\r\\n \\\"name\\\": {\\r\\n \\\"type\\\": \\\"text\\\"\\r\\n
}\\r\\n\n}\\r\\n }\\r\\n }\\r\\n }\\r\\n },\\r\\n \\\"version\\\":
1\\r\\n}\\r\\n\\r\\nPUT\n/_index_template/.risk-score.risk-score-default-index-template\\r\\n{\\r\\n\n\\\"index_patterns\\\":\n[\\\".risk-score.risk-score-default-index-template\\\"],\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_replicas\\\": 1\\r\\n }\\r\\n
},\\r\\n\n\\\"composed_of\\\": [\\\".risk-score-mappings\\\"],\\r\\n
\\\"priority\\\": 100,\\r\\n\n\\\"version\\\": 1,\\r\\n \\\"_meta\\\":
{\\r\\n \\\"description\\\": \\\"Index template\nfor indices with the
pattern my_index-*\\\"\\r\\n }\\r\\n}\\r\\n\\r\\n# The\ndeployment is
updated to 8.16\\r\\n# User tries to enable the Entity store\nwhich
init's the Risk Score engine (again!!) \\r\\n# Fails, but creates\nthe
component template and cannot update the index template to
reference\nthe new component template due to the
error\\r\\n\\r\\nPUT\n/_component_template/.risk-score-mappings-default\\r\\n{\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_shards\\\": 1\\r\\n },\\r\\n\n\\\"mappings\\\": {\\r\\n
\\\"properties\\\": {\\r\\n \\\"timestamp\\\": {\\r\\n
\\\"type\\\":\n\\\"date\\\"\\r\\n },\\r\\n \\\"user\\\": {\\r\\n
\\\"properties\\\": {\\r\\n \\\"id\\\": {\\r\\n\n\\\"type\\\":
\\\"keyword\\\"\\r\\n },\\r\\n \\\"name\\\": {\\r\\n \\\"type\\\":
\\\"text\\\"\\r\\n\n}\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n },\\r\\n
\\\"version\\\":
1\\r\\n}\\r\\n\\r\\nGET\n/_component_template?filter_path=component_templates.name&name=.risk-score-mappings*\\r\\n\\r\\n\\r\\nDELETE\n/_component_template/.risk-score-mappings\\r\\n\\r\\n#
Fails \\r\\n\\r\\n#\nchanged
flow\\r\\nPUT\n/_index_template/.risk-score.risk-score-default-index-template\\r\\n{\\r\\n\n\\\"index_patterns\\\":\n[\\\".risk-score.risk-score-default-index-template\\\"],\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_replicas\\\": 1\\r\\n }\\r\\n
},\\r\\n\n\\\"composed_of\\\":
[\\\".risk-score-mappings-default\\\"],\\r\\n
\\\"priority\\\":\n100,\\r\\n \\\"version\\\": 1,\\r\\n \\\"_meta\\\":
{\\r\\n \\\"description\\\": \\\"Index\ntemplate for indices with the
pattern my_index-*\\\"\\r\\n\n}\\r\\n}\\r\\n\\r\\nDELETE
/_component_template/.risk-score-mappings\\r\\n\\r\\n#\nSucceeds\\r\\n\\r\\n#########\\r\\n```\\r\\n\\r\\n\\r\\n###
Checklist\\r\\n\\r\\nDelete\nany items that are not applicable to this
PR.\\r\\n\\r\\n- [ ] [Unit
or\nfunctional\\r\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\r\\nwere\nupdated
or added to match the most common scenarios\\r\\n- [ ]
[Flaky\nTest\\r\\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)\nwas\\r\\nused
on any tests changed\\r\\n\\r\\n\\r\\n\\r\\n###
For\nmaintainers\\r\\n\\r\\n- [ ] This was checked for breaking API
changes
and\nwas\n[labeled\\r\\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\\r\\n-\n[
] This will appear in the **Release Notes** and
follow\nthe\\r\\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\",\"sha\":\"771c139269ac0eac27274e0858be2fbcf87b31e3\"}},{\"branch\":\"8.x\",\"label\":\"v8.17.0\",\"labelRegex\":\"^v8.17.0$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"},{\"branch\":\"8.16\",\"label\":\"v8.16.1\",\"labelRegex\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"url\":\"https://github.com/elastic/kibana/pull/200591\",\"number\":200591,\"state\":\"MERGED\",\"mergeCommit\":{\"sha\":\"06999139d210464c236a3784c58b7e5dcbd64ce3\",\"message\":\"[8.16]\n[Entity
Analytics] API changes for right placement of deleting the
old\ncomponent template (#199734) (#200591)\\n\\n# Backport\\n\\nThis
will\nbackport the following commits from `main` to `8.16`:\\n-
[[Entity\nAnalytics] API changes for right placement of deleting
the\\nold\ncomponent\ntemplate\\n(#199734)](https://github.com/elastic/kibana/pull/199734)\\n\\n<!---\nBackport
version: 8.9.8 -->\\n\\n### Questions ?\\nPlease refer to
the\n[Backport\ntool\\ndocumentation](https://github.com/sqren/backport)\\n\\n<!--BACKPORT\n[{\\\"author\\\":{\\\"name\\\":\\\"Abhishek\\nBhatia\\\",\\\"email\\\":\\\"117628830+abhishekbhatia1710@users.noreply.github.com\\\"},\\\"sourceCommit\\\":{\\\"committedDate\\\":\\\"2024-11-18T15:07:13Z\\\",\\\"message\\\":\\\"[Entity\\nAnalytics]\nAPI
changes for right placement of deleting the old
component\\ntemplate\n(#199734)\\\\n\\\\n## Summary\\\\r\\\\n\\\\r\\\\n-
Delete the old\ncomponent\\ntemplate after the index template
has\\\\r\\\\nreferenced to the\nnew component\\ntemplate\\\\r\\\\n- Test
cases for the same\nflow\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n```JSON\\\\r\\\\n#
Let's\\nassume this is 8.15.3\\\\r\\\\n#\nCreate the component template
when Risk Score\\nengine is\ninitialised\\\\r\\\\n# Create the index
template which references\\nthe\ncreated
component\ntemplate\\\\r\\\\n\\\\r\\\\nPUT\\n/_component_template/.risk-score-mappings\\\\r\\\\n{\\\\r\\\\n\n\\\\\\\"template\\\\\\\":
{\\\\r\\\\n\\n\\\\\\\"settings\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"number_of_shards\\\\\\\": 1\\\\r\\\\n },\\\\r\\\\n
\\\\\\\"mappings\\\\\\\":\\n{\\\\r\\\\n\n\\\\\\\"properties\\\\\\\":
{\\\\r\\\\n \\\\\\\"timestamp\\\\\\\": {\\\\r\\\\n
\\\\\\\"type\\\\\\\":\n\\\\\\\"date\\\\\\\"\\\\r\\\\n\\n},\\\\r\\\\n
\\\\\\\"user\\\\\\\": {\\\\r\\\\n
\\\\\\\"properties\\\\\\\":\n{\\\\r\\\\n \\\\\\\"id\\\\\\\": {\\\\r\\\\n
\\\\\\\"type\\\\\\\":\\n\\\\\\\"keyword\\\\\\\"\\\\r\\\\n\n},\\\\r\\\\n
\\\\\\\"name\\\\\\\": {\\\\r\\\\n \\\\\\\"type\\\\\\\":
\\\\\\\"text\\\\\\\"\\\\r\\\\n\n}\\\\r\\\\n\\n}\\\\r\\\\n }\\\\r\\\\n
}\\\\r\\\\n }\\\\r\\\\n },\\\\r\\\\n
\\\\\\\"version\\\\\\\":\n1\\\\r\\\\n}\\\\r\\\\n\\\\r\\\\nPUT\\n/_index_template/.risk-score.risk-score-default-index-template\\\\r\\\\n{\\\\r\\\\n\\n\\\\\\\"index_patterns\\\\\\\":\\n[\\\\\\\".risk-score.risk-score-default-index-template\\\\\\\"],\\\\r\\\\n\n\\\\\\\"template\\\\\\\":\\n{\\\\r\\\\n
\\\\\\\"settings\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"number_of_replicas\\\\\\\": 1\\\\r\\\\n
}\\\\r\\\\n\n},\\\\r\\\\n\\n\\\\\\\"composed_of\\\\\\\":
[\\\\\\\".risk-score-mappings\\\\\\\"],\\\\r\\\\n\n\\\\\\\"priority\\\\\\\":
100,\\\\r\\\\n\\n\\\\\\\"version\\\\\\\": 1,\\\\r\\\\n
\\\\\\\"_meta\\\\\\\":\n{\\\\r\\\\n \\\\\\\"description\\\\\\\":
\\\\\\\"Index template\\nfor indices with the\npattern
my_index-*\\\\\\\"\\\\r\\\\n }\\\\r\\\\n}\\\\r\\\\n\\\\r\\\\n#
The\\ndeployment is\nupdated to 8.16\\\\r\\\\n# User tries to enable the
Entity store\\nwhich\ninit's the Risk Score engine (again!!) \\\\r\\\\n#
Fails, but creates\\nthe\ncomponent template and cannot update the index
template to\nreference\\nthe new component template due to
the\nerror\\\\r\\\\n\\\\r\\\\nPUT\\n/_component_template/.risk-score-mappings-default\\\\r\\\\n{\\\\r\\\\n\n\\\\\\\"template\\\\\\\":\\n{\\\\r\\\\n
\\\\\\\"settings\\\\\\\": {\\\\r\\\\n\n\\\\\\\"number_of_shards\\\\\\\":
1\\\\r\\\\n },\\\\r\\\\n\\n\\\\\\\"mappings\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"properties\\\\\\\": {\\\\r\\\\n
\\\\\\\"timestamp\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"type\\\\\\\":\\n\\\\\\\"date\\\\\\\"\\\\r\\\\n
},\\\\r\\\\n \\\\\\\"user\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"properties\\\\\\\": {\\\\r\\\\n \\\\\\\"id\\\\\\\":
{\\\\r\\\\n\\n\\\\\\\"type\\\\\\\":\n\\\\\\\"keyword\\\\\\\"\\\\r\\\\n
},\\\\r\\\\n \\\\\\\"name\\\\\\\": {\\\\r\\\\n
\\\\\\\"type\\\\\\\":\n\\\\\\\"text\\\\\\\"\\\\r\\\\n\\n}\\\\r\\\\n
}\\\\r\\\\n }\\\\r\\\\n }\\\\r\\\\n }\\\\r\\\\n
},\\\\r\\\\n\n\\\\\\\"version\\\\\\\":\n1\\\\r\\\\n}\\\\r\\\\n\\\\r\\\\nGET\\n/_component_template?filter_path=component_templates.name&name=.risk-score-mappings*\\\\r\\\\n\\\\r\\\\n\\\\r\\\\nDELETE\\n/_component_template/.risk-score-mappings\\\\r\\\\n\\\\r\\\\n#\nFails
\\\\r\\\\n\\\\r\\\\n#\\nchanged\nflow\\\\r\\\\nPUT\\n/_index_template/.risk-score.risk-score-default-index-template\\\\r\\\\n{\\\\r\\\\n\\n\\\\\\\"index_patterns\\\\\\\":\\n[\\\\\\\".risk-score.risk-score-default-index-template\\\\\\\"],\\\\r\\\\n\n\\\\\\\"template\\\\\\\":\\n{\\\\r\\\\n
\\\\\\\"settings\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"number_of_replicas\\\\\\\": 1\\\\r\\\\n
}\\\\r\\\\n\n},\\\\r\\\\n\\n\\\\\\\"composed_of\\\\\\\":\n[\\\\\\\".risk-score-mappings-default\\\\\\\"],\\\\r\\\\n\n\\\\\\\"priority\\\\\\\":\\n100,\\\\r\\\\n
\\\\\\\"version\\\\\\\": 1,\\\\r\\\\n
\\\\\\\"_meta\\\\\\\":\n{\\\\r\\\\n \\\\\\\"description\\\\\\\":
\\\\\\\"Index\\ntemplate for indices with the\npattern
my_index-*\\\\\\\"\\\\r\\\\n\\n}\\\\r\\\\n}\\\\r\\\\n\\\\r\\\\nDELETE\n/_component_template/.risk-score-mappings\\\\r\\\\n\\\\r\\\\n#\\nSucceeds\\\\r\\\\n\\\\r\\\\n#########\\\\r\\\\n```\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n###\nChecklist\\\\r\\\\n\\\\r\\\\nDelete\\nany
items that are not applicable to this\nPR.\\\\r\\\\n\\\\r\\\\n- [ ]
[Unit\nor\\nfunctional\\\\r\\\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\\\r\\\\nwere\\nupdated\nor
added to match the most common scenarios\\\\r\\\\n- [
]\n[Flaky\\nTest\\\\r\\\\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)\\nwas\\\\r\\\\nused\non
any tests
changed\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n###\nFor\\nmaintainers\\\\r\\\\n\\\\r\\\\n-
[ ] This was checked for breaking
API\nchanges\nand\\nwas\\n[labeled\\\\r\\\\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\\\\r\\\\n-\\n[\n]
This will appear in the **Release Notes**
and\nfollow\\nthe\\\\r\\\\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\\\",\\\"sha\\\":\\\"771c139269ac0eac27274e0858be2fbcf87b31e3\\\",\\\"branchLabelMapping\\\":{\\\"^v9.0.0$\\\":\\\"main\\\",\\\"^v8.17.0$\\\":\\\"8.x\\\",\\\"^v(\\\\\\\\d+).(\\\\\\\\d+).\\\\\\\\d+$\\\":\\\"$1.$2\\\"}},\\\"sourcePullRequest\\\":{\\\"labels\\\":[\\\"bug\\\",\\\"release_note:fix\\\",\\\"v9.0.0\\\",\\\"Team:Entity\\nAnalytics\\\",\\\"backport:version\\\",\\\"v8.17.0\\\",\\\"v8.16.1\\\"],\\\"number\\\":199734,\\\"url\\\":\\\"https://github.com/elastic/kibana/pull/199734\\\",\\\"mergeCommit\\\":{\\\"message\\\":\\\"[Entity\\nAnalytics]\nAPI
changes for right placement of deleting the old
component\\ntemplate\n(#199734)\\\\n\\\\n## Summary\\\\r\\\\n\\\\r\\\\n-
Delete the old\ncomponent\\ntemplate after the index template
has\\\\r\\\\nreferenced to the\nnew component\\ntemplate\\\\r\\\\n- Test
cases for the same\nflow\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n```JSON\\\\r\\\\n#
Let's\\nassume this is 8.15.3\\\\r\\\\n#\nCreate the component template
when Risk Score\\nengine is\ninitialised\\\\r\\\\n# Create the index
template which references\\nthe\ncreated
component\ntemplate\\\\r\\\\n\\\\r\\\\nPUT\\n/_component_template/.risk-score-mappings\\\\r\\\\n{\\\\r\\\\n\n\\\\\\\"template\\\\\\\":
{\\\\r\\\\n\\n\\\\\\\"settings\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"number_of_shards\\\\\\\": 1\\\\r\\\\n },\\\\r\\\\n
\\\\\\\"mappings\\\\\\\":\\n{\\\\r\\\\n\n\\\\\\\"properties\\\\\\\":
{\\\\r\\\\n \\\\\\\"timestamp\\\\\\\": {\\\\r\\\\n
\\\\\\\"type\\\\\\\":\n\\\\\\\"date\\\\\\\"\\\\r\\\\n\\n},\\\\r\\\\n
\\\\\\\"user\\\\\\\": {\\\\r\\\\n
\\\\\\\"properties\\\\\\\":\n{\\\\r\\\\n \\\\\\\"id\\\\\\\": {\\\\r\\\\n
\\\\\\\"type\\\\\\\":\\n\\\\\\\"keyword\\\\\\\"\\\\r\\\\n\n},\\\\r\\\\n
\\\\\\\"name\\\\\\\": {\\\\r\\\\n \\\\\\\"type\\\\\\\":
\\\\\\\"text\\\\\\\"\\\\r\\\\n\n}\\\\r\\\\n\\n}\\\\r\\\\n }\\\\r\\\\n
}\\\\r\\\\n }\\\\r\\\\n },\\\\r\\\\n
\\\\\\\"version\\\\\\\":\n1\\\\r\\\\n}\\\\r\\\\n\\\\r\\\\nPUT\\n/_index_template/.risk-score.risk-score-default-index-template\\\\r\\\\n{\\\\r\\\\n\\n\\\\\\\"index_patterns\\\\\\\":\\n[\\\\\\\".risk-score.risk-score-default-index-template\\\\\\\"],\\\\r\\\\n\n\\\\\\\"template\\\\\\\":\\n{\\\\r\\\\n
\\\\\\\"settings\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"number_of_replicas\\\\\\\": 1\\\\r\\\\n
}\\\\r\\\\n\n},\\\\r\\\\n\\n\\\\\\\"composed_of\\\\\\\":
[\\\\\\\".risk-score-mappings\\\\\\\"],\\\\r\\\\n\n\\\\\\\"priority\\\\\\\":
100,\\\\r\\\\n\\n\\\\\\\"version\\\\\\\": 1,\\\\r\\\\n
\\\\\\\"_meta\\\\\\\":\n{\\\\r\\\\n \\\\\\\"description\\\\\\\":
\\\\\\\"Index template\\nfor indices with the\npattern
my_index-*\\\\\\\"\\\\r\\\\n }\\\\r\\\\n}\\\\r\\\\n\\\\r\\\\n#
The\\ndeployment is\nupdated to 8.16\\\\r\\\\n# User tries to enable the
Entity store\\nwhich\ninit's the Risk Score engine (again!!) \\\\r\\\\n#
Fails, but creates\\nthe\ncomponent template and cannot update the index
template to\nreference\\nthe new component template due to
the\nerror\\\\r\\\\n\\\\r\\\\nPUT\\n/_component_template/.risk-score-mappings-default\\\\r\\\\n{\\\\r\\\\n\n\\\\\\\"template\\\\\\\":\\n{\\\\r\\\\n
\\\\\\\"settings\\\\\\\": {\\\\r\\\\n\n\\\\\\\"number_of_shards\\\\\\\":
1\\\\r\\\\n },\\\\r\\\\n\\n\\\\\\\"mappings\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"properties\\\\\\\": {\\\\r\\\\n
\\\\\\\"timestamp\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"type\\\\\\\":\\n\\\\\\\"date\\\\\\\"\\\\r\\\\n
},\\\\r\\\\n \\\\\\\"user\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"properties\\\\\\\": {\\\\r\\\\n \\\\\\\"id\\\\\\\":
{\\\\r\\\\n\\n\\\\\\\"type\\\\\\\":\n\\\\\\\"keyword\\\\\\\"\\\\r\\\\n
},\\\\r\\\\n \\\\\\\"name\\\\\\\": {\\\\r\\\\n
\\\\\\\"type\\\\\\\":\n\\\\\\\"text\\\\\\\"\\\\r\\\\n\\n}\\\\r\\\\n
}\\\\r\\\\n }\\\\r\\\\n }\\\\r\\\\n }\\\\r\\\\n
},\\\\r\\\\n\n\\\\\\\"version\\\\\\\":\n1\\\\r\\\\n}\\\\r\\\\n\\\\r\\\\nGET\\n/_component_template?filter_path=component_templates.name&name=.risk-score-mappings*\\\\r\\\\n\\\\r\\\\n\\\\r\\\\nDELETE\\n/_component_template/.risk-score-mappings\\\\r\\\\n\\\\r\\\\n#\nFails
\\\\r\\\\n\\\\r\\\\n#\\nchanged\nflow\\\\r\\\\nPUT\\n/_index_template/.risk-score.risk-score-default-index-template\\\\r\\\\n{\\\\r\\\\n\\n\\\\\\\"index_patterns\\\\\\\":\\n[\\\\\\\".risk-score.risk-score-default-index-template\\\\\\\"],\\\\r\\\\n\n\\\\\\\"template\\\\\\\":\\n{\\\\r\\\\n
\\\\\\\"settings\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"number_of_replicas\\\\\\\": 1\\\\r\\\\n
}\\\\r\\\\n\n},\\\\r\\\\n\\n\\\\\\\"composed_of\\\\\\\":\n[\\\\\\\".risk-score-mappings-default\\\\\\\"],\\\\r\\\\n\n\\\\\\\"priority\\\\\\\":\\n100,\\\\r\\\\n
\\\\\\\"version\\\\\\\": 1,\\\\r\\\\n
\\\\\\\"_meta\\\\\\\":\n{\\\\r\\\\n \\\\\\\"description\\\\\\\":
\\\\\\\"Index\\ntemplate for indices with the\npattern
my_index-*\\\\\\\"\\\\r\\\\n\\n}\\\\r\\\\n}\\\\r\\\\n\\\\r\\\\nDELETE\n/_component_template/.risk-score-mappings\\\\r\\\\n\\\\r\\\\n#\\nSucceeds\\\\r\\\\n\\\\r\\\\n#########\\\\r\\\\n```\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n###\nChecklist\\\\r\\\\n\\\\r\\\\nDelete\\nany
items that are not applicable to this\nPR.\\\\r\\\\n\\\\r\\\\n- [ ]
[Unit\nor\\nfunctional\\\\r\\\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\\\r\\\\nwere\\nupdated\nor
added to match the most common scenarios\\\\r\\\\n- [
]\n[Flaky\\nTest\\\\r\\\\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)\\nwas\\\\r\\\\nused\non
any tests
changed\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n###\nFor\\nmaintainers\\\\r\\\\n\\\\r\\\\n-
[ ] This was checked for breaking
API\nchanges\nand\\nwas\\n[labeled\\\\r\\\\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\\\\r\\\\n-\\n[\n]
This will appear in the **Release Notes**
and\nfollow\\nthe\\\\r\\\\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\\\",\\\"sha\\\":\\\"771c139269ac0eac27274e0858be2fbcf87b31e3\\\"}},\\\"sourceBranch\\\":\\\"main\\\",\\\"suggestedTargetBranches\\\":[\\\"8.x\\\",\\\"8.16\\\"],\\\"targetPullRequestStates\\\":[{\\\"branch\\\":\\\"main\\\",\\\"label\\\":\\\"v9.0.0\\\",\\\"labelRegex\\\":\\\"^v9.0.0$\\\",\\\"isSourceBranch\\\":true,\\\"state\\\":\\\"MERGED\\\",\\\"url\\\":\\\"https://github.com/elastic/kibana/pull/199734\\\",\\\"number\\\":199734,\\\"mergeCommit\\\":{\\\"message\\\":\\\"[Entity\\nAnalytics]\nAPI
changes for right placement of deleting the old
component\\ntemplate\n(#199734)\\\\n\\\\n## Summary\\\\r\\\\n\\\\r\\\\n-
Delete the old\ncomponent\\ntemplate after the index template
has\\\\r\\\\nreferenced to the\nnew component\\ntemplate\\\\r\\\\n- Test
cases for the same\nflow\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n```JSON\\\\r\\\\n#
Let's\\nassume this is 8.15.3\\\\r\\\\n#\nCreate the component template
when Risk Score\\nengine is\ninitialised\\\\r\\\\n# Create the index
template which references\\nthe\ncreated
component\ntemplate\\\\r\\\\n\\\\r\\\\nPUT\\n/_component_template/.risk-score-mappings\\\\r\\\\n{\\\\r\\\\n\n\\\\\\\"template\\\\\\\":
{\\\\r\\\\n\\n\\\\\\\"settings\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"number_of_shards\\\\\\\": 1\\\\r\\\\n },\\\\r\\\\n
\\\\\\\"mappings\\\\\\\":\\n{\\\\r\\\\n\n\\\\\\\"properties\\\\\\\":
{\\\\r\\\\n \\\\\\\"timestamp\\\\\\\": {\\\\r\\\\n
\\\\\\\"type\\\\\\\":\n\\\\\\\"date\\\\\\\"\\\\r\\\\n\\n},\\\\r\\\\n
\\\\\\\"user\\\\\\\": {\\\\r\\\\n
\\\\\\\"properties\\\\\\\":\n{\\\\r\\\\n \\\\\\\"id\\\\\\\": {\\\\r\\\\n
\\\\\\\"type\\\\\\\":\\n\\\\\\\"keyword\\\\\\\"\\\\r\\\\n\n},\\\\r\\\\n
\\\\\\\"name\\\\\\\": {\\\\r\\\\n \\\\\\\"type\\\\\\\":
\\\\\\\"text\\\\\\\"\\\\r\\\\n\n}\\\\r\\\\n\\n}\\\\r\\\\n }\\\\r\\\\n
}\\\\r\\\\n }\\\\r\\\\n },\\\\r\\\\n
\\\\\\\"version\\\\\\\":\n1\\\\r\\\\n}\\\\r\\\\n\\\\r\\\\nPUT\\n/_index_template/.risk-score.risk-score-default-index-template\\\\r\\\\n{\\\\r\\\\n\\n\\\\\\\"index_patterns\\\\\\\":\\n[\\\\\\\".risk-score.risk-score-default-index-template\\\\\\\"],\\\\r\\\\n\n\\\\\\\"template\\\\\\\":\\n{\\\\r\\\\n
\\\\\\\"settings\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"number_of_replicas\\\\\\\": 1\\\\r\\\\n
}\\\\r\\\\n\n},\\\\r\\\\n\\n\\\\\\\"composed_of\\\\\\\":
[\\\\\\\".risk-score-mappings\\\\\\\"],\\\\r\\\\n\n\\\\\\\"priority\\\\\\\":
100,\\\\r\\\\n\\n\\\\\\\"version\\\\\\\": 1,\\\\r\\\\n
\\\\\\\"_meta\\\\\\\":\n{\\\\r\\\\n \\\\\\\"description\\\\\\\":
\\\\\\\"Index template\\nfor indices with the\npattern
my_index-*\\\\\\\"\\\\r\\\\n }\\\\r\\\\n}\\\\r\\\\n\\\\r\\\\n#
The\\ndeployment is\nupdated to 8.16\\\\r\\\\n# User tries to enable the
Entity store\\nwhich\ninit's the Risk Score engine (again!!) \\\\r\\\\n#
Fails, but creates\\nthe\ncomponent template and cannot update the index
template to\nreference\\nthe new component template due to
the\nerror\\\\r\\\\n\\\\r\\\\nPUT\\n/_component_template/.risk-score-mappings-default\\\\r\\\\n{\\\\r\\\\n\n\\\\\\\"template\\\\\\\":\\n{\\\\r\\\\n
\\\\\\\"settings\\\\\\\": {\\\\r\\\\n\n\\\\\\\"number_of_shards\\\\\\\":
1\\\\r\\\\n },\\\\r\\\\n\\n\\\\\\\"mappings\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"properties\\\\\\\": {\\\\r\\\\n
\\\\\\\"timestamp\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"type\\\\\\\":\\n\\\\\\\"date\\\\\\\"\\\\r\\\\n
},\\\\r\\\\n \\\\\\\"user\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"properties\\\\\\\": {\\\\r\\\\n \\\\\\\"id\\\\\\\":
{\\\\r\\\\n\\n\\\\\\\"type\\\\\\\":\n\\\\\\\"keyword\\\\\\\"\\\\r\\\\n
},\\\\r\\\\n \\\\\\\"name\\\\\\\": {\\\\r\\\\n
\\\\\\\"type\\\\\\\":\n\\\\\\\"text\\\\\\\"\\\\r\\\\n\\n}\\\\r\\\\n
}\\\\r\\\\n }\\\\r\\\\n }\\\\r\\\\n }\\\\r\\\\n
},\\\\r\\\\n\n\\\\\\\"version\\\\\\\":\n1\\\\r\\\\n}\\\\r\\\\n\\\\r\\\\nGET\\n/_component_template?filter_path=component_templates.name&name=.risk-score-mappings*\\\\r\\\\n\\\\r\\\\n\\\\r\\\\nDELETE\\n/_component_template/.risk-score-mappings\\\\r\\\\n\\\\r\\\\n#\nFails
\\\\r\\\\n\\\\r\\\\n#\\nchanged\nflow\\\\r\\\\nPUT\\n/_index_template/.risk-score.risk-score-default-index-template\\\\r\\\\n{\\\\r\\\\n\\n\\\\\\\"index_patterns\\\\\\\":\\n[\\\\\\\".risk-score.risk-score-default-index-template\\\\\\\"],\\\\r\\\\n\n\\\\\\\"template\\\\\\\":\\n{\\\\r\\\\n
\\\\\\\"settings\\\\\\\":
{\\\\r\\\\n\n\\\\\\\"number_of_replicas\\\\\\\": 1\\\\r\\\\n
}\\\\r\\\\n\n},\\\\r\\\\n\\n\\\\\\\"composed_of\\\\\\\":\n[\\\\\\\".risk-score-mappings-default\\\\\\\"],\\\\r\\\\n\n\\\\\\\"priority\\\\\\\":\\n100,\\\\r\\\\n
\\\\\\\"version\\\\\\\": 1,\\\\r\\\\n
\\\\\\\"_meta\\\\\\\":\n{\\\\r\\\\n \\\\\\\"description\\\\\\\":
\\\\\\\"Index\\ntemplate for indices with the\npattern
my_index-*\\\\\\\"\\\\r\\\\n\\n}\\\\r\\\\n}\\\\r\\\\n\\\\r\\\\nDELETE\n/_component_template/.risk-score-mappings\\\\r\\\\n\\\\r\\\\n#\\nSucceeds\\\\r\\\\n\\\\r\\\\n#########\\\\r\\\\n```\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n###\nChecklist\\\\r\\\\n\\\\r\\\\nDelete\\nany
items that are not applicable to this\nPR.\\\\r\\\\n\\\\r\\\\n- [ ]
[Unit\nor\\nfunctional\\\\r\\\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\\\r\\\\nwere\\nupdated\nor
added to match the most common scenarios\\\\r\\\\n- [
]\n[Flaky\\nTest\\\\r\\\\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)\\nwas\\\\r\\\\nused\non
any tests
changed\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n\\\\r\\\\n###\nFor\\nmaintainers\\\\r\\\\n\\\\r\\\\n-
[ ] This was checked for breaking
API\nchanges\nand\\nwas\\n[labeled\\\\r\\\\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\\\\r\\\\n-\\n[\n]
This will appear in the **Release Notes**
and\nfollow\\nthe\\\\r\\\\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\\\",\\\"sha\\\":\\\"771c139269ac0eac27274e0858be2fbcf87b31e3\\\"}},{\\\"branch\\\":\\\"8.x\\\",\\\"label\\\":\\\"v8.17.0\\\",\\\"labelRegex\\\":\\\"^v8.17.0$\\\",\\\"isSourceBranch\\\":false,\\\"state\\\":\\\"NOT_CREATED\\\"},{\\\"branch\\\":\\\"8.16\\\",\\\"label\\\":\\\"v8.16.1\\\",\\\"labelRegex\\\":\\\"^v(\\\\\\\\d+).(\\\\\\\\d+).\\\\\\\\d+$\\\",\\\"isSourceBranch\\\":false,\\\"state\\\":\\\"NOT_CREATED\\\"}]}]\\nBACKPORT-->\"}}]}]\nBACKPORT-->\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>"}},{"branch":"8.16","label":"v8.16.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/200591","number":200591,"state":"MERGED","mergeCommit":{"sha":"06999139d210464c236a3784c58b7e5dcbd64ce3","message":"[8.16]
[Entity Analytics] API changes for right placement of deleting the old
component template (#199734) (#200591)\n\n# Backport\n\nThis will
backport the following commits from `main` to `8.16`:\n- [[Entity
Analytics] API changes for right placement of deleting the\nold
component
template\n(#199734)](https://github.com/elastic/kibana/pull/199734)\n\n<!---
Backport version: 8.9.8 -->\n\n### Questions ?\nPlease refer to the
[Backport
tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT
[{\"author\":{\"name\":\"Abhishek\nBhatia\",\"email\":\"117628830+abhishekbhatia1710@users.noreply.github.com\"},\"sourceCommit\":{\"committedDate\":\"2024-11-18T15:07:13Z\",\"message\":\"[Entity\nAnalytics]
API changes for right placement of deleting the old component\ntemplate
(#199734)\\n\\n## Summary\\r\\n\\r\\n- Delete the old
component\ntemplate after the index template has\\r\\nreferenced to the
new component\ntemplate\\r\\n- Test cases for the same
flow\\r\\n\\r\\n\\r\\n```JSON\\r\\n# Let's\nassume this is 8.15.3\\r\\n#
Create the component template when Risk Score\nengine is
initialised\\r\\n# Create the index template which references\nthe
created component
template\\r\\n\\r\\nPUT\n/_component_template/.risk-score-mappings\\r\\n{\\r\\n
\\\"template\\\": {\\r\\n\n\\\"settings\\\": {\\r\\n
\\\"number_of_shards\\\": 1\\r\\n },\\r\\n \\\"mappings\\\":\n{\\r\\n
\\\"properties\\\": {\\r\\n \\\"timestamp\\\": {\\r\\n \\\"type\\\":
\\\"date\\\"\\r\\n\n},\\r\\n \\\"user\\\": {\\r\\n \\\"properties\\\":
{\\r\\n \\\"id\\\": {\\r\\n \\\"type\\\":\n\\\"keyword\\\"\\r\\n
},\\r\\n \\\"name\\\": {\\r\\n \\\"type\\\": \\\"text\\\"\\r\\n
}\\r\\n\n}\\r\\n }\\r\\n }\\r\\n }\\r\\n },\\r\\n \\\"version\\\":
1\\r\\n}\\r\\n\\r\\nPUT\n/_index_template/.risk-score.risk-score-default-index-template\\r\\n{\\r\\n\n\\\"index_patterns\\\":\n[\\\".risk-score.risk-score-default-index-template\\\"],\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_replicas\\\": 1\\r\\n }\\r\\n
},\\r\\n\n\\\"composed_of\\\": [\\\".risk-score-mappings\\\"],\\r\\n
\\\"priority\\\": 100,\\r\\n\n\\\"version\\\": 1,\\r\\n \\\"_meta\\\":
{\\r\\n \\\"description\\\": \\\"Index template\nfor indices with the
pattern my_index-*\\\"\\r\\n }\\r\\n}\\r\\n\\r\\n# The\ndeployment is
updated to 8.16\\r\\n# User tries to enable the Entity store\nwhich
init's the Risk Score engine (again!!) \\r\\n# Fails, but creates\nthe
component template and cannot update the index template to
reference\nthe new component template due to the
error\\r\\n\\r\\nPUT\n/_component_template/.risk-score-mappings-default\\r\\n{\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_shards\\\": 1\\r\\n },\\r\\n\n\\\"mappings\\\": {\\r\\n
\\\"properties\\\": {\\r\\n \\\"timestamp\\\": {\\r\\n
\\\"type\\\":\n\\\"date\\\"\\r\\n },\\r\\n \\\"user\\\": {\\r\\n
\\\"properties\\\": {\\r\\n \\\"id\\\": {\\r\\n\n\\\"type\\\":
\\\"keyword\\\"\\r\\n },\\r\\n \\\"name\\\": {\\r\\n \\\"type\\\":
\\\"text\\\"\\r\\n\n}\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n },\\r\\n
\\\"version\\\":
1\\r\\n}\\r\\n\\r\\nGET\n/_component_template?filter_path=component_templates.name&name=.risk-score-mappings*\\r\\n\\r\\n\\r\\nDELETE\n/_component_template/.risk-score-mappings\\r\\n\\r\\n#
Fails \\r\\n\\r\\n#\nchanged
flow\\r\\nPUT\n/_index_template/.risk-score.risk-score-default-index-template\\r\\n{\\r\\n\n\\\"index_patterns\\\":\n[\\\".risk-score.risk-score-default-index-template\\\"],\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_replicas\\\": 1\\r\\n }\\r\\n
},\\r\\n\n\\\"composed_of\\\":
[\\\".risk-score-mappings-default\\\"],\\r\\n
\\\"priority\\\":\n100,\\r\\n \\\"version\\\": 1,\\r\\n \\\"_meta\\\":
{\\r\\n \\\"description\\\": \\\"Index\ntemplate for indices with the
pattern my_index-*\\\"\\r\\n\n}\\r\\n}\\r\\n\\r\\nDELETE
/_component_template/.risk-score-mappings\\r\\n\\r\\n#\nSucceeds\\r\\n\\r\\n#########\\r\\n```\\r\\n\\r\\n\\r\\n###
Checklist\\r\\n\\r\\nDelete\nany items that are not applicable to this
PR.\\r\\n\\r\\n- [ ] [Unit
or\nfunctional\\r\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\r\\nwere\nupdated
or added to match the most common scenarios\\r\\n- [ ]
[Flaky\nTest\\r\\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)\nwas\\r\\nused
on any tests changed\\r\\n\\r\\n\\r\\n\\r\\n###
For\nmaintainers\\r\\n\\r\\n- [ ] This was checked for breaking API
changes
and\nwas\n[labeled\\r\\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\\r\\n-\n[
] This will appear in the **Release Notes** and
follow\nthe\\r\\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\",\"sha\":\"771c139269ac0eac27274e0858be2fbcf87b31e3\",\"branchLabelMapping\":{\"^v9.0.0$\":\"main\",\"^v8.17.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"bug\",\"release_note:fix\",\"v9.0.0\",\"Team:Entity\nAnalytics\",\"backport:version\",\"v8.17.0\",\"v8.16.1\"],\"number\":199734,\"url\":\"https://github.com/elastic/kibana/pull/199734\",\"mergeCommit\":{\"message\":\"[Entity\nAnalytics]
API changes for right placement of deleting the old component\ntemplate
(#199734)\\n\\n## Summary\\r\\n\\r\\n- Delete the old
component\ntemplate after the index template has\\r\\nreferenced to the
new component\ntemplate\\r\\n- Test cases for the same
flow\\r\\n\\r\\n\\r\\n```JSON\\r\\n# Let's\nassume this is 8.15.3\\r\\n#
Create the component template when Risk Score\nengine is
initialised\\r\\n# Create the index template which references\nthe
created component
template\\r\\n\\r\\nPUT\n/_component_template/.risk-score-mappings\\r\\n{\\r\\n
\\\"template\\\": {\\r\\n\n\\\"settings\\\": {\\r\\n
\\\"number_of_shards\\\": 1\\r\\n },\\r\\n \\\"mappings\\\":\n{\\r\\n
\\\"properties\\\": {\\r\\n \\\"timestamp\\\": {\\r\\n \\\"type\\\":
\\\"date\\\"\\r\\n\n},\\r\\n \\\"user\\\": {\\r\\n \\\"properties\\\":
{\\r\\n \\\"id\\\": {\\r\\n \\\"type\\\":\n\\\"keyword\\\"\\r\\n
},\\r\\n \\\"name\\\": {\\r\\n \\\"type\\\": \\\"text\\\"\\r\\n
}\\r\\n\n}\\r\\n }\\r\\n }\\r\\n }\\r\\n },\\r\\n \\\"version\\\":
1\\r\\n}\\r\\n\\r\\nPUT\n/_index_template/.risk-score.risk-score-default-index-template\\r\\n{\\r\\n\n\\\"index_patterns\\\":\n[\\\".risk-score.risk-score-default-index-template\\\"],\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_replicas\\\": 1\\r\\n }\\r\\n
},\\r\\n\n\\\"composed_of\\\": [\\\".risk-score-mappings\\\"],\\r\\n
\\\"priority\\\": 100,\\r\\n\n\\\"version\\\": 1,\\r\\n \\\"_meta\\\":
{\\r\\n \\\"description\\\": \\\"Index template\nfor indices with the
pattern my_index-*\\\"\\r\\n }\\r\\n}\\r\\n\\r\\n# The\ndeployment is
updated to 8.16\\r\\n# User tries to enable the Entity store\nwhich
init's the Risk Score engine (again!!) \\r\\n# Fails, but creates\nthe
component template and cannot update the index template to
reference\nthe new component template due to the
error\\r\\n\\r\\nPUT\n/_component_template/.risk-score-mappings-default\\r\\n{\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_shards\\\": 1\\r\\n },\\r\\n\n\\\"mappings\\\": {\\r\\n
\\\"properties\\\": {\\r\\n \\\"timestamp\\\": {\\r\\n
\\\"type\\\":\n\\\"date\\\"\\r\\n },\\r\\n \\\"user\\\": {\\r\\n
\\\"properties\\\": {\\r\\n \\\"id\\\": {\\r\\n\n\\\"type\\\":
\\\"keyword\\\"\\r\\n },\\r\\n \\\"name\\\": {\\r\\n \\\"type\\\":
\\\"text\\\"\\r\\n\n}\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n },\\r\\n
\\\"version\\\":
1\\r\\n}\\r\\n\\r\\nGET\n/_component_template?filter_path=component_templates.name&name=.risk-score-mappings*\\r\\n\\r\\n\\r\\nDELETE\n/_component_template/.risk-score-mappings\\r\\n\\r\\n#
Fails \\r\\n\\r\\n#\nchanged
flow\\r\\nPUT\n/_index_template/.risk-score.risk-score-default-index-template\\r\\n{\\r\\n\n\\\"index_patterns\\\":\n[\\\".risk-score.risk-score-default-index-template\\\"],\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_replicas\\\": 1\\r\\n }\\r\\n
},\\r\\n\n\\\"composed_of\\\":
[\\\".risk-score-mappings-default\\\"],\\r\\n
\\\"priority\\\":\n100,\\r\\n \\\"version\\\": 1,\\r\\n \\\"_meta\\\":
{\\r\\n \\\"description\\\": \\\"Index\ntemplate for indices with the
pattern my_index-*\\\"\\r\\n\n}\\r\\n}\\r\\n\\r\\nDELETE
/_component_template/.risk-score-mappings\\r\\n\\r\\n#\nSucceeds\\r\\n\\r\\n#########\\r\\n```\\r\\n\\r\\n\\r\\n###
Checklist\\r\\n\\r\\nDelete\nany items that are not applicable to this
PR.\\r\\n\\r\\n- [ ] [Unit
or\nfunctional\\r\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\r\\nwere\nupdated
or added to match the most common scenarios\\r\\n- [ ]
[Flaky\nTest\\r\\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)\nwas\\r\\nused
on any tests changed\\r\\n\\r\\n\\r\\n\\r\\n###
For\nmaintainers\\r\\n\\r\\n- [ ] This was checked for breaking API
changes
and\nwas\n[labeled\\r\\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\\r\\n-\n[
] This will appear in the **Release Notes** and
follow\nthe\\r\\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\",\"sha\":\"771c139269ac0eac27274e0858be2fbcf87b31e3\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[\"8.x\",\"8.16\"],\"targetPullRequestStates\":[{\"branch\":\"main\",\"label\":\"v9.0.0\",\"labelRegex\":\"^v9.0.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/199734\",\"number\":199734,\"mergeCommit\":{\"message\":\"[Entity\nAnalytics]
API changes for right placement of deleting the old component\ntemplate
(#199734)\\n\\n## Summary\\r\\n\\r\\n- Delete the old
component\ntemplate after the index template has\\r\\nreferenced to the
new component\ntemplate\\r\\n- Test cases for the same
flow\\r\\n\\r\\n\\r\\n```JSON\\r\\n# Let's\nassume this is 8.15.3\\r\\n#
Create the component template when Risk Score\nengine is
initialised\\r\\n# Create the index template which references\nthe
created component
template\\r\\n\\r\\nPUT\n/_component_template/.risk-score-mappings\\r\\n{\\r\\n
\\\"template\\\": {\\r\\n\n\\\"settings\\\": {\\r\\n
\\\"number_of_shards\\\": 1\\r\\n },\\r\\n \\\"mappings\\\":\n{\\r\\n
\\\"properties\\\": {\\r\\n \\\"timestamp\\\": {\\r\\n \\\"type\\\":
\\\"date\\\"\\r\\n\n},\\r\\n \\\"user\\\": {\\r\\n \\\"properties\\\":
{\\r\\n \\\"id\\\": {\\r\\n \\\"type\\\":\n\\\"keyword\\\"\\r\\n
},\\r\\n \\\"name\\\": {\\r\\n \\\"type\\\": \\\"text\\\"\\r\\n
}\\r\\n\n}\\r\\n }\\r\\n }\\r\\n }\\r\\n },\\r\\n \\\"version\\\":
1\\r\\n}\\r\\n\\r\\nPUT\n/_index_template/.risk-score.risk-score-default-index-template\\r\\n{\\r\\n\n\\\"index_patterns\\\":\n[\\\".risk-score.risk-score-default-index-template\\\"],\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_replicas\\\": 1\\r\\n }\\r\\n
},\\r\\n\n\\\"composed_of\\\": [\\\".risk-score-mappings\\\"],\\r\\n
\\\"priority\\\": 100,\\r\\n\n\\\"version\\\": 1,\\r\\n \\\"_meta\\\":
{\\r\\n \\\"description\\\": \\\"Index template\nfor indices with the
pattern my_index-*\\\"\\r\\n }\\r\\n}\\r\\n\\r\\n# The\ndeployment is
updated to 8.16\\r\\n# User tries to enable the Entity store\nwhich
init's the Risk Score engine (again!!) \\r\\n# Fails, but creates\nthe
component template and cannot update the index template to
reference\nthe new component template due to the
error\\r\\n\\r\\nPUT\n/_component_template/.risk-score-mappings-default\\r\\n{\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_shards\\\": 1\\r\\n },\\r\\n\n\\\"mappings\\\": {\\r\\n
\\\"properties\\\": {\\r\\n \\\"timestamp\\\": {\\r\\n
\\\"type\\\":\n\\\"date\\\"\\r\\n },\\r\\n \\\"user\\\": {\\r\\n
\\\"properties\\\": {\\r\\n \\\"id\\\": {\\r\\n\n\\\"type\\\":
\\\"keyword\\\"\\r\\n },\\r\\n \\\"name\\\": {\\r\\n \\\"type\\\":
\\\"text\\\"\\r\\n\n}\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n },\\r\\n
\\\"version\\\":
1\\r\\n}\\r\\n\\r\\nGET\n/_component_template?filter_path=component_templates.name&name=.risk-score-mappings*\\r\\n\\r\\n\\r\\nDELETE\n/_component_template/.risk-score-mappings\\r\\n\\r\\n#
Fails \\r\\n\\r\\n#\nchanged
flow\\r\\nPUT\n/_index_template/.risk-score.risk-score-default-index-template\\r\\n{\\r\\n\n\\\"index_patterns\\\":\n[\\\".risk-score.risk-score-default-index-template\\\"],\\r\\n
\\\"template\\\":\n{\\r\\n \\\"settings\\\": {\\r\\n
\\\"number_of_replicas\\\": 1\\r\\n }\\r\\n
},\\r\\n\n\\\"composed_of\\\":
[\\\".risk-score-mappings-default\\\"],\\r\\n
\\\"priority\\\":\n100,\\r\\n \\\"version\\\": 1,\\r\\n \\\"_meta\\\":
{\\r\\n \\\"description\\\": \\\"Index\ntemplate for indices with the
pattern my_index-*\\\"\\r\\n\n}\\r\\n}\\r\\n\\r\\nDELETE
/_component_template/.risk-score-mappings\\r\\n\\r\\n#\nSucceeds\\r\\n\\r\\n#########\\r\\n```\\r\\n\\r\\n\\r\\n###
Checklist\\r\\n\\r\\nDelete\nany items that are not applicable to this
PR.\\r\\n\\r\\n- [ ] [Unit
or\nfunctional\\r\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\r\\nwere\nupdated
or added to match the most common scenarios\\r\\n- [ ]
[Flaky\nTest\\r\\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)\nwas\\r\\nused
on any tests changed\\r\\n\\r\\n\\r\\n\\r\\n###
For\nmaintainers\\r\\n\\r\\n- [ ] This was checked for breaking API
changes
and\nwas\n[labeled\\r\\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\\r\\n-\n[
] This will appear in the **Release Notes** and
follow\nthe\\r\\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\",\"sha\":\"771c139269ac0eac27274e0858be2fbcf87b31e3\"}},{\"branch\":\"8.x\",\"label\":\"v8.17.0\",\"labelRegex\":\"^v8.17.0$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"},{\"branch\":\"8.16\",\"label\":\"v8.16.1\",\"labelRegex\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"}]}]\nBACKPORT-->"}},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
This commit is contained in:
Abhishek Bhatia 2025-02-26 17:21:47 +05:30 committed by GitHub
parent 83391ca5d9
commit 01a430a06c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 498 additions and 350 deletions

View file

@ -129,6 +129,9 @@ export const riskScoreFieldMap: FieldMap = {
} as const;
export const mappingComponentName = '.risk-score-mappings';
export const nameSpaceAwareMappingsComponentName = (namespace: string): string => {
return `${mappingComponentName}-${namespace}`;
};
export const totalFieldsLimit = 1000;
export const getIndexPatternDataStream = (namespace: string): IIndexPatternString => ({

View file

@ -40,6 +40,7 @@ jest.spyOn(transforms, 'scheduleTransformNow').mockResolvedValue(Promise.resolve
describe('RiskScoreDataClient', () => {
let riskScoreDataClient: RiskScoreDataClient;
let riskScoreDataClientWithNameSpace: RiskScoreDataClient;
let mockSavedObjectClient: ReturnType<typeof savedObjectsClientMock.create>;
let logger: ReturnType<typeof loggingSystemMock.createLogger>;
const esClient = elasticsearchServiceMock.createScopedClusterClient().asCurrentUser;
@ -56,6 +57,8 @@ describe('RiskScoreDataClient', () => {
namespace: 'default',
};
riskScoreDataClient = new RiskScoreDataClient(options);
const optionsWithNamespace = { ...options, namespace: 'space-1' };
riskScoreDataClientWithNameSpace = new RiskScoreDataClient(optionsWithNamespace);
});
afterEach(() => {
@ -80,369 +83,396 @@ describe('RiskScoreDataClient', () => {
});
describe('init success', () => {
it('should initialize risk engine resources', async () => {
await riskScoreDataClient.init();
it('should initialize risk engine resources in the appropriate space', async () => {
const assertComponentTemplate = (namespace: string) => {
expect(createOrUpdateComponentTemplate).toHaveBeenCalledWith(
expect.objectContaining({
logger,
esClient,
template: expect.objectContaining({
name: `.risk-score-mappings-${namespace}`,
_meta: {
managed: true,
},
}),
totalFieldsLimit: 1000,
})
);
};
expect(createOrUpdateComponentTemplate).toHaveBeenCalledWith(
expect.objectContaining({
const assertIndexTemplate = (namespace: string) => {
expect(createOrUpdateIndexTemplate).toHaveBeenCalledWith({
logger,
esClient,
template: expect.objectContaining({
name: '.risk-score-mappings',
_meta: {
managed: true,
template: {
name: `.risk-score.risk-score-${namespace}-index-template`,
body: {
data_stream: { hidden: true },
index_patterns: [`risk-score.risk-score-${namespace}`],
composed_of: [`.risk-score-mappings-${namespace}`],
template: {
lifecycle: {},
settings: {
'index.mapping.total_fields.limit': totalFieldsLimit,
},
mappings: {
dynamic: false,
_meta: {
kibana: {
version: '8.9.0',
},
managed: true,
namespace,
},
},
},
_meta: {
kibana: {
version: '8.9.0',
},
managed: true,
namespace,
},
},
}),
totalFieldsLimit: 1000,
})
);
},
});
};
const assertDataStream = (namespace: string) => {
expect(createDataStream).toHaveBeenCalledWith({
logger,
esClient,
totalFieldsLimit,
indexPatterns: {
template: `.risk-score.risk-score-${namespace}-index-template`,
alias: `risk-score.risk-score-${namespace}`,
},
});
};
const assertIndex = (namespace: string) => {
expect(createOrUpdateIndex).toHaveBeenCalledWith({
logger,
esClient,
options: {
index: `risk-score.risk-score-latest-${namespace}`,
mappings: {
dynamic: false,
properties: {
'@timestamp': {
ignore_malformed: false,
type: 'date',
},
host: {
properties: {
name: {
type: 'keyword',
},
risk: {
properties: {
calculated_level: {
type: 'keyword',
},
calculated_score: {
type: 'float',
},
calculated_score_norm: {
type: 'float',
},
category_1_count: {
type: 'long',
},
category_1_score: {
type: 'float',
},
id_field: {
type: 'keyword',
},
id_value: {
type: 'keyword',
},
inputs: {
properties: {
category: {
type: 'keyword',
},
description: {
type: 'keyword',
},
id: {
type: 'keyword',
},
index: {
type: 'keyword',
},
risk_score: {
type: 'float',
},
timestamp: {
type: 'date',
},
},
type: 'object',
},
notes: {
type: 'keyword',
},
},
type: 'object',
},
},
},
user: {
properties: {
name: {
type: 'keyword',
},
risk: {
properties: {
calculated_level: {
type: 'keyword',
},
calculated_score: {
type: 'float',
},
calculated_score_norm: {
type: 'float',
},
category_1_count: {
type: 'long',
},
category_1_score: {
type: 'float',
},
id_field: {
type: 'keyword',
},
id_value: {
type: 'keyword',
},
inputs: {
properties: {
category: {
type: 'keyword',
},
description: {
type: 'keyword',
},
id: {
type: 'keyword',
},
index: {
type: 'keyword',
},
risk_score: {
type: 'float',
},
timestamp: {
type: 'date',
},
},
type: 'object',
},
notes: {
type: 'keyword',
},
},
type: 'object',
},
},
},
},
},
},
});
};
const assertTransform = (namespace: string) => {
expect(transforms.createTransform).toHaveBeenCalledWith({
logger,
esClient,
transform: {
dest: {
index: `risk-score.risk-score-latest-${namespace}`,
},
frequency: '1h',
latest: {
sort: '@timestamp',
unique_key: ['host.name', 'user.name'],
},
source: {
index: [`risk-score.risk-score-${namespace}`],
},
sync: {
time: {
delay: '0s',
field: '@timestamp',
},
},
transform_id: `risk_score_latest_transform_${namespace}`,
settings: {
unattended: true,
},
_meta: {
version: 2,
managed: true,
managed_by: 'security-entity-analytics',
},
},
});
};
// Default namespace
esClient.cluster.existsComponentTemplate.mockResolvedValue(false);
await riskScoreDataClient.init();
assertComponentTemplate('default');
assertIndexTemplate('default');
assertDataStream('default');
assertIndex('default');
assertTransform('default');
// Space-1 namespace
esClient.cluster.existsComponentTemplate.mockResolvedValue(false);
await riskScoreDataClientWithNameSpace.init();
assertComponentTemplate('space-1');
assertIndexTemplate('space-1');
assertDataStream('space-1');
assertIndex('space-1');
assertTransform('space-1');
expect((createOrUpdateComponentTemplate as jest.Mock).mock.lastCall[0].template.template)
.toMatchInlineSnapshot(`
Object {
"mappings": Object {
"dynamic": "strict",
"properties": Object {
"@timestamp": Object {
"ignore_malformed": false,
"type": "date",
},
"host": Object {
"properties": Object {
"name": Object {
"type": "keyword",
},
"risk": Object {
"properties": Object {
"calculated_level": Object {
"type": "keyword",
},
"calculated_score": Object {
"type": "float",
},
"calculated_score_norm": Object {
"type": "float",
},
"category_1_count": Object {
"type": "long",
},
"category_1_score": Object {
"type": "float",
},
"id_field": Object {
"type": "keyword",
},
"id_value": Object {
"type": "keyword",
},
"inputs": Object {
"properties": Object {
"category": Object {
"type": "keyword",
},
"description": Object {
"type": "keyword",
},
"id": Object {
"type": "keyword",
},
"index": Object {
"type": "keyword",
},
"risk_score": Object {
"type": "float",
},
"timestamp": Object {
"type": "date",
},
Object {
"mappings": Object {
"dynamic": "strict",
"properties": Object {
"@timestamp": Object {
"ignore_malformed": false,
"type": "date",
},
"host": Object {
"properties": Object {
"name": Object {
"type": "keyword",
},
"risk": Object {
"properties": Object {
"calculated_level": Object {
"type": "keyword",
},
"calculated_score": Object {
"type": "float",
},
"calculated_score_norm": Object {
"type": "float",
},
"category_1_count": Object {
"type": "long",
},
"category_1_score": Object {
"type": "float",
},
"id_field": Object {
"type": "keyword",
},
"id_value": Object {
"type": "keyword",
},
"inputs": Object {
"properties": Object {
"category": Object {
"type": "keyword",
},
"type": "object",
},
"notes": Object {
"type": "keyword",
},
},
"type": "object",
},
},
},
"user": Object {
"properties": Object {
"name": Object {
"type": "keyword",
},
"risk": Object {
"properties": Object {
"calculated_level": Object {
"type": "keyword",
},
"calculated_score": Object {
"type": "float",
},
"calculated_score_norm": Object {
"type": "float",
},
"category_1_count": Object {
"type": "long",
},
"category_1_score": Object {
"type": "float",
},
"id_field": Object {
"type": "keyword",
},
"id_value": Object {
"type": "keyword",
},
"inputs": Object {
"properties": Object {
"category": Object {
"type": "keyword",
},
"description": Object {
"type": "keyword",
},
"id": Object {
"type": "keyword",
},
"index": Object {
"type": "keyword",
},
"risk_score": Object {
"type": "float",
},
"timestamp": Object {
"type": "date",
},
"description": Object {
"type": "keyword",
},
"id": Object {
"type": "keyword",
},
"index": Object {
"type": "keyword",
},
"risk_score": Object {
"type": "float",
},
"timestamp": Object {
"type": "date",
},
"type": "object",
},
"notes": Object {
"type": "keyword",
},
"type": "object",
},
"notes": Object {
"type": "keyword",
},
"type": "object",
},
"type": "object",
},
},
},
"user": Object {
"properties": Object {
"name": Object {
"type": "keyword",
},
"risk": Object {
"properties": Object {
"calculated_level": Object {
"type": "keyword",
},
"calculated_score": Object {
"type": "float",
},
"calculated_score_norm": Object {
"type": "float",
},
"category_1_count": Object {
"type": "long",
},
"category_1_score": Object {
"type": "float",
},
"id_field": Object {
"type": "keyword",
},
"id_value": Object {
"type": "keyword",
},
"inputs": Object {
"properties": Object {
"category": Object {
"type": "keyword",
},
"description": Object {
"type": "keyword",
},
"id": Object {
"type": "keyword",
},
"index": Object {
"type": "keyword",
},
"risk_score": Object {
"type": "float",
},
"timestamp": Object {
"type": "date",
},
},
"type": "object",
},
"notes": Object {
"type": "keyword",
},
},
"type": "object",
},
},
},
},
"settings": Object {},
}
`);
expect(createOrUpdateIndexTemplate).toHaveBeenCalledWith({
logger,
esClient,
template: {
name: '.risk-score.risk-score-default-index-template',
body: {
data_stream: { hidden: true },
index_patterns: ['risk-score.risk-score-default'],
composed_of: ['.risk-score-mappings'],
template: {
lifecycle: {},
settings: {
'index.mapping.total_fields.limit': totalFieldsLimit,
},
mappings: {
dynamic: false,
_meta: {
kibana: {
version: '8.9.0',
},
managed: true,
namespace: 'default',
},
},
},
_meta: {
kibana: {
version: '8.9.0',
},
managed: true,
namespace: 'default',
},
},
},
});
expect(createDataStream).toHaveBeenCalledWith({
logger,
esClient,
totalFieldsLimit,
indexPatterns: {
template: `.risk-score.risk-score-default-index-template`,
alias: `risk-score.risk-score-default`,
},
});
expect(createOrUpdateIndex).toHaveBeenCalledWith({
logger,
esClient,
options: {
index: `risk-score.risk-score-latest-default`,
mappings: {
dynamic: false,
properties: {
'@timestamp': {
ignore_malformed: false,
type: 'date',
},
host: {
properties: {
name: {
type: 'keyword',
},
risk: {
properties: {
calculated_level: {
type: 'keyword',
},
calculated_score: {
type: 'float',
},
calculated_score_norm: {
type: 'float',
},
category_1_count: {
type: 'long',
},
category_1_score: {
type: 'float',
},
id_field: {
type: 'keyword',
},
id_value: {
type: 'keyword',
},
inputs: {
properties: {
category: {
type: 'keyword',
},
description: {
type: 'keyword',
},
id: {
type: 'keyword',
},
index: {
type: 'keyword',
},
risk_score: {
type: 'float',
},
timestamp: {
type: 'date',
},
},
type: 'object',
},
notes: {
type: 'keyword',
},
},
type: 'object',
},
},
},
user: {
properties: {
name: {
type: 'keyword',
},
risk: {
properties: {
calculated_level: {
type: 'keyword',
},
calculated_score: {
type: 'float',
},
calculated_score_norm: {
type: 'float',
},
category_1_count: {
type: 'long',
},
category_1_score: {
type: 'float',
},
id_field: {
type: 'keyword',
},
id_value: {
type: 'keyword',
},
inputs: {
properties: {
category: {
type: 'keyword',
},
description: {
type: 'keyword',
},
id: {
type: 'keyword',
},
index: {
type: 'keyword',
},
risk_score: {
type: 'float',
},
timestamp: {
type: 'date',
},
},
type: 'object',
},
notes: {
type: 'keyword',
},
},
type: 'object',
},
},
},
},
},
},
});
expect(transforms.createTransform).toHaveBeenCalledWith({
logger,
esClient,
transform: {
dest: {
index: 'risk-score.risk-score-latest-default',
},
frequency: '1h',
latest: {
sort: '@timestamp',
unique_key: ['host.name', 'user.name'],
},
source: {
index: ['risk-score.risk-score-default'],
},
sync: {
time: {
delay: '0s',
field: '@timestamp',
},
},
transform_id: 'risk_score_latest_transform_default',
settings: {
unattended: true,
},
_meta: {
version: 2,
managed: true,
managed_by: 'security-entity-analytics',
},
},
});
"settings": Object {},
}
`);
});
});

View file

@ -22,6 +22,7 @@ import {
getIndexPatternDataStream,
getTransformOptions,
mappingComponentName,
nameSpaceAwareMappingsComponentName,
riskScoreFieldMap,
totalFieldsLimit,
} from './configurations';
@ -114,12 +115,22 @@ export class RiskScoreDataClient {
namespace,
};
// Check if there are any existing component templates with the namespace in the name
const oldComponentTemplateExists = await esClient.cluster.existsComponentTemplate({
name: mappingComponentName,
});
if (oldComponentTemplateExists) {
await this.updateComponentTemplateNamewithNamespace(namespace);
}
// Update the new component template with the required data
await Promise.all([
createOrUpdateComponentTemplate({
logger: this.options.logger,
esClient,
template: {
name: mappingComponentName,
name: nameSpaceAwareMappingsComponentName(namespace),
_meta: {
managed: true,
},
@ -140,7 +151,7 @@ export class RiskScoreDataClient {
body: {
data_stream: { hidden: true },
index_patterns: [indexPatterns.alias],
composed_of: [mappingComponentName],
composed_of: [nameSpaceAwareMappingsComponentName(namespace)],
template: {
lifecycle: {},
settings: {
@ -156,6 +167,14 @@ export class RiskScoreDataClient {
},
});
// Delete the component template without the namespace in the name
await esClient.cluster.deleteComponentTemplate(
{
name: mappingComponentName,
},
{ ignore: [404] }
);
await createDataStream({
logger: this.options.logger,
esClient,
@ -286,4 +305,20 @@ export class RiskScoreDataClient {
{ logger: this.options.logger }
);
}
private async updateComponentTemplateNamewithNamespace(namespace: string): Promise<void> {
const esClient = this.options.esClient;
const oldComponentTemplateResponse = await esClient.cluster.getComponentTemplate(
{
name: mappingComponentName,
},
{ ignore: [404] }
);
const oldComponentTemplate = oldComponentTemplateResponse?.component_templates[0];
const newComponentTemplateName = nameSpaceAwareMappingsComponentName(namespace);
await esClient.cluster.putComponentTemplate({
name: newComponentTemplateName,
body: oldComponentTemplate.component_template,
});
}
}