-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Entity Store] Keep per-process extraction state #290481
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
Open
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
05690f7
entity_store: SO v9, nonPriority cursor field
kubasobon 9ab307b
entity_store: route cursor by extraction mode
kubasobon ee6c394
entity_store: tests for nonPriority cursor routing
kubasobon 5139cd9
fixup: update comments
kubasobon 3c0eb99
Changes from node scripts/check
kibanamachine 6875ce1
fix test schemas
kubasobon f8d0d6e
fix: apply review remarks
kubasobon b408d77
Changes from node scripts/check
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
...eck-saved-objects-cli/src/migrations/__fixtures__/entity-engine-descriptor-v2/10.9.0.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| { | ||
| "10.8.0": [ | ||
| { | ||
| "type": "user", | ||
| "status": "started", | ||
| "logExtractionState": { | ||
| "checkpointTimestamp": "2026-03-04T18:00:00.000Z", | ||
| "paginationId": null, | ||
| "lastExecutionTimestamp": "2026-03-04T17:37:20.000Z", | ||
| "sliceEndTimestamp": null | ||
| }, | ||
| "error": null, | ||
| "versionState": { | ||
| "version": "2", | ||
| "state": "running", | ||
| "isMigratedFromV1": true | ||
| } | ||
| }, | ||
| { | ||
| "type": "service", | ||
| "status": "stopped", | ||
| "logExtractionState": { | ||
| "checkpointTimestamp": null, | ||
| "paginationId": null, | ||
| "lastExecutionTimestamp": null, | ||
| "sliceEndTimestamp": null | ||
| }, | ||
| "error": null, | ||
| "versionState": { | ||
| "version": "2", | ||
| "state": "running", | ||
| "isMigratedFromV1": false | ||
| } | ||
| }, | ||
| { | ||
| "type": "host", | ||
| "status": "started", | ||
| "logExtractionState": { | ||
| "checkpointTimestamp": "2026-03-04T17:00:00.000Z", | ||
| "paginationId": "some-pagination-id", | ||
| "lastExecutionTimestamp": "2026-03-04T16:37:20.000Z", | ||
| "sliceEndTimestamp": "2026-03-04T17:30:00.000Z" | ||
| }, | ||
| "error": null, | ||
| "versionState": { | ||
| "version": "2", | ||
| "state": "running", | ||
| "isMigratedFromV1": false | ||
| } | ||
| } | ||
| ], | ||
| "10.9.0": [ | ||
| { | ||
| "type": "user", | ||
| "status": "started", | ||
| "logExtractionState": { | ||
| "checkpointTimestamp": "2026-03-04T18:00:00.000Z", | ||
| "paginationId": null, | ||
| "lastExecutionTimestamp": "2026-03-04T17:37:20.000Z", | ||
| "sliceEndTimestamp": null | ||
| }, | ||
| "error": null, | ||
| "versionState": { | ||
| "version": "2", | ||
| "state": "running", | ||
| "isMigratedFromV1": true | ||
| } | ||
| }, | ||
| { | ||
| "type": "service", | ||
| "status": "stopped", | ||
| "logExtractionState": { | ||
| "checkpointTimestamp": null, | ||
| "paginationId": null, | ||
| "lastExecutionTimestamp": null, | ||
| "sliceEndTimestamp": null | ||
| }, | ||
| "error": null, | ||
| "versionState": { | ||
| "version": "2", | ||
| "state": "running", | ||
| "isMigratedFromV1": false | ||
| } | ||
| }, | ||
| { | ||
| "type": "host", | ||
| "status": "started", | ||
| "logExtractionState": { | ||
| "checkpointTimestamp": "2026-03-04T17:00:00.000Z", | ||
| "paginationId": "some-pagination-id", | ||
| "lastExecutionTimestamp": "2026-03-04T16:37:20.000Z", | ||
| "sliceEndTimestamp": "2026-03-04T17:30:00.000Z" | ||
| }, | ||
| "error": null, | ||
| "versionState": { | ||
| "version": "2", | ||
| "state": "running", | ||
| "isMigratedFromV1": false | ||
| } | ||
| } | ||
| ] | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ import { | |
| } from '../asset_manager/external_indices_contants'; | ||
| import { type LogExtractionConfig } from '../saved_objects'; | ||
| import { | ||
| type EngineDescriptor, | ||
| type EngineDescriptorClient, | ||
| type EngineLogExtractionState, | ||
| type EntityStoreGlobalStateClient, | ||
|
|
@@ -132,6 +133,20 @@ export class LogsExtractionClient { | |
| this.extractionMode = extractionMode ?? 'single'; | ||
| } | ||
|
|
||
| /** Maps each extraction mode to its cursor field. single and priority share logExtractionState; | ||
| * nonPriority has its own field so the two processes do not overwrite each other's position. */ | ||
| private static readonly CURSOR_FIELD: Record<ExtractionMode, keyof EngineDescriptor> = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
||
| single: 'logExtractionState', | ||
| priority: 'logExtractionState', | ||
| nonPriority: 'nonPriorityLogExtractionState', | ||
| }; | ||
|
|
||
| private cursorPatch(state: EngineLogExtractionState): Partial<EngineDescriptor> { | ||
| return { | ||
| [LogsExtractionClient.CURSOR_FIELD[this.extractionMode]]: state, | ||
| } as Partial<EngineDescriptor>; | ||
| } | ||
|
|
||
| private async getLogExtractionConfigAndState( | ||
| type: EntityType | ||
| ): Promise<{ config: LogExtractionConfig; engineState: EngineLogExtractionState }> { | ||
|
|
@@ -140,9 +155,13 @@ export class LogsExtractionClient { | |
| throw new EntityStoreNotRunningError(); | ||
| } | ||
| const globalOverrides = await this.globalStateClient.findLogExtractionOverrides(); | ||
| const engineState = | ||
| this.extractionMode === 'nonPriority' | ||
| ? engineDescriptor.nonPriorityLogExtractionState ?? FRESH_ENGINE_LOG_EXTRACTION_STATE | ||
| : engineDescriptor.logExtractionState; | ||
| return { | ||
| config: getMergedConfig(type, globalOverrides, engineDescriptor.logExtractionConfig), | ||
| engineState: engineDescriptor.logExtractionState, | ||
| engineState, | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -206,12 +225,12 @@ export class LogsExtractionClient { | |
| await this.engineDescriptorClient.update(type, { error: null }); | ||
| } else { | ||
| await this.engineDescriptorClient.update(type, { | ||
| logExtractionState: { | ||
| ...this.cursorPatch({ | ||
| checkpointTimestamp: null, | ||
| paginationId: null, | ||
| lastExecutionTimestamp: lastSearchTimestamp || moment().utc().toISOString(), | ||
| sliceEndTimestamp: null, | ||
| }, | ||
| }), | ||
| error: null, | ||
| }); | ||
| } | ||
|
|
@@ -957,9 +976,10 @@ export class LogsExtractionClient { | |
| if (opts?.specificWindow) { | ||
| return; | ||
| } | ||
| await this.engineDescriptorClient.update(type, { | ||
| logExtractionState: logExtractionState as EngineLogExtractionState, | ||
| }); | ||
| await this.engineDescriptorClient.update( | ||
| type, | ||
| this.cursorPatch(logExtractionState as EngineLogExtractionState) | ||
| ); | ||
| } | ||
|
|
||
| private async handleError( | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Could be worth adding a test for when priority is the same bookmark as single. It should resume from
logExtractionStateand keep writing that field.