[Metrics UI] Invalidate non-count alerts which have no metrics (#62837)

This commit is contained in:
Zacqary Adam Xeper 2020-04-08 12:39:59 -05:00 committed by GitHub
parent 1c718d6760
commit cbe479b8bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,6 +23,7 @@ export function validateMetricThreshold({
timeWindowSize: string[];
threshold0: string[];
threshold1: string[];
metric: string[];
};
} = {};
validationResult.errors = errors;
@ -41,6 +42,7 @@ export function validateMetricThreshold({
timeWindowSize: [],
threshold0: [],
threshold1: [],
metric: [],
};
if (!c.aggType) {
errors[id].aggField.push(
@ -73,6 +75,14 @@ export function validateMetricThreshold({
})
);
}
if (!c.metric && c.aggType !== 'count') {
errors[id].metric.push(
i18n.translate('xpack.infra.metrics.alertFlyout.error.metricRequired', {
defaultMessage: 'Metric is required.',
})
);
}
});
return validationResult;