-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fleet] Support user overrides in composable templates #101769
[Fleet] Support user overrides in composable templates #101769
Conversation
@elasticmachine merge upstream |
…i/kibana into 90454-support-composable-templates
jenkins, test this (restarting due to jenkins upgrade) |
x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts
Outdated
Show resolved
Hide resolved
@elasticmachine merge upstream |
x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts
Outdated
Show resolved
Hide resolved
@jpountz Pinging you on this PR as we introduce here a new naming convention for component templates for the data stream naming scheme with is |
I was playing around with this. I installed apache but there was only the I remove the apache package again and the custom template also disappears. I'm torn if this is expected or might be a suprise to the user? Should we make it an option to the user if these should be removed to? @jen-huang @jfsiii What do you see as the expected behavior? |
No, but I'd like @dakrone to check too. |
Thanks for mentioning that. The current code merely creates the new component templates. It doesn't move or rename the
It is the current behavior and expected but I see why it may not be "correct" or "desirable". cc: @simitt & @mostlyjason The current code in
Good question, cc: @mostlyjason & @simitt again. It's not a technical challenge to leave it installed, but giving the user a choice would seem to add some UI and we're ~1 week from FF. We could have it default one way (possibly with a param in the API) and add the UI to override in a later iteration. |
Apologies for the last minute change proposal - but could we install the custom component template only if the package sets a flag? (for example:
Not certain what the best behavior is for deleting. What happens if the package is reinstalled - would it get overwritten on install? |
@jfsiii For the |
@simitt No. We only install the kibana/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts Lines 261 to 270 in 9872757
I think I can add/tweak a test to confirm that reinstalling doesn't override an existing template |
@elasticmachine merge upstream |
@simitt I'll leave the decision to @ruflin @mostlyjason @jen-huang , but adding the property in a package means changes & approval (however minor) from the registry & package-spec. It's not a significant amount of engineering effort (it's essentially the approach I took initially) but it does require coordination with other parts of the stack. |
@ruflin Thanks! I updated the description and hope it's more accurate & helpful now. |
That naming scheme seems fine to me also. |
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: cc @jfsiii |
To keep this moving, should we get this PR in as and follow up on the part around |
While I have been pushing for this, the APM integration itself is only beta in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work, thanks for all the tests as well. I tested installing, upgrading, and uninstalling packages locally and things worked as expected. In the case of upgrade, my user settings were kept around in the custom template. 🎉
For the items discussed, I will create a follow up issue (#103034) to discuss them further, but I would like to get this PR in as it doesn't sound like any follow up enhancements would be breaking to what this PR introduces:
- Whether or not packages should specify if a custom template is installed or not: from discussion with @ruflin and @mostlyjason, it would be rare for a package to not want this (Endpoint seems to be the only case), so we can add an opt-out option later on.
- Whether or not the custom template should be deleted when a package is uninstalled: let's wait for user feedback on whether deleting it automatically is an annoying UX. In the future we could potentially expose a checkbox/flag to delete custom settings on uninstall.
## Summary Closes elastic#90454 Closes elastic#72959 * Rename the component templates which are [installed for some packages](https://github.com/elastic/kibana/blob/master/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts#L197-L213) from `${templateName}-mappings` and `${templateName}-settings` to `${templateName}@mappings` and `${templateName}@settings` * When any package is installed, add a component template named `${templateName}@custom` * Any of above templates also include a `_meta` property with `{ package: { name: packageName } }` * On package installation, add any installed component templates to the `installed_es` property of the `epm-packages` saved object * On package removal, remove any installed component templates from the `installed_es` property of the `epm-packages` saved object <details><summary>Kibana logs showing component templates added for package</summary> ``` │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.file@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.registry@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [.logs-endpoint.diagnostic.collection@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.library@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.security@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.network@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.alerts@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.metrics@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.process@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.policy@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.metadata@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.registry@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [.logs-endpoint.diagnostic.collection@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.security@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.file@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.library@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.network@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.alerts@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.metrics@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.policy@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.process@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.metadata@custom] ``` </details> <details><summary>screenshot - component templates are editable in the Stack Management UI</summary> <img width="1342" alt="Screen Shot 2021-06-17 at 4 06 24 PM" src="https://user-images.githubusercontent.com/57655/122465421-1502bb80-cf86-11eb-94f4-9880cb3ea844.png"> </details> ### Checklist Delete any items that are not applicable to this PR. - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [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
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
…3126) ## Summary Closes #90454 Closes #72959 * Rename the component templates which are [installed for some packages](https://github.com/elastic/kibana/blob/master/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts#L197-L213) from `${templateName}-mappings` and `${templateName}-settings` to `${templateName}@mappings` and `${templateName}@settings` * When any package is installed, add a component template named `${templateName}@custom` * Any of above templates also include a `_meta` property with `{ package: { name: packageName } }` * On package installation, add any installed component templates to the `installed_es` property of the `epm-packages` saved object * On package removal, remove any installed component templates from the `installed_es` property of the `epm-packages` saved object <details><summary>Kibana logs showing component templates added for package</summary> ``` │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.file@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.registry@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [.logs-endpoint.diagnostic.collection@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.library@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.security@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.network@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.alerts@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.metrics@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.process@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.policy@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.metadata@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.registry@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [.logs-endpoint.diagnostic.collection@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.security@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.file@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.library@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.network@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.alerts@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.metrics@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.policy@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.process@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.metadata@custom] ``` </details> <details><summary>screenshot - component templates are editable in the Stack Management UI</summary> <img width="1342" alt="Screen Shot 2021-06-17 at 4 06 24 PM" src="https://user-images.githubusercontent.com/57655/122465421-1502bb80-cf86-11eb-94f4-9880cb3ea844.png"> </details> ### Checklist Delete any items that are not applicable to this PR. - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [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 Co-authored-by: John Schulz <john.schulz@elastic.co>
Summary
Closes #90454
Closes #72959
${templateName}-mappings
and${templateName}-settings
to${templateName}@mappings
and${templateName}@settings
${templateName}@custom
_meta
property with{ package: { name: packageName } }
installed_es
property of theepm-packages
saved objectinstalled_es
property of theepm-packages
saved objectKibana logs showing component templates added for package
screenshot - component templates are editable in the Stack Management UI
Checklist
Delete any items that are not applicable to this PR.