[Fleet] Auto install content packages task#226523
[Fleet] Auto install content packages task#226523juliaElastic merged 22 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/fleet (Team:Fleet) |
| telemetryEvent.currentVersion = installedPkg?.attributes.version || 'not_installed'; | ||
| telemetryEvent.packageType = packageInfo.type; | ||
| telemetryEvent.discoveryFields = packageInfo.discovery?.fields; | ||
| telemetryEvent.automaticInstall = automaticInstall; |
There was a problem hiding this comment.
sending telemetry event like this:
{
packageName: 'kubernetes_otel',
currentVersion: 'not_installed',
newVersion: '1.1.0',
status: 'success',
dryRun: false,
eventType: 'package-install',
installType: 'install',
packageType: 'content',
discoveryDatasets: [ { name: 'system.cpu' } ],
automaticInstall: true
}
| continue; | ||
| } | ||
|
|
||
| const hasData = await this.hasDiscoveryFieldData(esClient, dataset); |
There was a problem hiding this comment.
I'm not sure how much overlap there will be in content packs dataset fields.
Currently doing an ES search for each dataset value (as they can map to multiple packages).
Alternatively we could go by package and do a single terms query with all dataset values at once.
Another option would be to do a single terms aggregation on the dataset field, and compare results with dataset fields in content packages.
There was a problem hiding this comment.
Is it worth exploring ESQL for these queries at all to simplify anything here, or is the DSL our best bet? We definitely want to minimize the amount of queries we run here and keep them lightweight as the index patterns we query are going to be under heavy write pressure from agents, collectors, etc in large environments.
There was a problem hiding this comment.
Changed the implementation to use a single ESQL query to get the unique datasets that appear in the recently ingested data, filtering out the dataset fields from the already installed content packs.
We would have to test the performance of this query on large clusters.
MichelLosier
left a comment
There was a problem hiding this comment.
Code looks good! Working on the local setup to verify
x-pack/platform/plugins/shared/fleet/server/tasks/auto_install_content_packages_task.ts
Outdated
Show resolved
Hide resolved
…_content_packages_task.ts Co-authored-by: Michel Losier <mikelosier@gmail.com>
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Public APIs missing comments
Public APIs missing exports
Page load bundle
History
|
MichelLosier
left a comment
There was a problem hiding this comment.
Runs as expected!
- Ran it with this package-registry PR: elastic/package-registry#1338
- For the good_content package discovery fields to get picked up I had to:
- In
auto_install_content_packages_task:322I setprereleasetotrue - In
Registry.fetchListcomment out thesetConstraints - Also added
elastic_agent.filebeatas a discovery field to good_content
- In
## Summary Adjusted to datasets field elastic/package-spec#922 Closes elastic/ingest-dev#5685 Added kibana task to check discovery dataset fields of content packages in EPR, check recent data ingested for matching fields, and install content packages if not installed yet. Added telemetry mappings: elastic/telemetry#4940 To verify: - enable feature flag in `kibana.dev.yml`: `xpack.fleet.enableExperimental: ['enableAutoInstallContentPackages']` - TODO start local epr with test package that has a `discovery.datasets` with a value (e.g. system.cpu), depends on [package-spec](elastic/package-spec#922) change to be available - enroll an agent and wait until some data is ingested to the dataset above - wait 10m for the task to run - verify that the test package is installed Kibana logs: ``` [2025-07-10T14:07:13.177+02:00][INFO ][plugins.fleet.fleet:auto-install-content-packages-task:1.0.1] [runTask()] started [2025-07-10T14:07:13.206+02:00][DEBUG][plugins.fleet.fleet:auto-install-content-packages-task:1.0.1] [AutoInstallContentPackagesTask] ESQL query took: 11ms [2025-07-10T14:07:13.207+02:00][DEBUG][plugins.fleet.fleet:auto-install-content-packages-task:1.0.1] [AutoInstallContentPackagesTask] Found datasets with data: fleet_server.agent_versions, fleet_server.agent_status, elastic_agent.fleet_server [2025-07-10T14:07:13.207+02:00][DEBUG][plugins.fleet.fleet:auto-install-content-packages-task:1.0.1] [AutoInstallContentPackagesTask] Content packages to install: kubernetes_otel@1.1.0 [2025-07-10T14:07:13.208+02:00][DEBUG][plugins.fleet] Kicking off install of kubernetes_otel-1.1.0 from registry [2025-07-10T14:07:15.605+02:00][INFO ][plugins.fleet.fleet:auto-install-content-packages-task:1.0.1] [AutoInstallContentPackagesTask] runTask ended: success ``` ### Checklist - [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: Michel Losier <mikelosier@gmail.com>
## Summary Adjusted to datasets field elastic/package-spec#922 Closes elastic/ingest-dev#5685 Added kibana task to check discovery dataset fields of content packages in EPR, check recent data ingested for matching fields, and install content packages if not installed yet. Added telemetry mappings: elastic/telemetry#4940 To verify: - enable feature flag in `kibana.dev.yml`: `xpack.fleet.enableExperimental: ['enableAutoInstallContentPackages']` - TODO start local epr with test package that has a `discovery.datasets` with a value (e.g. system.cpu), depends on [package-spec](elastic/package-spec#922) change to be available - enroll an agent and wait until some data is ingested to the dataset above - wait 10m for the task to run - verify that the test package is installed Kibana logs: ``` [2025-07-10T14:07:13.177+02:00][INFO ][plugins.fleet.fleet:auto-install-content-packages-task:1.0.1] [runTask()] started [2025-07-10T14:07:13.206+02:00][DEBUG][plugins.fleet.fleet:auto-install-content-packages-task:1.0.1] [AutoInstallContentPackagesTask] ESQL query took: 11ms [2025-07-10T14:07:13.207+02:00][DEBUG][plugins.fleet.fleet:auto-install-content-packages-task:1.0.1] [AutoInstallContentPackagesTask] Found datasets with data: fleet_server.agent_versions, fleet_server.agent_status, elastic_agent.fleet_server [2025-07-10T14:07:13.207+02:00][DEBUG][plugins.fleet.fleet:auto-install-content-packages-task:1.0.1] [AutoInstallContentPackagesTask] Content packages to install: kubernetes_otel@1.1.0 [2025-07-10T14:07:13.208+02:00][DEBUG][plugins.fleet] Kicking off install of kubernetes_otel-1.1.0 from registry [2025-07-10T14:07:15.605+02:00][INFO ][plugins.fleet.fleet:auto-install-content-packages-task:1.0.1] [AutoInstallContentPackagesTask] runTask ended: success ``` ### Checklist - [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: Michel Losier <mikelosier@gmail.com>
Summary
Adjusted to datasets field elastic/package-spec#922
Closes https://github.com/elastic/ingest-dev/issues/5685
Added kibana task to check discovery dataset fields of content packages in EPR, check recent data ingested for matching fields, and install content packages if not installed yet.
Added telemetry mappings: https://github.com/elastic/telemetry/pull/4940
To verify:
kibana.dev.yml:xpack.fleet.enableExperimental: ['enableAutoInstallContentPackages']discovery.datasetswith a value (e.g. system.cpu), depends on package-spec change to be availableKibana logs:
Checklist