From e128dfcb284692c9b4042395b01f6d2d6df554ae Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:33:49 +1100 Subject: [PATCH] [8.x] [DataUsage][Serverless] Fix AutoOps error message to drop "agent" reference (#202996) (#203190) # Backport This will backport the following commits from `main` to `8.x`: - [[DataUsage][Serverless] Fix AutoOps error message to drop "agent" reference (#202996)](https://github.com/elastic/kibana/pull/202996) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Chris Earle --- .../data_usage/server/services/autoops_api.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/data_usage/server/services/autoops_api.ts b/x-pack/plugins/data_usage/server/services/autoops_api.ts index d98b0c507fe14..8f371d3004def 100644 --- a/x-pack/plugins/data_usage/server/services/autoops_api.ts +++ b/x-pack/plugins/data_usage/server/services/autoops_api.ts @@ -24,8 +24,7 @@ import { AutoOpsConfig } from '../types'; import { AutoOpsError } from './errors'; import { appContextService } from './app_context'; -const AGENT_CREATION_FAILED_ERROR = 'AutoOps API could not create the autoops agent'; -const AUTO_OPS_AGENT_CREATION_PREFIX = '[AutoOps API] Creating autoops agent failed'; +const AUTO_OPS_REQUEST_FAILED_PREFIX = '[AutoOps API] Request failed'; const AUTO_OPS_MISSING_CONFIG_ERROR = 'Missing autoops configuration'; const getAutoOpsAPIRequestUrl = (url?: string, projectId?: string): string => @@ -120,7 +119,7 @@ export class AutoOpsAPIService { (error: Error | AxiosError) => { if (!axios.isAxiosError(error)) { this.logger.error( - `${AUTO_OPS_AGENT_CREATION_PREFIX} with an error ${error} ${requestConfigDebugStatus}`, + `${AUTO_OPS_REQUEST_FAILED_PREFIX} with an error ${error}, request config: ${requestConfigDebugStatus}`, errorMetadataWithRequestConfig ); throw new AutoOpsError(withRequestIdMessage(error.message)); @@ -131,9 +130,11 @@ export class AutoOpsAPIService { if (error.response) { // The request was made and the server responded with a status code and error data this.logger.error( - `${AUTO_OPS_AGENT_CREATION_PREFIX} because the AutoOps API responded with a status code that falls out of the range of 2xx: ${JSON.stringify( + `${AUTO_OPS_REQUEST_FAILED_PREFIX} because the AutoOps API responded with a status code that falls out of the range of 2xx: ${JSON.stringify( error.response.status - )}} ${JSON.stringify(error.response.data)}} ${requestConfigDebugStatus}`, + )}} ${JSON.stringify( + error.response.data + )}}, request config: ${requestConfigDebugStatus}`, { ...errorMetadataWithRequestConfig, http: { @@ -145,22 +146,22 @@ export class AutoOpsAPIService { }, } ); - throw new AutoOpsError(withRequestIdMessage(AGENT_CREATION_FAILED_ERROR)); + throw new AutoOpsError(withRequestIdMessage(AUTO_OPS_REQUEST_FAILED_PREFIX)); } else if (error.request) { // The request was made but no response was received this.logger.error( - `${AUTO_OPS_AGENT_CREATION_PREFIX} while sending the request to the AutoOps API: ${errorLogCodeCause} ${requestConfigDebugStatus}`, + `${AUTO_OPS_REQUEST_FAILED_PREFIX} while sending the request to the AutoOps API: ${errorLogCodeCause}, request config: ${requestConfigDebugStatus}`, errorMetadataWithRequestConfig ); throw new AutoOpsError(withRequestIdMessage(`no response received from the AutoOps API`)); } else { // Something happened in setting up the request that triggered an Error this.logger.error( - `${AUTO_OPS_AGENT_CREATION_PREFIX} to be created ${errorLogCodeCause} ${requestConfigDebugStatus} ${error.toJSON()}`, + `${AUTO_OPS_REQUEST_FAILED_PREFIX} with ${errorLogCodeCause}, request config: ${requestConfigDebugStatus}, error: ${error.toJSON()}`, errorMetadataWithRequestConfig ); throw new AutoOpsError( - withRequestIdMessage(`${AGENT_CREATION_FAILED_ERROR}, ${error.message}`) + withRequestIdMessage(`${AUTO_OPS_REQUEST_FAILED_PREFIX}, ${error.message}`) ); } }