[9.4] [Entity Store] Cap window size (#268170)#268446
Merged
Merged
Conversation
In lagging environments the entity-store extraction window grows unboundedly. `getExtractionWindow` always sets `toDateISO = now - delay` while `fromDateISO` advances only via `lastExecutionTimestamp / paginationTimestamp`. If a run cannot keep up, each subsequent run sees a wider window. The probe (`buildLogPaginationCursorProbeEsql`) sorts every doc in that window in ES|QL, so probe cost grows with window size — feeding a death-spiral where slow runs widen the window which slows the next run further. We want a hard cap on the width of each probe's window so that probe cost stays bounded regardless of how far behind the engine is. The cap is purely a cost-bounding device for the probe — it does not artificially defer catch-up to a later run. Within a single extractLogs execution, once a capped sub-window is drained we immediately advance to the next sub-window and continue, until we reach the effective window end (now - delay). Only when a run is interrupted (crash, abort, hitting a slow probe) do we resume on the next scheduled run from the last persisted lastExecutionTimestamp. ### How it works When the gap between `fromDateISO` and the effective window end (`now - delay`) exceeds `maxTimeWindowSize + GRACE_PERIOD` (default `15m + 30s`), the run processes the time range as a sequence of capped `[fromSub, toSub]` sub-windows of width `maxTimeWindowSize`, advancing within a single execution until the effective end is reached. Sub-windows are an in-memory iteration concept — the saved-object schema is unaware of them. Crash recovery uses the per-slice persistence emitted by the inner outer-loop (last `paginationTimestamp` / `checkpointTimestamp` written). Manual `specificWindow` / `windowOverride` runs bypass capping and run as a single pass. ### Added - `maxTimeWindowSize` parameter to the global configuration, available on install and update paths. Also exposed via status api ### Why default 15m `15m` seems to be an ok cap based on the default `3h` look back period. A too short `1m` will cause 180 queries to elasticsearch. `15m` will cause only 12. This will need to be configured on heavy environments where `15m` worth of data account for millions of logs. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 555237a) # Conflicts: # src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts # x-pack/solutions/security/plugins/entity_store/server/routes/apis/status.ts
…tion_tests/ci_checks
Contributor
💛 Build succeeded, but was flaky
Failed CI Steps
Test Failures
Metrics [docs]
|
uri-weisman
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
mainto9.4:Questions ?
Please refer to the Backport tool documentation