Skip to content

Commit 6503048

Browse files
authored
[9.0] [index mgmt] Fix preview of index templates which are used by data streams (#217604) (#217767)
# Backport This will backport the following commits from `main` to `9.0`: - [[index mgmt] Fix preview of index templates which are used by data streams (#217604)](#217604) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Matthew Kime","email":"matt@mattki.me"},"sourceCommit":{"committedDate":"2025-04-09T17:29:12Z","message":"[index mgmt] Fix preview of index templates which are used by data streams (#217604)\n\n## Summary\n\nFixes error message when attempting to preview an index template which\nis used by a data stream.\n\nWhen previewing a saved index template, a index template name and index\npattern were provided. If the index pattern didn't match data streams\nthat relied on the index template (and they never did) an error would be\nshown. As it turns out, supplying the index pattern was entirely\nunnecessary. This PR simply removes the index pattern from the api call\nand adds a test to make sure that preview functionality works when index\ntemplates match data streams.\n\nFollow up to https://github.com/elastic/kibana/pull/195174\n\nCloses https://github.com/elastic/kibana/issues/212781","sha":"b542a760cf5c87900c87b3f5424749eec52366c6","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Feature:Index Management","Team:Kibana Management","backport:prev-major","v8.18.0","v9.1.0","v8.19.0"],"title":"[index mgmt] Fix preview of index templates which are used by data streams","number":217604,"url":"https://github.com/elastic/kibana/pull/217604","mergeCommit":{"message":"[index mgmt] Fix preview of index templates which are used by data streams (#217604)\n\n## Summary\n\nFixes error message when attempting to preview an index template which\nis used by a data stream.\n\nWhen previewing a saved index template, a index template name and index\npattern were provided. If the index pattern didn't match data streams\nthat relied on the index template (and they never did) an error would be\nshown. As it turns out, supplying the index pattern was entirely\nunnecessary. This PR simply removes the index pattern from the api call\nand adds a test to make sure that preview functionality works when index\ntemplates match data streams.\n\nFollow up to https://github.com/elastic/kibana/pull/195174\n\nCloses https://github.com/elastic/kibana/issues/212781","sha":"b542a760cf5c87900c87b3f5424749eec52366c6"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/217737","number":217737,"state":"MERGED","mergeCommit":{"sha":"b652d91bd4dcace9f127c0e475ced46ef91388c6","message":"[8.18] [index mgmt] Fix preview of index templates which are used by data streams (#217604) (#217737)\n\n# Backport\n\nThis will backport the following commits from `main` to `8.18`:\n- [[index mgmt] Fix preview of index templates which are used by data\nstreams (#217604)](https://github.com/elastic/kibana/pull/217604)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by: Matthew Kime <matt@mattki.me>"}},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217604","number":217604,"mergeCommit":{"message":"[index mgmt] Fix preview of index templates which are used by data streams (#217604)\n\n## Summary\n\nFixes error message when attempting to preview an index template which\nis used by a data stream.\n\nWhen previewing a saved index template, a index template name and index\npattern were provided. If the index pattern didn't match data streams\nthat relied on the index template (and they never did) an error would be\nshown. As it turns out, supplying the index pattern was entirely\nunnecessary. This PR simply removes the index pattern from the api call\nand adds a test to make sure that preview functionality works when index\ntemplates match data streams.\n\nFollow up to https://github.com/elastic/kibana/pull/195174\n\nCloses https://github.com/elastic/kibana/issues/212781","sha":"b542a760cf5c87900c87b3f5424749eec52366c6"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/217738","number":217738,"state":"MERGED","mergeCommit":{"sha":"28cc7e2d2484d35f5691fad2edcfc44998e41b9a","message":"[8.x] [index mgmt] Fix preview of index templates which are used by data streams (#217604) (#217738)\n\n# Backport\n\nThis will backport the following commits from `main` to `8.x`:\n- [[index mgmt] Fix preview of index templates which are used by data\nstreams (#217604)](https://github.com/elastic/kibana/pull/217604)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by: Matthew Kime <matt@mattki.me>"}}]}] BACKPORT-->
1 parent 5f4c02a commit 6503048

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

x-pack/platform/plugins/shared/index_management/server/routes/api/templates/register_simulate_route.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export function registerSimulateRoute({ router, lib: { handleEsError } }: RouteD
4040
const params: estypes.IndicesSimulateTemplateRequest = templateName
4141
? {
4242
name: templateName,
43-
index_patterns,
4443
}
4544
: {
4645
...template,

x-pack/test/api_integration/apis/management/index_management/templates.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,23 @@ export default function ({ getService }: FtrProviderContext) {
521521
// cleanup
522522
await deleteTemplates([{ name: templateName }]);
523523
});
524+
525+
it('should simulate an index template by name with a related data stream', async () => {
526+
const dataStreamName = `test-foo`;
527+
const templateName = `template-${getRandomString()}`;
528+
const payload = getTemplatePayload(templateName);
529+
530+
await createTemplate({ ...payload, dataStream: {} }).expect(200);
531+
532+
// Matches index template
533+
await es.indices.createDataStream({ name: dataStreamName });
534+
535+
await simulateTemplateByName(templateName).expect(200);
536+
537+
// cleanup
538+
await deleteTemplates([{ name: templateName }]);
539+
await es.indices.deleteDataStream({ name: dataStreamName });
540+
});
524541
});
525542
});
526543
}

0 commit comments

Comments
 (0)