mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-11 13:57:36 -08:00
Add stabilizing to UI
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
This commit is contained in:
parent
8e500dbd39
commit
2c408289f8
|
@ -536,11 +536,12 @@ func (r *AlertingRule) sendAlerts(ctx context.Context, ts time.Time, resendDelay
|
||||||
|
|
||||||
func (r *AlertingRule) String() string {
|
func (r *AlertingRule) String() string {
|
||||||
ar := rulefmt.Rule{
|
ar := rulefmt.Rule{
|
||||||
Alert: r.name,
|
Alert: r.name,
|
||||||
Expr: r.vector.String(),
|
Expr: r.vector.String(),
|
||||||
For: model.Duration(r.holdDuration),
|
For: model.Duration(r.holdDuration),
|
||||||
Labels: r.labels.Map(),
|
KeepFiringFor: model.Duration(r.keepFiringFor),
|
||||||
Annotations: r.annotations.Map(),
|
Labels: r.labels.Map(),
|
||||||
|
Annotations: r.annotations.Map(),
|
||||||
}
|
}
|
||||||
|
|
||||||
byt, err := yaml.Marshal(ar)
|
byt, err := yaml.Marshal(ar)
|
||||||
|
|
|
@ -1115,7 +1115,7 @@ type Alert struct {
|
||||||
Annotations labels.Labels `json:"annotations"`
|
Annotations labels.Labels `json:"annotations"`
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
ActiveAt *time.Time `json:"activeAt,omitempty"`
|
ActiveAt *time.Time `json:"activeAt,omitempty"`
|
||||||
KeepFiringSince *time.Time `json:"keep_firing_since,omitempty"`
|
KeepFiringSince *time.Time `json:"keepFiringSince,omitempty"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1139,12 +1139,14 @@ func rulesAlertsToAPIAlerts(rulesAlerts []*rules.Alert) []*Alert {
|
||||||
apiAlerts := make([]*Alert, len(rulesAlerts))
|
apiAlerts := make([]*Alert, len(rulesAlerts))
|
||||||
for i, ruleAlert := range rulesAlerts {
|
for i, ruleAlert := range rulesAlerts {
|
||||||
apiAlerts[i] = &Alert{
|
apiAlerts[i] = &Alert{
|
||||||
Labels: ruleAlert.Labels,
|
Labels: ruleAlert.Labels,
|
||||||
Annotations: ruleAlert.Annotations,
|
Annotations: ruleAlert.Annotations,
|
||||||
State: ruleAlert.State.String(),
|
State: ruleAlert.State.String(),
|
||||||
ActiveAt: &ruleAlert.ActiveAt,
|
ActiveAt: &ruleAlert.ActiveAt,
|
||||||
KeepFiringSince: &ruleAlert.KeepFiringSince,
|
Value: strconv.FormatFloat(ruleAlert.Value, 'e', -1, 64),
|
||||||
Value: strconv.FormatFloat(ruleAlert.Value, 'e', -1, 64),
|
}
|
||||||
|
if !ruleAlert.KeepFiringSince.IsZero() {
|
||||||
|
apiAlerts[i].KeepFiringSince = &ruleAlert.KeepFiringSince
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ export interface Alert {
|
||||||
value: string;
|
value: string;
|
||||||
annotations: Record<string, string>;
|
annotations: Record<string, string>;
|
||||||
activeAt: string;
|
activeAt: string;
|
||||||
|
keepFiringSince: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RuleGroup {
|
interface RuleGroup {
|
||||||
|
|
|
@ -96,9 +96,14 @@ const CollapsibleAlertPanel: FC<CollapsibleAlertPanelProps> = ({ rule, showAnnot
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<h5 className="m-0">
|
<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}
|
{alert.state}
|
||||||
</Badge>
|
</Badge>
|
||||||
|
{alert.keepFiringSince && (
|
||||||
|
<Badge color="secondary" className="px-3">
|
||||||
|
Stabilizing
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
</h5>
|
</h5>
|
||||||
</td>
|
</td>
|
||||||
<td>{alert.activeAt}</td>
|
<td>{alert.activeAt}</td>
|
||||||
|
|
Loading…
Reference in a new issue