Add stabilizing to UI

Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
This commit is contained in:
Julien Pivotto 2023-01-19 11:33:54 +01:00
parent 8e500dbd39
commit 2c408289f8
4 changed files with 22 additions and 13 deletions

View file

@ -539,6 +539,7 @@ func (r *AlertingRule) String() string {
Alert: r.name,
Expr: r.vector.String(),
For: model.Duration(r.holdDuration),
KeepFiringFor: model.Duration(r.keepFiringFor),
Labels: r.labels.Map(),
Annotations: r.annotations.Map(),
}

View file

@ -1115,7 +1115,7 @@ type Alert struct {
Annotations labels.Labels `json:"annotations"`
State string `json:"state"`
ActiveAt *time.Time `json:"activeAt,omitempty"`
KeepFiringSince *time.Time `json:"keep_firing_since,omitempty"`
KeepFiringSince *time.Time `json:"keepFiringSince,omitempty"`
Value string `json:"value"`
}
@ -1143,9 +1143,11 @@ func rulesAlertsToAPIAlerts(rulesAlerts []*rules.Alert) []*Alert {
Annotations: ruleAlert.Annotations,
State: ruleAlert.State.String(),
ActiveAt: &ruleAlert.ActiveAt,
KeepFiringSince: &ruleAlert.KeepFiringSince,
Value: strconv.FormatFloat(ruleAlert.Value, 'e', -1, 64),
}
if !ruleAlert.KeepFiringSince.IsZero() {
apiAlerts[i].KeepFiringSince = &ruleAlert.KeepFiringSince
}
}
return apiAlerts

View file

@ -29,6 +29,7 @@ export interface Alert {
value: string;
annotations: Record<string, string>;
activeAt: string;
keepFiringSince: string;
}
interface RuleGroup {

View file

@ -96,9 +96,14 @@ const CollapsibleAlertPanel: FC<CollapsibleAlertPanelProps> = ({ rule, showAnnot
</td>
<td>
<h5 className="m-0">
<Badge color={alertColors[alert.state] + ' text-uppercase'} className="px-3">
<Badge color={alertColors[alert.state] + ' text-uppercase'} className="px-3 mr-1">
{alert.state}
</Badge>
{alert.keepFiringSince && (
<Badge color="secondary" className="px-3">
Stabilizing
</Badge>
)}
</h5>
</td>
<td>{alert.activeAt}</td>