Skip to content

[9.2] Add fleet policy revisions cleanup task (#242612)#245729

Merged
MichelLosier merged 1 commit intoelastic:9.2from
MichelLosier:backport/9.2/pr-242612
Dec 9, 2025
Merged

[9.2] Add fleet policy revisions cleanup task (#242612)#245729
MichelLosier merged 1 commit intoelastic:9.2from
MichelLosier:backport/9.2/pr-242612

Conversation

@MichelLosier
Copy link
Contributor

Backport

This will backport the following commits from main to 9.2:

Questions ?

Please refer to the Backport tool documentation

Resolves: elastic#119963
PR to add new Kibana config to allow list:
elastic/cloud#149322

* Adds the background task `FleetPolicyRevisionsCleanupTask` which
removes excess policy revisions from the `.fleet-policies` index
* Enabled by default, disabled by new feature flag:
```
 xpack.fleet.experimentalFeatures:
  enableFleetPolicyRevisionsCleanupTask: true
```
* Configurable with the following:

```
xpack.fleet.fleetPolicyRevisionsCleanup:
  interval: string // Time interval expression. Default: '1h'
  max_revisions: number // Maximum amount of policy revisions. Default: 10.
  max_policies_per_run: number // Maximum policies to delete revisions from per run. Default 100.
```
* Also adds an internal endpoint for the same operation:

```
POST kbn:/internal/fleet/agent_policies/_cleanup_revisions?apiVersion=1
{
    "maxRevisions": number, // max revisions a policy should have
    "maxPolicies": number, // max policies to process
}
```
---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit d2e01dc)

# Conflicts:
#	x-pack/platform/plugins/shared/fleet/common/experimental_features.ts
#	x-pack/platform/plugins/shared/fleet/moon.yml
#	x-pack/platform/test/fleet_api_integration/config.base.ts
#	x-pack/platform/test/plugin_api_integration/test_suites/task_manager/check_registered_task_types.ts
@MichelLosier MichelLosier added the backport This PR is a backport of another PR label Dec 9, 2025
@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Dec 9, 2025
@MichelLosier MichelLosier enabled auto-merge (squash) December 9, 2025 20:11
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@MichelLosier MichelLosier merged commit 753cdb9 into elastic:9.2 Dec 9, 2025
18 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
fleet 1527 1528 +1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 177.3KB 177.4KB +108.0B
Unknown metric groups

API count

id before after diff
fleet 1659 1660 +1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR Team:Fleet Team label for Observability Data Collection Fleet team

3 participants