Alerting: Fixes for pending period (#81718)

This commit is contained in:
Gilles De Mey 2024-02-02 12:58:04 +01:00 committed by GitHub
parent f2936d6695
commit e1197641f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 13 deletions

View File

@ -57,7 +57,7 @@ const forValidationOptions = (evaluateEvery: string): RegisterOptions => ({
const millisEvery = parsePrometheusDuration(evaluateEvery); const millisEvery = parsePrometheusDuration(evaluateEvery);
return millisFor >= millisEvery return millisFor >= millisEvery
? true ? true
: 'For duration must be greater than or equal to the evaluation interval.'; : 'Pending period must be greater than or equal to the evaluation interval.';
} catch (err) { } catch (err) {
// if we fail to parse "every", assume validation is successful, or the error messages // if we fail to parse "every", assume validation is successful, or the error messages
// will overlap in the UI // will overlap in the UI

View File

@ -82,7 +82,7 @@ export const RulesForGroupTable = ({ rulesWithoutRecordingRules }: { rulesWithou
}, },
{ {
id: 'for', id: 'for',
label: 'For', label: 'Pending period',
renderCell: ({ data: { forDuration } }) => { renderCell: ({ data: { forDuration } }) => {
return <>{forDuration}</>; return <>{forDuration}</>;
}, },

View File

@ -72,7 +72,7 @@ const EvaluationBehaviorSummary = ({ rule }: EvaluationBehaviorSummaryProps) =>
// recording rules don't have a for duration // recording rules don't have a for duration
if (!isRecordingRulerRule(rule.rulerRule)) { if (!isRecordingRulerRule(rule.rulerRule)) {
forDuration = rule.rulerRule?.for; forDuration = rule.rulerRule?.for ?? '0s';
} }
return ( return (
@ -82,11 +82,10 @@ const EvaluationBehaviorSummary = ({ rule }: EvaluationBehaviorSummaryProps) =>
Every {every} Every {every}
</DetailsField> </DetailsField>
)} )}
{forDuration && (
<DetailsField label="For" horizontal={true}> <DetailsField label="Pending period" horizontal={true}>
{forDuration} {forDuration}
</DetailsField> </DetailsField>
)}
{lastEvaluation && !isNullDate(lastEvaluation) && ( {lastEvaluation && !isNullDate(lastEvaluation) && (
<DetailsField label="Last evaluation" horizontal={true}> <DetailsField label="Last evaluation" horizontal={true}>

View File

@ -330,9 +330,7 @@ export function alertingRulerRuleToRuleForm(
> { > {
const defaultFormValues = getDefaultFormValues(); const defaultFormValues = getDefaultFormValues();
const [forTime, forTimeUnit] = rule.for const [forTime, forTimeUnit] = rule.for ? parseInterval(rule.for) : [0, 's'];
? parseInterval(rule.for)
: [defaultFormValues.forTime, defaultFormValues.forTimeUnit];
const [keepFiringForTime, keepFiringForTimeUnit] = rule.keep_firing_for const [keepFiringForTime, keepFiringForTimeUnit] = rule.keep_firing_for
? parseInterval(rule.keep_firing_for) ? parseInterval(rule.keep_firing_for)

View File

@ -229,8 +229,8 @@ export const getAlertInfo = (alert: RulerRuleDTO, currentEvaluation: string): Al
if (isAlertingRulerRule(alert)) { if (isAlertingRulerRule(alert)) {
return { return {
alertName: alert.alert, alertName: alert.alert,
forDuration: alert.for ?? '1m', forDuration: alert.for ?? '0s',
evaluationsToFire: getNumberEvaluationsToStartAlerting(alert.for ?? '1m', currentEvaluation), evaluationsToFire: getNumberEvaluationsToStartAlerting(alert.for ?? '0s', currentEvaluation),
}; };
} }
return emptyAlert; return emptyAlert;