From a0c94f433ac438787b4564750606efd847acfa2c Mon Sep 17 00:00:00 2001 From: Kevin Delemme Date: Thu, 2 Jan 2025 12:27:26 -0500 Subject: [PATCH] chore(slo): cleanup error log message (#205334) --- .../observability/plugins/slo/server/plugin.ts | 4 ++-- .../plugins/slo/server/services/create_slo.ts | 4 ++-- .../plugins/slo/server/services/reset_slo.ts | 2 +- .../slo/server/services/resource_installer.ts | 2 +- .../plugins/slo/server/services/slo_installer.ts | 2 +- .../slo/server/services/summary_search_client.ts | 2 +- .../server/services/summay_transform_manager.ts | 10 +++++----- .../services/tasks/orphan_summary_cleanup_task.ts | 10 ++++++---- .../services/transform_generators/common.ts | 2 +- .../slo/server/services/transform_manager.ts | 15 ++++++++------- .../plugins/slo/server/services/update_slo.ts | 8 ++++---- 11 files changed, 32 insertions(+), 29 deletions(-) diff --git a/x-pack/solutions/observability/plugins/slo/server/plugin.ts b/x-pack/solutions/observability/plugins/slo/server/plugin.ts index e7b25fe06ef32..c7a5a1dda3280 100644 --- a/x-pack/solutions/observability/plugins/slo/server/plugin.ts +++ b/x-pack/solutions/observability/plugins/slo/server/plugin.ts @@ -160,8 +160,8 @@ export class SLOPlugin const sloInstaller = new DefaultSLOInstaller(sloResourceInstaller, this.logger); await sloInstaller.install(); }) - .catch((error) => { - this.logger.error(`Failed to install the default SLOs: ${error}`); + .catch(() => { + // noop - error already logged from the installer }); this.sloOrphanCleanupTask = new SloOrphanSummaryCleanupTask( diff --git a/x-pack/solutions/observability/plugins/slo/server/services/create_slo.ts b/x-pack/solutions/observability/plugins/slo/server/services/create_slo.ts index a8e01fb4681f4..c74f49c1ccac8 100644 --- a/x-pack/solutions/observability/plugins/slo/server/services/create_slo.ts +++ b/x-pack/solutions/observability/plugins/slo/server/services/create_slo.ts @@ -100,14 +100,14 @@ export class CreateSLO { ]); } catch (err) { this.logger.error( - `Cannot install the SLO [id: ${slo.id}, revision: ${slo.revision}]. Rolling back.` + `Cannot create the SLO [id: ${slo.id}, revision: ${slo.revision}]. Rolling back. ${err}` ); await asyncForEach(rollbackOperations.reverse(), async (operation) => { try { await operation(); } catch (rollbackErr) { - this.logger.error('Rollback operation failed', rollbackErr); + this.logger.error(`Rollback operation failed. ${rollbackErr}`); } }); diff --git a/x-pack/solutions/observability/plugins/slo/server/services/reset_slo.ts b/x-pack/solutions/observability/plugins/slo/server/services/reset_slo.ts index c9da382c2d6ce..e91e720b4fd8d 100644 --- a/x-pack/solutions/observability/plugins/slo/server/services/reset_slo.ts +++ b/x-pack/solutions/observability/plugins/slo/server/services/reset_slo.ts @@ -87,7 +87,7 @@ export class ResetSLO { ); } catch (err) { this.logger.error( - `Cannot reset the SLO [id: ${slo.id}, revision: ${slo.revision}]. Rolling back.` + `Cannot reset the SLO [id: ${slo.id}, revision: ${slo.revision}]. Rolling back. ${err}` ); await this.summaryTransformManager.stop(summaryTransformId); diff --git a/x-pack/solutions/observability/plugins/slo/server/services/resource_installer.ts b/x-pack/solutions/observability/plugins/slo/server/services/resource_installer.ts index b81fbe183c4ff..d6544d352f90f 100644 --- a/x-pack/solutions/observability/plugins/slo/server/services/resource_installer.ts +++ b/x-pack/solutions/observability/plugins/slo/server/services/resource_installer.ts @@ -79,7 +79,7 @@ export class DefaultResourceInstaller implements ResourceInstaller { await this.createIndex(SLO_SUMMARY_DESTINATION_INDEX_NAME); await this.createIndex(SLO_SUMMARY_TEMP_INDEX_NAME); } catch (err) { - this.logger.error(`Error installing resources shared for SLO: ${err.message}`); + this.logger.error(`Error while installing SLO shared resources: ${err}`); throw err; } } diff --git a/x-pack/solutions/observability/plugins/slo/server/services/slo_installer.ts b/x-pack/solutions/observability/plugins/slo/server/services/slo_installer.ts index 9484ecd907d9f..eab4c266aae8e 100644 --- a/x-pack/solutions/observability/plugins/slo/server/services/slo_installer.ts +++ b/x-pack/solutions/observability/plugins/slo/server/services/slo_installer.ts @@ -29,7 +29,7 @@ export class DefaultSLOInstaller implements SLOInstaller { await this.sloResourceInstaller.ensureCommonResourcesInstalled(); } catch (error) { - this.logger.error('Failed to install SLO common resources'); + this.logger.error(`Failed to install SLO common resources: ${error}`); } finally { this.isInstalling = false; clearTimeout(installTimeout); diff --git a/x-pack/solutions/observability/plugins/slo/server/services/summary_search_client.ts b/x-pack/solutions/observability/plugins/slo/server/services/summary_search_client.ts index 6493e613bbedc..0d12ee7255dc8 100644 --- a/x-pack/solutions/observability/plugins/slo/server/services/summary_search_client.ts +++ b/x-pack/solutions/observability/plugins/slo/server/services/summary_search_client.ts @@ -177,7 +177,7 @@ export class DefaultSummarySearchClient implements SummarySearchClient { }), }; } catch (err) { - this.logger.error(new Error(`Summary search query error, ${err.message}`, { cause: err })); + this.logger.error(`Error while searching SLO summary documents. ${err}`); return { total: 0, perPage: pagination.perPage, page: pagination.page, results: [] }; } } diff --git a/x-pack/solutions/observability/plugins/slo/server/services/summay_transform_manager.ts b/x-pack/solutions/observability/plugins/slo/server/services/summay_transform_manager.ts index 27d24e7fb5039..9389210505b4c 100644 --- a/x-pack/solutions/observability/plugins/slo/server/services/summay_transform_manager.ts +++ b/x-pack/solutions/observability/plugins/slo/server/services/summay_transform_manager.ts @@ -32,7 +32,7 @@ export class DefaultSummaryTransformManager implements TransformManager { } ); } catch (err) { - this.logger.error(`Cannot create summary transform for SLO [${slo.id}]`); + this.logger.error(`Cannot create summary transform for SLO [${slo.id}]. ${err}`); if (err.meta?.body?.error?.type === 'security_exception') { throw new SecurityException(err.meta.body.error.reason); } @@ -57,7 +57,7 @@ export class DefaultSummaryTransformManager implements TransformManager { { logger: this.logger } ); } catch (err) { - this.logger.error(`Cannot preview SLO summary transform [${transformId}]`); + this.logger.error(`Cannot preview SLO summary transform [${transformId}]. ${err}`); throw err; } } @@ -75,7 +75,7 @@ export class DefaultSummaryTransformManager implements TransformManager { } ); } catch (err) { - this.logger.error(`Cannot start SLO summary transform [${transformId}]`); + this.logger.error(`Cannot start SLO summary transform [${transformId}]. ${err}`); throw err; } } @@ -91,7 +91,7 @@ export class DefaultSummaryTransformManager implements TransformManager { { logger: this.logger } ); } catch (err) { - this.logger.error(`Cannot stop SLO summary transform [${transformId}]`); + this.logger.error(`Cannot stop SLO summary transform [${transformId}]. ${err}`); throw err; } } @@ -107,7 +107,7 @@ export class DefaultSummaryTransformManager implements TransformManager { { logger: this.logger } ); } catch (err) { - this.logger.error(`Cannot delete SLO summary transform [${transformId}]`); + this.logger.error(`Cannot delete SLO summary transform [${transformId}]. ${err}`); throw err; } } diff --git a/x-pack/solutions/observability/plugins/slo/server/services/tasks/orphan_summary_cleanup_task.ts b/x-pack/solutions/observability/plugins/slo/server/services/tasks/orphan_summary_cleanup_task.ts index c3d56854f4946..6d0aa1ee9c587 100644 --- a/x-pack/solutions/observability/plugins/slo/server/services/tasks/orphan_summary_cleanup_task.ts +++ b/x-pack/solutions/observability/plugins/slo/server/services/tasks/orphan_summary_cleanup_task.ts @@ -67,7 +67,7 @@ export class SloOrphanSummaryCleanupTask { }, cancel: async () => { - this.abortController.abort('[SLO] Definitions clean up Task timed out'); + this.abortController.abort('orphan-slo-summary-cleanup task timed out'); }, }; }, @@ -101,7 +101,7 @@ export class SloOrphanSummaryCleanupTask { if (sloSummaryIdsToDelete.length > 0) { this.logger.info( - `[SLO] Deleting ${sloSummaryIdsToDelete.length} SLO Summaries from the summary index` + `[SLO] Deleting ${sloSummaryIdsToDelete.length} SLO Summary documents from the summary index` ); await this.esClient.deleteByQuery({ @@ -124,7 +124,7 @@ export class SloOrphanSummaryCleanupTask { searchAfter?: AggregationsCompositeAggregateKey; sloSummaryIds: Array<{ id: string; revision: number }>; }> => { - this.logger.debug(`[SLO] Fetching SLO Summaries ids after ${searchAfter}`); + this.logger.debug(`[TASK] Fetching SLO Summary ids after ${searchAfter}`); if (!this.esClient) { return { searchAfter: undefined, @@ -227,7 +227,9 @@ export class SloOrphanSummaryCleanupTask { this.esClient = esClient; if (!taskManager) { - this.logger.info('[SLO] Missing required service during startup, skipping task.'); + this.logger.info( + 'Missing required service during startup, skipping orphan-slo-summary-cleanup task.' + ); return; } diff --git a/x-pack/solutions/observability/plugins/slo/server/services/transform_generators/common.ts b/x-pack/solutions/observability/plugins/slo/server/services/transform_generators/common.ts index 35a6e180650fa..4958a65a17a15 100644 --- a/x-pack/solutions/observability/plugins/slo/server/services/transform_generators/common.ts +++ b/x-pack/solutions/observability/plugins/slo/server/services/transform_generators/common.ts @@ -39,7 +39,7 @@ export function parseStringFilters(filters: string, logger: Logger) { try { return JSON.parse(filters); } catch (e) { - logger.error(`Failed to parse filters: ${e.message}`); + logger.info(`Failed to parse filters: ${e}`); } return {}; diff --git a/x-pack/solutions/observability/plugins/slo/server/services/transform_manager.ts b/x-pack/solutions/observability/plugins/slo/server/services/transform_manager.ts index 464d1f1aeaa59..c07c8d78a5ca4 100644 --- a/x-pack/solutions/observability/plugins/slo/server/services/transform_manager.ts +++ b/x-pack/solutions/observability/plugins/slo/server/services/transform_manager.ts @@ -46,7 +46,9 @@ export class DefaultTransformManager implements TransformManager { } ); } catch (err) { - this.logger.error(`Cannot create SLO transform for indicator type [${slo.indicator.type}]`); + this.logger.error( + `Cannot create SLO transform for indicator type [${slo.indicator.type}]. ${err}` + ); if (err.meta?.body?.error?.type === 'security_exception') { throw new SecurityException(err.meta.body.error.reason); } @@ -77,7 +79,7 @@ export class DefaultTransformManager implements TransformManager { { logger: this.logger } ); } catch (err) { - this.logger.error(`Cannot preview SLO transform [${transformId}]`); + this.logger.error(`Cannot preview SLO transform [${transformId}]. ${err}`); throw err; } } @@ -94,7 +96,7 @@ export class DefaultTransformManager implements TransformManager { ); await this.scheduleNowTransform(transformId); } catch (err) { - this.logger.error(`Cannot start SLO transform [${transformId}]`); + this.logger.error(`Cannot start SLO transform [${transformId}]. ${err}`); throw err; } } @@ -110,7 +112,7 @@ export class DefaultTransformManager implements TransformManager { { logger: this.logger } ); } catch (err) { - this.logger.error(`Cannot stop SLO transform [${transformId}]`); + this.logger.error(`Cannot stop SLO transform [${transformId}]. ${err}`); throw err; } } @@ -126,7 +128,7 @@ export class DefaultTransformManager implements TransformManager { { logger: this.logger } ); } catch (err) { - this.logger.error(`Cannot delete SLO transform [${transformId}]`); + this.logger.error(`Cannot delete SLO transform [${transformId}]. ${err}`); throw err; } } @@ -138,8 +140,7 @@ export class DefaultTransformManager implements TransformManager { this.logger.debug(`SLO transform [${transformId}] scheduled now successfully`); }) .catch((e) => { - this.logger.error(`Cannot schedule now SLO transform [${transformId}]`); - this.logger.error(e); + this.logger.error(`Cannot schedule now SLO transform [${transformId}]. ${e}`); }); } } diff --git a/x-pack/solutions/observability/plugins/slo/server/services/update_slo.ts b/x-pack/solutions/observability/plugins/slo/server/services/update_slo.ts index 402ca82acecd4..30d62140f80d9 100644 --- a/x-pack/solutions/observability/plugins/slo/server/services/update_slo.ts +++ b/x-pack/solutions/observability/plugins/slo/server/services/update_slo.ts @@ -103,14 +103,14 @@ export class UpdateSLO { ); } catch (err) { this.logger.error( - `Cannot update the SLO summary pipeline [id: ${updatedSlo.id}, revision: ${updatedSlo.revision}].` + `Cannot update the SLO summary pipeline [id: ${updatedSlo.id}, revision: ${updatedSlo.revision}]. ${err}` ); await asyncForEach(rollbackOperations.reverse(), async (operation) => { try { await operation(); } catch (rollbackErr) { - this.logger.error('Rollback operation failed', rollbackErr); + this.logger.error(`Rollback operation failed. ${rollbackErr}`); } }); @@ -182,14 +182,14 @@ export class UpdateSLO { ); } catch (err) { this.logger.error( - `Cannot update the SLO [id: ${updatedSlo.id}, revision: ${updatedSlo.revision}]. Rolling back.` + `Cannot update the SLO [id: ${updatedSlo.id}, revision: ${updatedSlo.revision}]. Rolling back. ${err}` ); await asyncForEach(rollbackOperations.reverse(), async (operation) => { try { await operation(); } catch (rollbackErr) { - this.logger.error('Rollback operation failed', rollbackErr); + this.logger.error(`Rollback operation failed. ${rollbackErr}`); } });