[index mgmt] Fix preview of index templates which are used by data streams (#217604)

## Summary

Fixes error message when attempting to preview an index template which
is used by a data stream.

When previewing a saved index template, a index template name and index
pattern were provided. If the index pattern didn't match data streams
that relied on the index template (and they never did) an error would be
shown. As it turns out, supplying the index pattern was entirely
unnecessary. This PR simply removes the index pattern from the api call
and adds a test to make sure that preview functionality works when index
templates match data streams.

Follow up to https://github.com/elastic/kibana/pull/195174

Closes https://github.com/elastic/kibana/issues/212781
This commit is contained in:
Matthew Kime 2025-04-09 12:29:12 -05:00 committed by GitHub
parent b6de659199
commit b542a760cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View file

@ -40,7 +40,6 @@ export function registerSimulateRoute({ router, lib: { handleEsError } }: RouteD
const params: estypes.IndicesSimulateTemplateRequest = templateName
? {
name: templateName,
index_patterns,
}
: {
...template,

View file

@ -519,6 +519,23 @@ export default function ({ getService }: FtrProviderContext) {
// cleanup
await deleteTemplates([{ name: templateName }]);
});
it('should simulate an index template by name with a related data stream', async () => {
const dataStreamName = `test-foo`;
const templateName = `template-${getRandomString()}`;
const payload = getTemplatePayload(templateName);
await createTemplate({ ...payload, dataStream: {} }).expect(200);
// Matches index template
await es.indices.createDataStream({ name: dataStreamName });
await simulateTemplateByName(templateName).expect(200);
// cleanup
await deleteTemplates([{ name: templateName }]);
await es.indices.deleteDataStream({ name: dataStreamName });
});
});
});
}