[Metrics UI] Display No Data context.values as [NO DATA] (#78038)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
a61f4d4cbf
commit
7836998e76
|
@ -148,8 +148,10 @@ export const FIRED_ACTIONS = {
|
||||||
|
|
||||||
const formatMetric = (metric: SnapshotMetricType, value: number) => {
|
const formatMetric = (metric: SnapshotMetricType, value: number) => {
|
||||||
const metricFormatter = get(METRIC_FORMATTERS, metric, METRIC_FORMATTERS.count);
|
const metricFormatter = get(METRIC_FORMATTERS, metric, METRIC_FORMATTERS.count);
|
||||||
if (value == null) {
|
if (isNaN(value)) {
|
||||||
return '';
|
return i18n.translate('xpack.infra.metrics.alerting.inventory.noDataFormattedValue', {
|
||||||
|
defaultMessage: '[NO DATA]',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const formatter = createFormatter(metricFormatter.formatter, metricFormatter.template);
|
const formatter = createFormatter(metricFormatter.formatter, metricFormatter.template);
|
||||||
return formatter(value);
|
return formatter(value);
|
||||||
|
|
|
@ -131,11 +131,24 @@ const formatAlertResult = <AlertResult>(
|
||||||
} & AlertResult
|
} & AlertResult
|
||||||
) => {
|
) => {
|
||||||
const { metric, currentValue, threshold } = 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');
|
const formatter = createFormatter('percent');
|
||||||
return {
|
return {
|
||||||
...alertResult,
|
...alertResult,
|
||||||
currentValue: formatter(currentValue),
|
currentValue:
|
||||||
|
currentValue !== null && typeof currentValue !== 'undefined'
|
||||||
|
? formatter(currentValue)
|
||||||
|
: noDataValue,
|
||||||
threshold: Array.isArray(threshold) ? threshold.map((v: number) => formatter(v)) : threshold,
|
threshold: Array.isArray(threshold) ? threshold.map((v: number) => formatter(v)) : threshold,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue