mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fixes for pending period (#81718)
This commit is contained in:
parent
f2936d6695
commit
e1197641f3
@ -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
|
||||||
|
@ -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}</>;
|
||||||
},
|
},
|
||||||
|
@ -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}>
|
||||||
|
@ -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)
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user