Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 => {
Expand All @@ -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 {
Expand Down
10 changes: 9 additions & 1 deletion x-pack/plugins/infra/server/lib/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand All @@ -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;
Expand Down