Skip to content

Commit

Permalink
Invalidate non-count alerts which have no metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacqary committed Apr 7, 2020
1 parent d707184 commit 065d2c3
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function validateMetricThreshold({
timeWindowSize: string[];
threshold0: string[];
threshold1: string[];
metric: string[];
};
} = {};
validationResult.errors = errors;
Expand All @@ -42,6 +43,7 @@ export function validateMetricThreshold({
timeWindowSize: [],
threshold0: [],
threshold1: [],
metric: [],
};
if (!c.aggType) {
errors[id].aggField.push(
Expand Down Expand Up @@ -74,6 +76,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;
Expand Down

0 comments on commit 065d2c3

Please sign in to comment.