Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Response Ops][Alerting] Alerting event logger should not throw error…
… when ad hoc task runner cannot load saved object (#201637) ## Summary The ad-hoc task runner loads the `ad_hoc_run` saved object that contains rule information when it first starts running. If the saved object cannot be loaded due to saved object not found (likely because the SO was deleted), the alerting event logger was throwing an error because it didn't have the rule information to populate the `execute-backfill` event. This PR fixes it so we're not throwing an error and writes the `execute-backfill` event with whatever information is available. ## To Verify 1. Modify the ad-hoc task runner to load a random saved object ``` --- a/x-pack/plugins/alerting/server/task_runner/ad_hoc_task_runner.ts +++ b/x-pack/plugins/alerting/server/task_runner/ad_hoc_task_runner.ts @@ -294,7 +294,8 @@ export class AdHocTaskRunner implements CancellableTask { const adHocRunSO: SavedObject<AdHocRunSO> = await this.context.encryptedSavedObjectsClient.getDecryptedAsInternalUser<AdHocRunSO>( AD_HOC_RUN_SAVED_OBJECT_TYPE, - adHocRunParamsId, + `abcdefgh`, + // adHocRunParamsId, { namespace } ``` 2. Create a detection rule and then schedule backfill run for it. You should see the execution fail with `Executing ad hoc run with id \"7401d1f1-73fc-4483-acd5-edf6180028ce\" has resulted in Error: Saved object [ad_hoc_run_params/abcdefgh] not found` but you should NOT see any errors from task manager like `Task ad_hoc_run-backfill "40fd4c52-411f-462c-b285-87e33520bd5b" failed: Error: AlertingEventLogger not initialized` Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information