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);
return millisFor >= millisEvery
? 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) {
// if we fail to parse "every", assume validation is successful, or the error messages
// will overlap in the UI

View File

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

View File

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

View File

@ -330,9 +330,7 @@ export function alertingRulerRuleToRuleForm(
> {
const defaultFormValues = getDefaultFormValues();
const [forTime, forTimeUnit] = rule.for
? parseInterval(rule.for)
: [defaultFormValues.forTime, defaultFormValues.forTimeUnit];
const [forTime, forTimeUnit] = rule.for ? parseInterval(rule.for) : [0, 's'];
const [keepFiringForTime, keepFiringForTimeUnit] = 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)) {
return {
alertName: alert.alert,
forDuration: alert.for ?? '1m',
evaluationsToFire: getNumberEvaluationsToStartAlerting(alert.for ?? '1m', currentEvaluation),
forDuration: alert.for ?? '0s',
evaluationsToFire: getNumberEvaluationsToStartAlerting(alert.for ?? '0s', currentEvaluation),
};
}
return emptyAlert;