diff --git a/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.ts b/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.ts index 99904f15b460..b56ede197439 100644 --- a/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.ts +++ b/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.ts @@ -148,8 +148,10 @@ export const FIRED_ACTIONS = { const formatMetric = (metric: SnapshotMetricType, value: number) => { const metricFormatter = get(METRIC_FORMATTERS, metric, METRIC_FORMATTERS.count); - if (value == null) { - return ''; + if (isNaN(value)) { + return i18n.translate('xpack.infra.metrics.alerting.inventory.noDataFormattedValue', { + defaultMessage: '[NO DATA]', + }); } const formatter = createFormatter(metricFormatter.formatter, metricFormatter.template); return formatter(value); diff --git a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/metric_threshold_executor.ts b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/metric_threshold_executor.ts index c85685b4cdca..4dec552c5bd6 100644 --- a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/metric_threshold_executor.ts +++ b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/metric_threshold_executor.ts @@ -131,11 +131,24 @@ const formatAlertResult = ( } & AlertResult ) => { const { metric, currentValue, threshold } = alertResult; - if (!metric.endsWith('.pct')) return alertResult; + const noDataValue = i18n.translate( + 'xpack.infra.metrics.alerting.threshold.noDataFormattedValue', + { + defaultMessage: '[NO DATA]', + } + ); + if (!metric.endsWith('.pct')) + return { + ...alertResult, + currentValue: currentValue ?? noDataValue, + }; const formatter = createFormatter('percent'); return { ...alertResult, - currentValue: formatter(currentValue), + currentValue: + currentValue !== null && typeof currentValue !== 'undefined' + ? formatter(currentValue) + : noDataValue, threshold: Array.isArray(threshold) ? threshold.map((v: number) => formatter(v)) : threshold, }; };