diff --git a/x-pack/solutions/observability/plugins/observability/server/lib/annotations/register_annotation_apis.ts b/x-pack/solutions/observability/plugins/observability/server/lib/annotations/register_annotation_apis.ts index 5df2ed8d0e682..5cd95c5828a77 100644 --- a/x-pack/solutions/observability/plugins/observability/server/lib/annotations/register_annotation_apis.ts +++ b/x-pack/solutions/observability/plugins/observability/server/lib/annotations/register_annotation_apis.ts @@ -78,12 +78,19 @@ export function registerAnnotationAPIs({ return response.ok({ body: res, }); - } catch (err) { - logger.error(err); + } catch (error) { + const statusCode = error.output?.statusCode ?? 500; + const errorMessage = error.output?.payload?.message ?? 'An internal server error occurred'; + if (statusCode >= 500) { + logger.error(errorMessage, { error }); + } else { + logger.debug(errorMessage, { error }); + } + return response.custom({ - statusCode: err.output?.statusCode ?? 500, + statusCode, body: { - message: err.output?.payload?.message ?? 'An internal server error occurred', + message: errorMessage, }, }); } diff --git a/x-pack/solutions/observability/plugins/observability/server/services/related_dashboards_client.ts b/x-pack/solutions/observability/plugins/observability/server/services/related_dashboards_client.ts index 52a323daad307..b15ca35464df5 100644 --- a/x-pack/solutions/observability/plugins/observability/server/services/related_dashboards_client.ts +++ b/x-pack/solutions/observability/plugins/observability/server/services/related_dashboards_client.ts @@ -106,7 +106,7 @@ export class RelatedDashboardsClient { const panels = d.attributes.panels; const matchingPanels = this.getPanelsByIndex(index, panels); if (matchingPanels.length > 0) { - this.logger.info( + this.logger.debug( () => `Found ${matchingPanels.length} panel(s) in dashboard ${d.id} using index ${index}` ); relevantDashboards.push({ @@ -151,7 +151,7 @@ export class RelatedDashboardsClient { matchingPanels.map((p) => Array.from(p.matchingFields)).flat() ); if (matchingPanels.length > 0) { - this.logger.info( + this.logger.debug( () => `Found ${matchingPanels.length} panel(s) in dashboard ${ d.id diff --git a/x-pack/solutions/observability/plugins/observability/server/utils/create_or_update_index.ts b/x-pack/solutions/observability/plugins/observability/server/utils/create_or_update_index.ts index 5ecf298f361d9..8f39c085e2400 100644 --- a/x-pack/solutions/observability/plugins/observability/server/utils/create_or_update_index.ts +++ b/x-pack/solutions/observability/plugins/observability/server/utils/create_or_update_index.ts @@ -54,8 +54,7 @@ export async function createOrUpdateIndex({ }, { onFailedAttempt: (e) => { - logger.warn(`Could not create index: '${index}'. Retrying...`); - logger.warn(e); + logger.warn(`Could not create index: '${index}'. Retrying...`, { error: e }); }, } ); diff --git a/x-pack/solutions/observability/plugins/observability/server/utils/create_or_update_index_template.ts b/x-pack/solutions/observability/plugins/observability/server/utils/create_or_update_index_template.ts index cebdbaec8d0e3..41328b397bd12 100644 --- a/x-pack/solutions/observability/plugins/observability/server/utils/create_or_update_index_template.ts +++ b/x-pack/solutions/observability/plugins/observability/server/utils/create_or_update_index_template.ts @@ -44,12 +44,15 @@ export async function createOrUpdateIndexTemplate({ }, { onFailedAttempt: (e) => { - logger.warn(`Could not create index template: '${indexTemplate.name}'. Retrying...`); - logger.warn(e); + logger.warn(`Could not create index template: '${indexTemplate.name}'. Retrying...`, { + error: e, + }); }, } ); } catch (e) { - logger.error(`Could not create index template: '${indexTemplate.name}'. Error: ${e.message}.`); + logger.error(`Could not create index template: '${indexTemplate.name}'. Error: ${e.message}.`, { + error: e, + }); } }