diff --git a/x-pack/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts index bb7f7f6d2dc93..3c596695e24fa 100644 --- a/x-pack/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { i18n } from '@kbn/i18n'; import { flatten } from 'lodash'; import { InfraMetric, InfraMetricData, InfraNodeType } from '../../../../common/graphql/types'; import { InfraBackendFrameworkAdapter, InfraFrameworkRequest } from '../framework'; @@ -44,7 +45,14 @@ export class KibanaMetricsAdapter implements InfraMetricsAdapter { const validNode = await checkValidNode(search, indexPattern, nodeField, options.nodeId); if (!validNode) { - throw new Error(`${options.nodeId} does not exist.`); + throw new Error( + i18n.translate('xpack.infra.kibanaMetrics.nodeDoesNotExistErrorMessage', { + defaultMessage: '{nodeId} does not exist.', + values: { + nodeId: options.nodeId, + }, + }) + ); } const requests = options.metrics.map(metricId => { @@ -59,7 +67,14 @@ export class KibanaMetricsAdapter implements InfraMetricsAdapter { return metricIds.map((id: string) => { const infraMetricId: InfraMetric = (InfraMetric as any)[id]; if (!infraMetricId) { - throw new Error(`${id} is not a valid InfraMetric`); + throw new Error( + i18n.translate('xpack.infra.kibanaMetrics.invalidInfraMetricErrorMessage', { + defaultMessage: '{id} is not a valid InfraMetric', + values: { + id, + }, + }) + ); } const panel = result[infraMetricId]; return { diff --git a/x-pack/plugins/infra/server/lib/sources.ts b/x-pack/plugins/infra/server/lib/sources.ts index 4bf9ce6c61f0e..43f066c9e3f30 100644 --- a/x-pack/plugins/infra/server/lib/sources.ts +++ b/x-pack/plugins/infra/server/lib/sources.ts @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +import { i18n } from '@kbn/i18n'; export class InfraSources { constructor(private readonly adapter: InfraSourcesAdapter) {} @@ -12,7 +13,14 @@ export class InfraSources { const requestedSourceConfiguration = sourceConfigurations[sourceId]; if (!requestedSourceConfiguration) { - throw new Error(`Failed to find source '${sourceId}'`); + throw new Error( + i18n.translate('xpack.infra.infraSources.failedToFindSourceErrorMessage', { + defaultMessage: 'Failed to find source {sourceId}', + values: { + sourceId: `'${sourceId}'`, + }, + }) + ); } return requestedSourceConfiguration;