fix: correlate log alert recovery lifecycle

This commit is contained in:
zxr
2026-07-21 22:15:59 +08:00
parent eaca3d0ac8
commit 8495fdf039
6 changed files with 194 additions and 99 deletions

View File

@@ -38,6 +38,7 @@ type AlertReceiveBody struct {
Labels map[string]string `json:"labels"`
Agent string `json:"agent"`
PolicyID uint `json:"policy_id"`
Fingerprint string `json:"fingerprint,omitempty"`
State string `json:"state,omitempty"`
SourceEventKey string `json:"source_event_key"`
TraceID string `json:"trace_id"`
@@ -104,6 +105,9 @@ func forwardAlert(body AlertReceiveBody) error {
(details.Status != "firing" && details.Status != "resolved") || !validFingerprint(details.Fingerprint) {
return fmt.Errorf("Alert 响应缺少完整写入结果,无法确认转发成功;请稍后重试")
}
if body.Fingerprint != "" && details.Fingerprint != body.Fingerprint {
return fmt.Errorf("Alert 返回的告警指纹与请求不一致;请稍后重试")
}
return nil
}